I'm trying to get a simple 1-N FK relationship working with DataNucleus JDO. I have classes GridDO and GridColumnDO with relevant getters and setters. I'm trying to establish that a grid has multiple columns. The entity_attribute (GridColumn) table has a FK column (named entity_id) to the entity (Grid) table's PK (also named entity_id). I worked off of the example code on the DataNucleus website. I can load the GridDO object, but when I try to get the columns, I get
Iteration request failed : SELECT 'com.mycompany.myapplication.data.GridColumnDO' AS NUCLEUS_TYPE,A0.DISPLAY_NAME,A0.COLUMN_ORDER,A0.PROPERTY_NAME,A0.ENTITY_ID,A0.ENTITY_ATTRIBUTE_ID,A0.VALUE_TYPE FROM ENTITY_ATTRIBUTE A0 WHERE A0.ENTITY_ID = ?
org.datanucleus.exceptions.NucleusDataStoreException: Iteration request failed : SELECT 'com.mycompany.myapplication.data.GridColumnDO' AS NUCLEUS_TYPE,A0.DISPLAY_NAME,A0.COLUMN_ORDER,A0.PROPERTY_NAME,A0.ENTITY_ID,A0.ENTITY_ATTRIBUTE_ID,A0.VALUE_TYPE FROM ENTITY_ATTRIBUTE A0 WHERE A0.ENTITY_ID = ?
...
Caused by: java.sql.SQLException: Parameter #1 has not been set.
Does anybody know what I might be doing wrong? I've been searching and banging at this for a while now, with no real luck. This is an excerpt from package-mssql.orm:
<class name="GridDO" identity-type="application" table="entity">
<field name="id" primary-key="true">
<column name="entity_id"/>
</field>
<field name="columns">
<collection element-type="com.mycompany.myapplication.data.GridColumnDO"/>
<element column="entity_id"/>
</field>
...
</class>
<class name="GridColumnDO" identity-type="application" table="entity_attribute">
<field name="id" primary-key="true">
<column name="entity_attribute_id"/>
</field>
...
</class>
The issue was that PersistenceCapable and PrimaryKey must either both be identified via annotations or both be identified via metadata. I had PersistenceCapable in an annotation and PrimaryKey in my .orm file.