-->
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 'new java object' cannot handle collection
PostPosted: Mon Nov 19, 2007 4:18 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 8:37 am
Posts: 22
Location: London
If I have an entity 'Person' that has an associated collection 'Books' why can't I write a query like this:
Code:
ThisQueryBean thisQueryBean = entityManager.createQuery(
    "select new ThisQueryBean(p, p.books) from Person as p")
    .getResultList();


The problem seems to be with p.books being a collection. If it is an object or primitive then it is fine. The constructor for ThisQueryBean looks like this:
Code:
public ThisQueryBean(Person p, List<Book> books) {
    etc, etc


Is what I am trying to do not supported/stupid? It would be very convenient. The alternative is to do a distinct join which works but doesn't feel as elegant.

Thanks,

Damian


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.