-->
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: Doubt with "select new MyClass(c.id, c.o) from MyEntity
PostPosted: Thu Oct 09, 2008 2:45 pm 
Newbie

Joined: Thu Apr 26, 2007 2:42 pm
Posts: 6
Hibernate version: Entity Manager 3.3.1.ga

Mapping documents:

@Entity
public class MyEntity {

@Id
public Long id;

public List<MyOtherEntity> others;

}

I have a class MyClass with the constructor MyClass(Long, List<MyOtherEntity), when I try to make a query like:

"select new MyClass(c.id, c.others) from MyEntity c"

I get an exception because Hibernate is expecting that the constructor is MyClass(Long, MyOtherEntity). Seems that whants to create an instance for each element of the list.

How shoud I write the query to get for each object the Id and the List associated to the field 'others' ?

Thanks


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.