Friday, 15 August 2014

java - Convert List<Tuple> to List<Bean> -


I do not want to show all my attributes on a table, so I want to select only some columns then their values Map the bean, use some of Hibernate's transformers. Lius Tobin (T. Class) , but use JPA and Criteria.

Send me a list & lt; Tupal & gt; , I'll call it list & lt; T & gt; How can I change the form of

, as the title says, is it possible?

can argue object constructor within the query within JPQL / parameters so that the query returns those objects for you. . For example: "SELECT new package.BeanClass (e.attribute1, e.attribute2) Entity e"

With basic SQL queries, if you are using JPA 2.1, you can use the same example Constructor Silent can be used to build:

But if you are not able to use JPA 2.1, then you will need a provider-specific solution such as


No comments:

Post a Comment