-->
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: Collection issue while Hibernate upgrade to version 3
PostPosted: Mon Sep 26, 2005 9:17 am 
Newbie

Joined: Mon Sep 26, 2005 8:43 am
Posts: 16
Hi I am newbie to Hibernate. I got to upgrade the Hibernate version from 2.1.6 to 3.

While upgrading to HB 3, I had to replace the hbm2java task[net.sf.hibernate.tool.hbm2java.Hbm2JavaTask] with hibernatetool[org.hibernate.tool.ant.HibernateToolTask]

Code:
           <taskdef
               name="hibernatetool"
               classname="org.hibernate.tool.ant.HibernateToolTask"         
               classpathref="hibernate.lib"/>

           <hibernatetool destdir="${hibernate.build}">             
               <configuration>
                     <fileset dir="${hibernate.src}">
                        <include name="**/*.hbm.xml" />
                     </fileset>                                    
               </configuration>
               <hbm2java/> <!-- generate default .java files -->
               
           </hibernatetool>   

Earlier when .java source file were generated by using hbm2java, the collection properties in the *.hbm.xml files were observed to be of java.util.List data type in the .java source files. My *.hbm.xml files make use of <idbag/> element for collections as shown in code below:

Code:
<idbag name="details" table="RealmL10n" lazy="true">
         <cache usage="nonstrict-read-write"/><!-- Should be read-only -->
         
         <collection-id type="long" column="realm_l10n_guid">
            <meta attribute="scope-set">protected</meta>           
            <generator class="com.abc.persistence.GuidGenerator"/>
         </collection-id>
         
         <key column="realmId_guid" foreign-key="FK_REALML10N_REALM"/>

-------------------------------------------------
-------------------------------------------------
</idbag>

The new tool generates them as java.util.Collection data type.

The existing code that consumes the Java source files(Generated from .hbm.xml) expects the List rather than Collection data type. I can't go and change all the consumer code. ( This can only be considered as the last option).

Can anyone please suggest how should I generate the Java Source files using the new tool so that they generate the java.util.List properties rather than java.util.Collection properties?

_________________
--Beejal


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 9:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
<meta attribute="property-type">java.util.List</meta>

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 12:23 am 
Newbie

Joined: Mon Sep 26, 2005 8:43 am
Posts: 16
Thanks max. It worked fine for me.

I don't know how to give credits :(. Please let me know so that I can give you the credits.

_________________
--Beejal


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 12:24 am 
Newbie

Joined: Mon Sep 26, 2005 8:43 am
Posts: 16
Ok I have given you the required credits now.

_________________
--Beejal


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.