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: HQL, dont select some properties
PostPosted: Thu Oct 25, 2007 6:40 am 
Newbie

Joined: Wed Sep 19, 2007 2:59 am
Posts: 14
Hi
I wounder if its possible in HQL to specify which propertys of an object i want to get. Lets say i have an objet with 3 many-to-one properties and 5 singel string properties. I just want to get the object with the string properties and 1 of the many-to-one properties. I also want it to get it as the type my object is. So an object[] is not the thing that i want.

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 25, 2007 7:55 am 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
If the many-one classes act as proxies (the default in NH 1.2), the many-one properties are lazy and are only filled with data when accessed.
And if you want the single many-one property to be loaded together with the string properties, use 'join fetch' in HQL.

_________________
Cuyahoga


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2007 12:01 pm 
Newbie

Joined: Wed Sep 19, 2007 2:59 am
Posts: 14
Thanks but i think you miss understood my question.

I dont use lazy because of the way the application handles the session, we also use data transfer objects. I want to do the following in hql.

MyClass
Property, String:Name
Property, String:Id
Property, Bag: Logins
Property, Bag: Pictures

I want to get the the string properties and the Bag with logins in a hql-select.

Like
select p.Name, p.Id, elements(p.Logins) from Person p

Want it to NOT select the Pictures-bag, executing the query above, will not result in any hits. And if i leave elements out, it says it expect its.

Thanks


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.