-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: hbm2java, composite ID in separate class, extra code in meta
PostPosted: Fri Oct 02, 2009 8:11 am 
Newbie

Joined: Fri Oct 02, 2009 8:02 am
Posts: 2
Hi!

I have a hibernate mapping file with a bean "SectionPlan" which has a composite ID split into a separate class "SectionPlanId".
Now I have injected extra class code into the bean using the "class-code" meta tag. No problem so far.
But if I generate the actual bean class code using hbm2java, it injects the "class-code" from the meta tag into both the "SectionPlan" AND the "SectionPlanId" code.

How can I control wether meta class code goes into the ID class as well?

Any kind of help would be appreciated:)
Thanks:)

Cheers,
Patrick

Code:
<class name="SectionPlan" table="TBXSectionPlan">

   <meta attribute="class-code">
   <![CDATA[
      public String test() {
         return "mooooo";
      } // test()      
        ]]>
        </meta>
   
   <composite-id name="id" class="SectionPlanId">
      <key-property name="siteId" column="TBXSiteID" type="integer" />
      <key-property name="sectionId" column="TBXSectionID" type="integer" />
   </composite-id>     
        <property name="name" column="TBXSectionName" type="string" />
   
</class>


Top
 Profile  
 
 Post subject: Re: hbm2java, composite ID in separate class, extra code in meta
PostPosted: Wed Oct 14, 2009 10:08 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
Seems like a bug.
Use the following workaround:
...
<composite-id name="id" class="SectionPlanId">
<meta attribute="class-code"></meta>
<key-property name="siteId" column="TBXSiteID" type="integer" />
<key-property name="sectionId" column="TBXSectionID" type="integer" />
</composite-id>


Top
 Profile  
 
 Post subject: Re: hbm2java, composite ID in separate class, extra code in meta
PostPosted: Wed Oct 14, 2009 10:45 am 
Newbie

Joined: Fri Oct 02, 2009 8:02 am
Posts: 2
Thanks a lot, much appreciated!!!


Top
 Profile  
 
 Post subject: Re: hbm2java, composite ID in separate class, extra code in meta
PostPosted: Mon Nov 02, 2009 7:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it's not a bug, but a feature that meta attributes are inherited.

set inherit="false" on the meta attribute to prevent it from being applied to "subelements"

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.