-->
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: Select single element from CollectionOfElements
PostPosted: Tue Nov 03, 2009 10:00 am 
Beginner
Beginner

Joined: Tue Nov 03, 2009 9:38 am
Posts: 24
Hi,

I want to select an entity and a single element from a collection of elements that is contained in the entity.

I'm currently doing something like this:

Code:
select theme, text.name from ThemeEntity theme left outer join theme.translations as text with index(text)=:languageCode where theme.uid=:themeUid  order by theme.index asc


or

Code:
select theme, new <somepackage>.ThemeText(text.name) from ThemeEntity theme left outer join theme.translations as text with index(text)=:languageCode where theme.uid=:themeUid  order by theme.index asc


This works if the elements have only a few attributes. If there are more attributes, selecting all of them explicitly is quite cumbersome, even more so if I want to improve type safety by using the constructor syntax.


Now, my question is: Is there a way to query a single element from a collection of elements and make Hibernate initialize it automatically?
Obviously "select entity, element ..." doesn't work since this is translated into something like "select ... from TaElement element where element.id = ?" and there's no id column in TaElement.

Thanks in advance.

Thomas


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.