-->
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.  [ 3 posts ] 
Author Message
 Post subject: Code Gen: Explicit Type in Collections?
PostPosted: Wed Dec 14, 2005 6:52 pm 
Beginner
Beginner

Joined: Tue Nov 15, 2005 6:56 pm
Posts: 39
I'm using the latest hibernate-tools3.1 beta2.

When I generate code my collection elements such as Sets, they don't have the explicit type specified for the Collection in the Java file. For example, if my hbm.xml file for class MyDataItems has this snippet in its hbm.xml file:

<set name="DataItem" table="DATA_ITEM" lazy="false" cascade="all">
<key column="MY_COLUMN"/>
<one-to-many class="DataItem" />
</set>

then the generated class for MyDataItems has this generated for the DataItem Set:

Code:
  private Set RulesParam;


instead of:

Code:
  private Set<DataItem> RulesParam;


Is there a way to get this second version generated?

Thanks.


Top
 Profile  
 
 Post subject: Figured it out...but have Maps don't get generated correctly
PostPosted: Wed Dec 14, 2005 7:30 pm 
Beginner
Beginner

Joined: Tue Nov 15, 2005 6:56 pm
Posts: 39
Well, the fix was to use this.setJdk5(true) function to essentially tell my customer generator task to use generics.

However, while most of my collections now had the correct classes in the generated classes, I noticed Map types did not get generated correctly.

For example my hbm.xml file for MyClass has this in it:

Code:
      <map name="myMapItems" lazy="false" inverse="true">
         <key column="MY_FIRST_COL_ID" />
         <map-key column="MY_SECOND_COL_ID" type="Integer"/>
         <one-to-many class="mycompany.MapItem"/>
      </map>


When I generated code, the java file had this in it:

Code:
private Map<mycompany.MapItem> myMapItems;


I want it to look like:

Code:
private Map<Integer, mycompany.MapItem> myMapItems;


Does anybodey know how to do this?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 15, 2005 2:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i'm pretty sure you are not using the latest version. the last 2 relelases have had this support in both ant and eclipse ui

_________________
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.  [ 3 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.