-->
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: createCriteria problem
PostPosted: Tue Feb 09, 2010 5:25 am 
Newbie

Joined: Tue Feb 09, 2010 5:08 am
Posts: 2
Hi ...
I am new to hibernate....
here my problem

Student{
Long sid; // primery key
String sname;
Address address;

}

Address{
Long addId;
String street;
String City;

}

I am passing Student to create Criteria ...
in o/p have to get all student records city is bangalore

Criteria crit = session.createCriteria(Student.class);
crit.add(Restrictions.eq("address.street","bangalore");

not working....
the error is org.hibernate.QueryException: could not resolve property:address.street

but its working for
Criteria crit = session.createCriteria(Student.class);
crit.add(Restrictions.eq("address.addid","1");

Pls Reply me...

Thanks in advance.....


Top
 Profile  
 
 Post subject: Re: createCriteria problem
PostPosted: Tue Feb 09, 2010 6:12 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I think you need to create an alias for the 'address' association. See http://docs.jboss.org/hibernate/stable/ ... sociations for some examples.


Top
 Profile  
 
 Post subject: Re: createCriteria problem
PostPosted: Tue Feb 09, 2010 7:22 am 
Newbie

Joined: Tue Feb 09, 2010 5:08 am
Posts: 2
Thanks buddy..........its working....


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.