Hibernate composite key generation patch

Patrick Peralta <[email protected]>
Newsgroups gmane.comp.java.ejb.middlegen.user
Message-ID <[email protected]>
Hello list,

I was using Middlegen to generate *.hbm.xml files on my database which 
uses composite keys.  From there I generated the java classes using 
hbm2java (and these classes included the XDoclet tags as generated by 
Middlegen).  However, when I tried to regenerate the hbm files from the 
XDoclet tags in the source, the composite keys were not represented 
correctly.  I modified the hibernate.vm file in the hibernate plugin jar 
  to produce the correct XDoclet tags.  Please review my patch and feel 
free to use it if it is correct.  I haven't used these classes in 
Hibernate yet...I'm trying to convince my DBA to modify the database so 
that I don't have to deal with composite keys. =)

Thanks!
Patrick

----------------------------------------------------------------------

--- middlegen/plugins/hibernate/hibernate.vm    2004-04-16 
06:14:37.000000000 -0400
+++ 
../../Middlegen-Hibernate-r4/middlegen-lib/modified-jar/middlegen/plugins/hibernate/hibernate.vm 
    2004-04-15 17:21:50.000000000 -0400
@@ -78,7 +78,7 @@
  #if ($table.primaryKeyColumns.size() == 0 )
      <composite-id>
  #if ($plugin.genXDocletTags)
-        <meta attribute="class-description" inherit="false">
+        <meta attribute="field-description">
             @hibernate.id
              generator-class="assigned"
          </meta>
@@ -112,7 +112,7 @@
      <composite-id name="comp_id" 
class="${table.package}.${table.compoundKeyDestinationClassName}">
  #end
  #if ($plugin.genXDocletTags)
-        <meta attribute="class-description" inherit="false">
+        <meta attribute="field-description">
             @hibernate.id
              generator-class="assigned"
          </meta>
@@ -153,7 +153,7 @@
  #foreach( $columnMap in $relationshipRole.targetRole.columnMaps )
              <meta attribute="field-description">
                 @hibernate.many-to-one
-                column="$columnMap.foreignKey""
+                column="$columnMap.foreignKey"
              </meta>
  #end
  #end


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.