Message: A new issue has been created in JIRA.
--------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/xdoclet/browse/XDT-1430 Here is an overview of the issue: --------------------------------------------------------------------- Key: XDT-1430 Summary: Hibernate 3.0 collection-key does not support not-null Type: Bug Status: Open Priority: Major Original Estimate: Unknown Time Spent: Unknown Remaining: Unknown Project: XDoclet Components: Hibernate Module Versions: 1.2.3 Assignee: xdoclet-devel (Use for new issues) Reporter: Alexander Zinniker Created: Tue, 7 Jun 2005 4:01 AM Updated: Tue, 7 Jun 2005 4:01 AM Description: Since version 3 of Hibernate the collection-keys do support also the not-null attribute (and some others I did not checkout). But using Hibernatedoclet it was not possible to create the expeceted mapping. Hibernate 2 Mapping DTD: <!ELEMENT key (column*)> <!ATTLIST key column CDATA #IMPLIED> <!ATTLIST key foreign-key CDATA #IMPLIED> Hibernate 3 Mapping DTD: <!ELEMENT key (column*)> <!ATTLIST key column CDATA #IMPLIED> <!ATTLIST key property-ref CDATA #IMPLIED> <!ATTLIST key foreign-key CDATA #IMPLIED> <!ATTLIST key on-delete (cascade|noaction) "noaction"> <!ATTLIST key not-null (true|false) #IMPLIED> <!ATTLIST key update (true|false) #IMPLIED> <!ATTLIST key unique (true|false) #IMPLIED> The following Hibernatedoclet-Tags produce not the expected mapping: /** * @hibernate.set lazy="false" * cascade="all-delete-orphan" * inverse="false" * @hibernate.collection-key * column="FOO_ID" * not-null="true" * @hibernate.collection-one-to-many * class="Bar" */ public Collection getFoos() { return foos; } The mapping looks like this: <set name="foos" lazy="false" inverse="false" cascade="all-delete-orphan" sort="unsorted" > <key column="FOO_ID" > </key> <one-to-many class="Foo" /> </set> The main problem with this is, that when I remove an item from the list of Foos and commit the transaction, without having specified the foreign key as not null, Hibernate first tries to update the child record and set the foreign key to null. This of course is not liked by our database and results in a rollback of the complete transaction, as the foreign key is not allowed to be null (due to the objects lifecycle, which ends at this point). Modifying the key to <key column="FOO_ID" not-null="true"/> resolves the problem. I tried also to use the @hibernate.collection-key-column attributes, which resulted in a MappingException, they even did not produce a valid mapping. For myself I solved the problem by modifying the hibernate-collections.xdt by just adding the lines <XDtMethod:ifHasMethodTag tagName="hibernate.collection-key" paramName="not-null"> not-null="<XDtMethod:methodTagValue tagName="hibernate.collection-key" paramName="not-null" default="false" />" </XDtMethod:ifHasMethodTag> to the hibernate.collection-key element. Of course it would be great if the problem is solved in future versions. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/xdoclet/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira ------------------------------------------------------- This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput a projector? How fast can you ride your desk chair down the office luge track? If you want to score the big prize, get to know the little guy. Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20 _______________________________________________ xdoclet-devel mailing list xdoclet-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xdoclet-devel