-->
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.  [ 2 posts ] 
Author Message
 Post subject: Simple select
PostPosted: Tue Aug 18, 2009 2:10 pm 
Newbie

Joined: Sun Nov 26, 2006 12:53 pm
Posts: 13
Hello everyone,
i have a class User that contains a field person,
i want to select all the users with person.name = John.

The mapping for User (old style xml for old project) is smth like this:
Code:
<class name="User" table="user">
   <id name="uid" column="uid">
      <generator class="increment"/>
   </id>
   <property name="username"  />
   <many-to-one name="person" class="Person" />
   <property name="deleted" />
</class>


and Person is smth like this:
Code:
<class name="Person" table="person">
   <id name="uid" column="uid">
      <generator class="increment"/>
   </id>
   <property name="name"/>
   <property name="deleted" />
</class>


could u help me? I know it's easy but I cant remember anything, lol


Top
 Profile  
 
 Post subject: Re: Simple select
PostPosted: Wed Aug 19, 2009 10:01 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
I'd do a criteria query, although, I always do criteria queries.

Just set up a restriction for the name.person or whatever the dot separated value of the field you are looking for is. That should do it pretty easily.

You might find this tutorial on the Hibernate Criteria API helpful:

http://jpa.ezhibernate.com/Javacode/lea ... riteriaapi

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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