Hello,
I'm using Hibernate 3 with annotations and a postgresql database.
I'm trying to create a method to find objects with the Example API. My example object has the following structure:
Code:
public class A {
@ManyToOne
private B Bobj;
}
The problem is that my Bobj comes only with it's id field filled, other stuff is null. Reading the Hibernate book I saw that Example ignores the id field by default. So my queries always return empty...
I using code like this one
Code:
Example AExample = Example.create(objA);
Example BExample = Example.create(objA.getObjB());
return getSession().createCriteria(A.class)
.add(AExample)
.createCriteria("objB")
.add(BExample).list();
If i initialize any other attribute in objB everythink works fine, but I can't do that. This object comes from the view layer, where I have a search page with lots of selection boxes for search criteria. All I have there are the id of the persistent objects...
Is it possible to make such query using Example or will i need to use pure criteria and add restrictions as needed?
Thank you!
Cássio Marques