-->
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.  [ 2 posts ] 
Author Message
 Post subject: Collection types in generated Java code
PostPosted: Wed Mar 17, 2010 11:22 pm 
Newbie

Joined: Wed Mar 17, 2010 11:10 pm
Posts: 1
Hi,

I'm using hbm2java 3.2.3.GA. For collection fields my generated code looks like this:

Code:
    private Map<Integer,Foobar> foobars = new HashMap<Integer,Foobar>(0);

    public Map<Integer,Foobar> getFoobars() {
        return this.foobars;
    }
   
    public void setFoobars(Map<Integer,Foobar> foobars) {
        this.foobars = foobars;
    }


I would like to generate code like below instead, so that collections are always referenced using their concrete type (e.g. HashMap, LinkedList, TreeSet), not an abstract type (Map, List, Set):

Code:
    private HashMap<Integer,Foobar> foobars = new HashMap<Integer,Foobar>(0);

    public HashMap<Integer,Foobar> getFoobars() {
        return this.foobars;
    }
   
    public void setFoobars(HashMap<Integer,Foobar> foobars) {
        this.foobars = foobars;
    }


I know that hbm2java's default pattern - using abstract classes where possible - provides flexibility and is generally a good one, I'm using it myself all the time. However I don't need the flexibility in this case and the use of abstract classes incurs a performance hit to do with RPC serialization.

Is there a way to accomplish this without having to touch the hbm2x source code?

Apologies if this question was answered before.

Thank you,

Julian


Top
 Profile  
 
 Post subject: Re: Collection types in generated Java code
PostPosted: Wed Mar 24, 2010 10:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
1) these are interfaces and not abstract classes and how can that hurt the performance ?!

2) it wouldn't work with hibernate nor jpa entities so not sure what usecase this would ever be relevant ?

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