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
|
|