-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem with Example
PostPosted: Tue Dec 04, 2007 9:32 am 
Newbie

Joined: Tue Dec 04, 2007 9:21 am
Posts: 1
Location: Taubate, SP - Brazil
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.