-->
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.  [ 10 posts ] 
Author Message
 Post subject: Bag class mapping (Collection or List)
PostPosted: Thu Apr 06, 2006 12:05 pm 
Newbie

Joined: Thu Apr 06, 2006 11:56 am
Posts: 2
Hello,

with the last releases of tools, hbm2java generates a java.util.Collection for bags as default, instead of java.util.List.

How to change this behaviour and force it to generate bags as List ? I need this for backward compatibility with previous source code.

Thanks in advance,
David


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 07, 2006 12:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Edit the code generation script (Velocity or Freemarker depending on the version) to output the format your after.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 07, 2006 2:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it was changed because Collection is actually the more correct way of representing it, but no worries I provided a work around:

<bag ...>
<meta attribute="property-type">java.util.List</meta>
....
</bag>

And that can be used generally, but mostly intended to remedy this one.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 07, 2006 3:26 am 
Newbie

Joined: Thu Apr 06, 2006 11:56 am
Posts: 2
It works great ! Thanks !


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 9:00 am 
Newbie

Joined: Wed May 17, 2006 8:13 am
Posts: 1
Hello,

I am facing the same problem as above. Adding
<meta attribute="property-type">java.util.List</meta>
is not ra really good solution, because it does not consider generics. I don't want
Code:
List ...
, but
Code:
List<MyClass> ...
.

So I changed the meta-tag to
Code:
<meta attribute="property-type">java.util.List<${property.getValue().getElement().getReferencedEntityName()}></meta>



Now I get nice declarations like "List<Y> x;" However no initialization code is generated anymore.

Is it possible to create declarations like
Code:
List<Y> x = new Vector<Y>();

and what needs to be changed to achieve this?


Thanks for your help

Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 9:09 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
we handle generics fine for everything else ;)

Please put it in jira with a reference to this.

We probably should just allow users to set the default for bags.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 10:16 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
david wrote:
Edit the code generation script (Velocity or Freemarker depending on the version) to output the format your after.


is this code in the hibernate source or the tools source? I need it to implement List with generics also.


edit: I couldn't find a jira issue related to this so I made one here http://opensource.atlassian.com/project ... se/HBX-666

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 1:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
they are in the hibernate-tools.jar (and hence in the hibernate tools src, but you can just take them from the jar)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 5:29 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
max wrote:
they are in the hibernate-tools.jar (and hence in the hibernate tools src, but you can just take them from the jar)


bahh, I can't find it in the source code, any chance you could point me to the file that handles this?

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 5:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
e.g. hibernate-tools.jar/dao/daohome.ftl or hibernate-tools.jar/pojo/*.ftl

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