-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate Association
PostPosted: Fri Oct 26, 2007 5:32 am 
Newbie

Joined: Tue Oct 16, 2007 5:56 am
Posts: 10
Hello All,

I have this 2 objects:
"Basket" that is related to more "ServiceBasket" (one-to-many).
The only problem is that I want to add another relation with a property of Basket that is not a foreign key.

Ho can I do?

Pls, help me..it's very urgent!

Thanks,
Francesco


Top
 Profile  
 
 Post subject: do you mean ServiceBasket to Basket using another property?
PostPosted: Fri Oct 26, 2007 5:47 am 
Newbie

Joined: Sat Jul 01, 2006 9:38 pm
Posts: 17
if it is,then just config as following:

<many-to-one name="basket"
property-ref=ANOTHER_PROPERTY_NAME_HERE(eg.property-ref="basketballplayerName", this is the foreign key.)
.... />

just use property-ref attribute as the foreign key, other configuration is as usual.

Hope this can help you.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 26, 2007 5:59 am 
Newbie

Joined: Tue Oct 16, 2007 5:56 am
Posts: 10
Sorry..
I haven't understand good..

where I must add that property? In serviceBasket?
If yes, in Basket Imust not set nothing? Then, if I add that property (many-to-one), Imust add some code (of getting and setting) in java code?

Thanks,
Francesco

This is my xml map :
<class name="it.eminds.data.Basket" table="Basket">
<id name="id" type="string">
<column name="id" length="50"/>
<generator class="assigned"/>
</id>
<property name="utente" type="string" >
<column name="utente" not-null="false" sql-type="text"/>
</property>

<!-- tabella Array servizi type="boolean" -->
<bag name="servizi" cascade="all">
<key column="uid"/>
<one-to-many class="it.eminds.data.ServiceBasket"/>
</bag>
</class>

<class name="it.eminds.data.ServiceBasket" table="serviceBasket">
<id name="id" unsaved-value="0">
<generator class="increment"/>
</id>
<property name="pax" type="string" >
<column name="pax" not-null="false" sql-type="text"/>
</property>
<property name="correlation" column="correlation" type="string" length="10" />
</class>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 26, 2007 11:11 am 
Newbie

Joined: Tue Oct 16, 2007 5:56 am
Posts: 10
Hi suyejun,
If I want to have 2 Key in "Basket" how can I set Basket?

In particular, I want that "bookid" is another Key of Basket.
After that, I want to associate serviceBasket with Basket, with "id" and "bookid" fileds.

I must modify this:
<bag name="servizi" cascade="all">
<key column="uid"/>
<one-to-many class="it.eminds.data.ServiceBasket"/>
</bag>

Now there is only "uid" that is the relation with "id" of basket. If I want to add "bookid" how can I do?

Thanks,
Francesco


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 26, 2007 11:11 am 
Newbie

Joined: Tue Oct 16, 2007 5:56 am
Posts: 10
Hi suyejun,
If I want to have 2 Key in "Basket" how can I set Basket?

In particular, I want that "bookid" is another Key of Basket.
After that, I want to associate serviceBasket with Basket, with "id" and "bookid" fileds.

I must modify this:
<bag name="servizi" cascade="all">
<key column="uid"/>
<one-to-many class="it.eminds.data.ServiceBasket"/>
</bag>

Now there is only "uid" that is the relation with "id" of basket. If I want to add "bookid" how can I do?

Thanks,
Francesco


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.