
|
If you were logged in you would be able to see more operations.
|
|
|
JPOX Java5
Created: 26/Apr/07 10:50 PM
Updated: 17/Sep/07 09:19 AM
|
|
| Component/s: |
JDO
|
| Affects Version/s: |
1.2.0-beta-1,
1.2.0-beta-2
|
| Fix Version/s: |
1.2.0-beta-4
|
|
|
Please read the forum thread completely when considering this issue.
Essentially, I want to have all the flexibility of the XML metadata available in JDO 2.1 annotations. Case in point, it's not possible to specify the names of foreign keys to join tables using annotations alone, e.g.:
<field name="contacts" table="content_provider_contact">
<collection element-type="com.example.Contact"/>
<join>
<primary-key name="XPKcontent_provider_contact"/>
<column name="content_provider_id"/>
<foreign-key name="R_4" update-action="none" delete-action="none"/>
</join>
<element>
<column name="contact_id"/>
<foreign-key name="R_5" update-action="none" delete-action="none"/>
</element>
</field>
This metadata informs JDO that there should be a join table called "content_provider_contact" with a primary-key called "XPKcontent_provider_contact" that is a composite of the table's two columns: "content_provider_id" and "contact_id". Additionally, there should be a foreign-key named R_5 on "contact_id" and a foreign-key named "R_4" on "content_provider_id".
The naming of the foreign-keys and primary-key are not currently possible with the current rev of JDO 2.1 annotations.
Here is my proposal for how this level of granular functionality could be supported:
@Field(defaultFetchGroup = "true")
@Element(column = "contact_id", foreignKey=@ForeignKey(name="R_5")
@Join(table = "content_provider_contact", column = "content_provider_id",
primaryKey = @PrimaryKey(name = "XPKcontent_provider_contact")
foreignKey = @ForeignKey(name = "R_4")
private Set<Contact> contacts = new HashSet<Contact>();
(again, see the forum thread for more detail)
Please let me know if there are further questions or more detail necessary.
Here's my overall entreaty about this: I want to be able to map any DBA-crafted schema, detail-by-detail into jdo annotations, and then be able to generate that schema identically. Using XML metadata, this is possible (at least 98% of the time, anyway). Using annotations, it's not. I propose that annotations should have the full power of JDO XML metadata. I understand it is a dubious decision to embed ORM-specific information into one's class definitions, but once that decision has been made, it should be possible to flex all of JDO's functionality with them.
At the very least, so that this bug is actionable, I'm requesting that the example snippet above be implemented with corresponding language added to the 2.1 spec:
1) Allow @Join annotations at the field level to take a single primaryKey and single foreignKey attribute.
2) Allow @Element annotations at the field level to take a single foreignKey attribute.
This meets my immediate neeeds, but I'm sure there are other cases of 'missing annotation functionality' that are desirable to get into the 2.1 timeline; if you have any such requests, please add them in separate issues and link to them here.
|
|
Description
|
Please read the forum thread completely when considering this issue.
Essentially, I want to have all the flexibility of the XML metadata available in JDO 2.1 annotations. Case in point, it's not possible to specify the names of foreign keys to join tables using annotations alone, e.g.:
<field name="contacts" table="content_provider_contact">
<collection element-type="com.example.Contact"/>
<join>
<primary-key name="XPKcontent_provider_contact"/>
<column name="content_provider_id"/>
<foreign-key name="R_4" update-action="none" delete-action="none"/>
</join>
<element>
<column name="contact_id"/>
<foreign-key name="R_5" update-action="none" delete-action="none"/>
</element>
</field>
This metadata informs JDO that there should be a join table called "content_provider_contact" with a primary-key called "XPKcontent_provider_contact" that is a composite of the table's two columns: "content_provider_id" and "contact_id". Additionally, there should be a foreign-key named R_5 on "contact_id" and a foreign-key named "R_4" on "content_provider_id".
The naming of the foreign-keys and primary-key are not currently possible with the current rev of JDO 2.1 annotations.
Here is my proposal for how this level of granular functionality could be supported:
@Field(defaultFetchGroup = "true")
@Element(column = "contact_id", foreignKey=@ForeignKey(name="R_5")
@Join(table = "content_provider_contact", column = "content_provider_id",
primaryKey = @PrimaryKey(name = "XPKcontent_provider_contact")
foreignKey = @ForeignKey(name = "R_4")
private Set<Contact> contacts = new HashSet<Contact>();
(again, see the forum thread for more detail)
Please let me know if there are further questions or more detail necessary.
Here's my overall entreaty about this: I want to be able to map any DBA-crafted schema, detail-by-detail into jdo annotations, and then be able to generate that schema identically. Using XML metadata, this is possible (at least 98% of the time, anyway). Using annotations, it's not. I propose that annotations should have the full power of JDO XML metadata. I understand it is a dubious decision to embed ORM-specific information into one's class definitions, but once that decision has been made, it should be possible to flex all of JDO's functionality with them.
At the very least, so that this bug is actionable, I'm requesting that the example snippet above be implemented with corresponding language added to the 2.1 spec:
1) Allow @Join annotations at the field level to take a single primaryKey and single foreignKey attribute.
2) Allow @Element annotations at the field level to take a single foreignKey attribute.
This meets my immediate neeeds, but I'm sure there are other cases of 'missing annotation functionality' that are desirable to get into the 2.1 timeline; if you have any such requests, please add them in separate issues and link to them here. |
Show » |
|