bidirectional relations using List
----------------------------------
Key: HIB-215
URL: http://jira.andromda.org/browse/HIB-215
Project: Hibernate Cartridge
Type: Bug
Versions: 3.2-RC1
Environment: Andromda 3.2
Reporter: Jorge RodrÃguez Pedrianes
Assigned to: Carlos Cuenca
Hello, I'm trying to use biridectional relations whithin two entities but hbm
files are wrong. For example
E1 (1) ---------- E2(0..*)
The hbm file generated for E1 is not ok:
.......
<list name="e2" lazy="true" fetch="select" inverse="false"
cascade="all,delete-orphan">
<key foreign-key="E1_LIC" not-null="false">
<!-- This is bad, the correct is not-null="true" if i use list and E1 its
required-->
<column name="E1_FK" sql-type="BIGINT"/>
</key>
<list-index column="indice"/>
<one-to-many class="E2"/>
</list>
....
I see the hibernate template (hibernate.hbm.xml.vm) and i see the problem:
in one2Many section code you put:
${indent} <key
foreign-key="$sourceEnd.foreignKeyConstraintName"#if ($otherEnd.list)
not-null="$otherEnd.required"#end>
but i think that is better:
${indent} <key
foreign-key="$sourceEnd.foreignKeyConstraintName"#if ($otherEnd.list)
not-null="$sourceEnd.required"#end> <!-- if source end its
required -->
I read the hibernate reference and say:
"It is important that you define not-null="true" on the <key>
element of the collection mapping if the underlying
foreign key column is NOT NULL. Don't only declare
not-null="true" on a possible nested <column> element,
but on the <key> element."
Thanks
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.andromda.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/