-->
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: joining tables without mapping with criteria... possible?
PostPosted: Tue Jan 27, 2009 4:46 am 
Newbie

Joined: Mon Jan 26, 2009 8:11 am
Posts: 2
Hi. i dont know if there is already an answer for this but it is really urgent

i have 2 tables, one is my person table and other is my view_log table

i need to get last few viewers of a site/article etc. and my query needs to be like:

select p.* from persons p join view_log v on
p.id = v.user_id where v.typ_id = <item id> order by v.created desc

there are only few places i need to do this thats why i need to do it without mapping ( or list or etc) to avoid trash data.

as it can be done by using the query as string, i think there should be a way to do it by using criteria only.

i'll be glad if you can help me about this.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 27, 2009 4:49 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Joining on "unmapped associations" is not possible using criteria.

What do mean with, you want to avoid trash-data. Why would there be trash-data, if you mapped this association as lazy, inverse collection?

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 27, 2009 5:03 am 
Newbie

Joined: Mon Jan 26, 2009 8:11 am
Posts: 2
it is not exactly trash-data. if i use map in my xmls then it will always check it through the map and other table (or atleast far as i know).

i only want to check it when i need to. as i said before i am using SQLQuery to make this control.

if it is not possible to join tables by using criteria without mapping in xml,
is there a way to choose weather i want to use join or not if i used map?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 27, 2009 5:12 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
You can describe how data is fetched, using the fetch-keyword (fetch="join|select|subselect") and when it is fetched using "lazy".

I guess what you need is laziness, as you want the association to be fetched, only when necessary.

_________________
-----------------
Need advanced help? http://www.viada.eu


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.