-->
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.  [ 3 posts ] 
Author Message
 Post subject: Can we override the Query generated by Hibernate Association
PostPosted: Tue Sep 14, 2010 11:09 am 
Newbie

Joined: Tue Sep 14, 2010 10:59 am
Posts: 2
Hi,

Assuming the following set gets all the Events for Person.

<set name="events" table="PERSON_EVENT">
<key column="PERSON_ID"/>
<many-to-many column="EVENT_ID" class="Event"/>
</set>


can we Override the Query generated by the hibernate with my own Query (HQL or SQL).

Thanks
Sampath Kumar


Top
 Profile  
 
 Post subject: Re: Can we override the Query generated by Hibernate Association
PostPosted: Tue Sep 14, 2010 2:04 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
It seems like you can but I have never used it myself: http://docs.jboss.org/hibernate/stable/ ... rysql-load


Top
 Profile  
 
 Post subject: Re: Can we override the Query generated by Hibernate Association
PostPosted: Wed Sep 15, 2010 11:48 am 
Newbie

Joined: Tue Sep 14, 2010 9:44 am
Posts: 3
Hi,

I feel you can override the query generated.

Code:

<set name="events" table="PERSON_EVENT">
       <key column="PERSON_ID"/>
       <many-to-many column="EVENT_ID" class="Event"/>
       <loader query-ref="personquery"/>
</set>

<sql-query name="personquery">
    <load-collection alias="pers" ....../>
    your query goes here
</sql-query>




cheers

VT


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