-->
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.  [ 7 posts ] 
Author Message
 Post subject: POJO generation question
PostPosted: Thu Feb 08, 2007 8:08 am 
Newbie

Joined: Mon Feb 05, 2007 11:49 am
Posts: 13
Hello.

I'm using hibernate tools to reverse engineer a database's tables into EJB 3.0 compliant objects.

In some many-to-many associations I want one of the sides not to be mapped to an entity, but rather have the other side contain a set of the primary keys belonging to the entities it has a relationship with.

For example, if I have the tables PERSON and LANGUAGE as entity tables, and PERSON_LANGUAGE as the many-to-many table containing both the primary keys of PERSON and LANGUAGE, the desired output would be an @Entity Person containig a Set<Integer> of the primary keys of the languages that person speaks.

If I place something like

<table-filter match-name="LK_.*" exclude="true" />

in reverng.xml, the reverse engineering process generates @Entity java classes for the tables mapping the many-to-many association.

Is there a way in which I can configure the reverse engineering process to obtain the result I want? Any help would be apreciated.

Thanks in advance,

Hugo Oliveira
hugom.oliveira.ext@siemens.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 09, 2007 9:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you could probably tweak the mapping generation/templates to output this; but it is *not* how you should map such things....does not make sense (not even from a performance point of view since lazy references is not more than integers + the option of lazy initializing the object).

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 09, 2007 11:11 am 
Newbie

Joined: Mon Feb 05, 2007 11:49 am
Posts: 13
Hello Max.

I need this behaviour because some database tables map their entities directly to java enums, and I need their primary key because it contains the respective enum sequence number. Having that I number I can then compare and modify values based on the respective java enum.

Thanks,

Hugo Oliveira
hugom.oliveira.ext@siemens.pt


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 09, 2007 1:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so why don't you just map them as such and/or do xyz.getId() ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 12, 2007 4:13 am 
Newbie

Joined: Mon Feb 05, 2007 11:49 am
Posts: 13
Hello Max.

Are you talking about puting the enum variable in the entity? If you are, I would really like to know how this is done, since I don't even know it to be possible (remember that the entity objects are being reverse engineered and they must be JPA compatible).

If you are talking about creating entities representing the enum and calling getId on these to compare values, I think it's just cluttering up the object model with unnecessary classes, since the only thing I would need from them would be their primary key number.

Thanks,

Hugo Oliveira
hugom.oliveira.ext@siemens.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 12, 2007 4:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well no matter what you do reveng does not support reverse engineering collection associations as values, only entities.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 12, 2007 4:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
...so some handtuning is needed for doing specific mappings.

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