one-to-many with a column name which is the same name as a identifier column
name no generate insert="false" update="false"
----------------------------------------------------------------------------------------------------------------------------
Key: HIB-196
URL: http://jira.andromda.org/browse/HIB-196
Project: Hibernate Cartridge
Type: Bug
Reporter: David Valdeita
Assigned to: Carlos Cuenca
I need to map a legacy schema and i have composite keys with column names which
attributes are in one-to-many association... see hibernate composite key
example in the reference guide...
in this situation the insert="false" update="false" is needed since the colum
name is already defined in the primary key. In andromda the entity asociated is
always null if this insert="false" update="false" are not setted.
meantime im working with this ugly patch...
--- hibernate.hbm.xml.vm.old 2006-09-30 02:31:22.000000000 +0200
+++ hibernate.hbm.xml.vm.new 2006-10-10 12:49:14.000000000 +0200
@@ -80,7 +80,23 @@
${indent} <one-to-many
class="$otherEnd.type.fullyQualifiedEntityImplementationName"/>
${indent}</$otherEnd.collectionType>
#elseif ($sourceEnd.many2One && !$sourceEnd.identifiersPresent)
-${indent}<many-to-one name="$otherEnd.name"
class="$otherEnd.type.fullyQualifiedEntityImplementationName"#if
($otherEnd.hibernateCascade) cascade="$otherEnd.hibernateCascade"#end
foreign-key="$otherEnd.foreignKeyConstraintName"#if($otherEnd.columnIndex)
index="$otherEnd.columnIndex"#end#if($otherEnd.lazy) lazy="proxy"
fetch="select"#else lazy="false" fetch="$otherEnd.outerJoin"#end#if
($otherEnd.xmlTagName) node="$otherEnd.xmlTagName"#end#if ($sourceEnd.embedXML)
embed-xml="$sourceEnd.embedXML"#end#if ($sourceEnd.list) insert="false"
update="false" not-null="$otherEnd.required"#end>
+#set($sameColumnName="false")
+#if (!$otherEnd.type.compositeIdentifier)
+#foreach ($attribute in $entity.attributes)
+#if ($attribute.columnName == $otherEnd.columnName)
+#set($sameColumnName="true")
+#end
+#end
+#else
+#foreach ($identifier in ${sourceEnd.otherEnd.type.identifiers})
+#foreach ($attribute in $entity.attributes)
+#if($attribute.columnName == $identifier.columnName)
+#set($sameColumnName="true")
+#end
+#end
+#end
+#end
+${indent}<many-to-one name="$otherEnd.name"
class="$otherEnd.type.fullyQualifiedEntityImplementationName"#if
($otherEnd.hibernateCascade) cascade="$otherEnd.hibernateCascade"#end
foreign-key="$otherEnd.foreignKeyConstraintName"#if($otherEnd.columnIndex)
index="$otherEnd.columnIndex"#end#if($otherEnd.lazy) lazy="proxy"
fetch="select"#else lazy="false" fetch="$otherEnd.outerJoin"#end#if
($otherEnd.xmlTagName) node="$otherEnd.xmlTagName"#end#if ($sourceEnd.embedXML)
embed-xml="$sourceEnd.embedXML"#end#if ($sourceEnd.list || $sameColumnName
=="true") insert="false" update="false" not-null="$otherEnd.required"#end>
#if (!$otherEnd.type.compositeIdentifier)
${indent} <column name="$otherEnd.columnName" not-null="$otherEnd.required"
sql-type="$otherEnd.sqlType"/>
#else
--
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
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642