-->
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: Middlegen/Hib Plugin: one-to-many, w/key value on "one&
PostPosted: Thu Dec 18, 2003 12:48 pm 
Newbie

Joined: Fri Dec 12, 2003 1:27 pm
Posts: 10
All,

Using the Middlegen/Hib Plugin I'd like to generate a one-to-many mapping where the "one" side of the mapping simply uses the foreign key value rather than the object referenced by the foreign key.

So in the Midgen/Hib generated-prefs.properties file:

In the tables section:

hibernate.tables.tableB.columns.tableA_id.java-name=tableAId
hibernate.tables.tableB.columns.tableA_id.java-type=int

In the relations section:

relations.tableB-tableA.tableA-has-tableB.enabled=true
relations.tableB-tableA.tableA-has-tableB.target-many=false

So for the generated object representing "tableA" which is the "one" side of the one-to-many, this is generated:

private com.my.package.name.TableB tableB; // the object

What I would like to accomplish is this (ie, use the key itself rather than the obj):

private int tableBId; // the int table id

Any suggestions?

Thanks,
Steve


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 19, 2003 4:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Relationships are done through the objects. You can choose not to map a relationship so you will just have the foreign key as a property. You will need to then get the collection using HQL. Middlegen looks for the foreign key constrains so kill the constraints then the foreign key will be mapped as a property.


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.