java - Hibernate dynamic instantiations with collections, is it possible? -


I would like to write a HQL query as a parameter by using a dynamic urgency with a list.

Simplified Example:

An HQL query with a dynamic urgency:

  New user from xyUserDto (u.name, u.contacts) Select where u.xyz =: Param1 ...  

and my DTO class constructor is:

  public class UserDto {private string name; Personal list contacts; Public UserDto (string name, list contact) {this.name = name; This.contacts = Contact; } ...}  

and entity mapping:

  public class user {@olumn (name = "NAME") string name; @ManyToMany (name = "USER_ID" From & lt; Contacts & gt; Contacts; ...}  

So as you can see, whatever I want, is to create a new object, which has some properties and a collection of units.

I understand that hibernate will need one or more questions in order to achieve this because it will generate several result rows for each unit.

Does anyone know what is possible to create a new object which is a combination of properties and collection?

"itemprop =" text ">

Sorry, but this is not possible. According to the JPA specification,

The query type result is a unit-specific type of schema type, specified by the SELECT clause, is a state-area type - not a collection -, the result of. Select the new xyUserDto: A composite function, the result of a construction operation, or some of these SEQUENCE

You can use the following instead:

(U) user join u.contacts FETCH

Then, it is brought to your contact with the way users are with you


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -