-->
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.  [ 1 post ] 
Author Message
 Post subject: hibernate, join query using criteria
PostPosted: Mon Feb 16, 2009 11:52 am 
Newbie

Joined: Wed Feb 11, 2009 7:30 am
Posts: 2
Hello,

someone can help me ..... with Hibernate, criteria and join.....


I have two tables, one is called the Resource and the other ResourceAttribute.

Table ResourceAttribute there is a field that matches idResource
to their incremental resource table.


For example:

Resource Table
id title private
1 test1 0
2 test2 0


Table ResourceAttribute
id idResource name
.. ......... ....
10 2 hits


I should find all the resource records in the table (with some
restrictions) that are also present in Table ResourceAttribute
where the name field is enhanced with hit.


To solve the first problem this is the query:

Criteria crit = getSession (). CreateCriteria (Risorsa.class);
crit.add (Restrictions.eq ( "private", new Integer (0));
crit.list return ();


simply can not understand how one can take the resources
which are also present in the table where the field ResourceAttribute
name is enhanced with hit.

That is the result of query by example, must have returned a
list of a record (object resource with id = 2 title = test2 ...).


Hello


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.