-->
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: Problem on Query criteria for associated objects
PostPosted: Mon Feb 06, 2006 9:58 pm 
Newbie

Joined: Mon Feb 06, 2006 4:00 pm
Posts: 5
Hi,

I am new to Hibernate. Having trouble in using "Example.create"
I have a scenario where i have to put criteria for associated object. I tried using "Example.create". But it is returning wrong results.This is what I did.

I have 1 parent class called "Master".
1 child class called "Child".

Inside the Child class I have reference to Master.For putting criteria i did like this.

Child child = new Child();
child(setCode("TEST"));
Master master = new Master();
master.setCode("MAS");
master.setName("MASTER");
child.setMaster(master);

List list = session.createCriteria(Child.class).add(Example.create(child)).createCriteria("master").add(Example.create(child.getMaster())).list();

I am expecting results which matches the criteria I mentioned above. But I am getting all the records from the Child table. When i see the console I am seeing the query like this.

select .... from CHILD c left outer join MASTER m on m.master_id = c.master_id where (1=1) and (1=1)


Can any please tell what I am doing wrong. if it is not possible with "Example" to give criteria fro associated fields is there any other way?


Thanks
Raju.M


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 07, 2006 12:00 am 
Regular
Regular

Joined: Tue Dec 14, 2004 5:21 am
Posts: 104
Location: india
wht exactly is your requirement .
the createCriteria() looks wierd for me :)

_________________
sHeRiN
thanks for your ratings ...... :)


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.