-->
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: Problem with criteria projections over a lazy property
PostPosted: Mon Sep 07, 2009 8:31 am 
Newbie

Joined: Thu May 21, 2009 2:35 pm
Posts: 4
When I create a query like this:
Code:
   List<Partida> partidas =  s.createCriteria(Bulto.class)
      .createAlias("partida", "p")
      .add(Restrictions.eq("p.producto", prod))
      .setProjection(Projections.property("partida"))
      .list();


Where Bulto has a property partida and uses lazy loading, It doesn't give me a list of objects of the class "Partida" but a list of some kind of proxies of a class named "Partida_$$_javassist_11".

If I change the mapping file and add ' lazy="false" ' then the same query returns a list of objects of "Partida"

Is there a way to force the query to return the real objects and not some proxy when it is lazily mapped?

Thanks in advance!


Top
 Profile  
 
 Post subject: Re: Problem with criteria projections over a lazy property
PostPosted: Mon Sep 14, 2009 1:32 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
Easiest way would be to call Hibernate.initialize on your return list but you also might be able to set the fetchMode on the association in the initial query.

_________________
Some people are like Slinkies - not really good for anything, but you still can't help but smile when you see one tumble down the stairs.


Top
 Profile  
 
 Post subject: Re: Problem with criteria projections over a lazy property
PostPosted: Thu Sep 17, 2009 9:22 pm 
Newbie

Joined: Thu May 21, 2009 2:35 pm
Posts: 4
Thanks, I'll try that. But for the moment I solved it with an HQL query which does what I want.


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.