-->
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: code generation with join tables
PostPosted: Fri Dec 14, 2007 12:08 pm 
Newbie

Joined: Tue Nov 27, 2007 6:11 am
Posts: 12
Hi,
I'm trying to generate code from my database, and I've got a table Person, with key personpk, a role wih key rolepk and a join table j_person_role that matches people and the roles on the above primary keys. Now I've generated the mapping files running the tools, and then I changed the Person.hbm.xml so that it states:
Code:
<set name="roles" inverse="false" table="j_person_role">
            <key>
                <column name="personpk" length="20" />
            </key>
            <one-to-many column="rolepk" unique="true" class="g2.database.mapping.Role" />
        </set>

but when I generate the DAO and Java Classes, I've got that Person contains a set of JPersonRole objects, that point to the Role objects, while I'd like to get a direct link from Person to Role. So instead of this:
Code:
public class Person implements java.io.Serializable {
   private Set<JPersonRole> JPersonRoles = new HashSet<JPersonRole>(0);
....


I'd like to get:
Code:
public class Person implements java.io.Serializable {
   private Set<Role> Role = new HashSet<Role>(0);
....


How can I get this? Is there a way to force the tools to use the modified mappings?

Thanks,
Luca


Top
 Profile  
 
 Post subject: Re: code generation with join tables
PostPosted: Mon Dec 17, 2007 2:29 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
cat4hire wrote:
Hi,
How can I get this? Is there a way to force the tools to use the modified mappings?


Don't tell the tools to reverse engineer from the database and let it instead know about the hbm.xml....that should do it.

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