-->
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.  [ 4 posts ] 
Author Message
 Post subject: inverse="true" confusion
PostPosted: Sat Aug 30, 2008 3:52 pm 
Beginner
Beginner

Joined: Wed May 14, 2008 2:06 pm
Posts: 21
<class name="Parent">
<id name="id" column="parent_id"/>
....
<set name="children" inverse="true">
<key column="parent_id"/>
<one-to-many class="Child"/>
</set>
</class>

<class name="Child">
<id name="id" column="child_id"/>
....
<many-to-one name="parent"
class="Parent"
column="parent_id"
not-null="true"/>
</class>

parent has inverse="true" what this means ?


here if I add a new child to the set in parent and persists parent will it save the new child ?
or
the child updates a property in parent and persists itself , will it update parent ? Please help me resolve this confusion!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 01, 2008 5:48 am 
Newbie

Joined: Mon Sep 01, 2008 5:33 am
Posts: 1
Location: India
Hi i am new to hibernate 3.0.

I have written a query in MySQL which will return top 10 best markets

The query is running fine in MySQL Query Browser. but I want to implement
the same query in form of Hibernate Query.

SELECT * FROM
(select a.market_id,count(distinct a.country_id)
countrycnt,b.marketName
from grt5_cms.Market_Country as a,grt5_cms.Market as b
where a.market_id=b.id group by
a.market_id order by countrycnt desc)
tab1 limit 10;



can some one please write the same to Hibernate Query..


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 01, 2008 9:20 pm 
Beginner
Beginner

Joined: Wed May 14, 2008 2:06 pm
Posts: 21
Please post it as a new thread


Top
 Profile  
 
 Post subject: Re: inverse="true" confusion
PostPosted: Tue Sep 02, 2008 12:14 am 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
inverse="true"(bidirectional) means both side is "mirror", so Hibernate will execute only 1 query when you save the children. Try to turn on the logger to see the query executed


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