Is that possible in JPA to load information from the database in dinamic VOs? Like lets say I want a subset of the information of the table customer, just name surname and some other fields, or some fields of customer plus some fields of address table in just one object. Is that possible to use, without coding it, a pool of this new VO object? Considering that creating new instances of a class is not that performatic. Basically load just the needed information (not entire entities) and load it in objects provided by a pool of those object. Any ideas?
Asked
Active
Viewed 2,159 times
2 Answers
1
You probably need to take a look at ObjectGraph concept (introduced in JPA 2.1)

WeMakeSoftware
- 9,039
- 5
- 34
- 52
-
It looks like what I'm looking for, the docs sounds confused to me, would you mind edit your question with a simple example? also, does this ObjectGraph load the objects from a pool ? – Roger that Oct 26 '15 at 09:23
-
it's really difficult to provide you a simple example of ObjectGraph without seeing your code. Please share some of your code – WeMakeSoftware Nov 12 '15 at 10:22
1
Sure, you may create a value object and have your query return list of these objects instead of entities. You just create appropriate constructor for the VO and use NEW
keyword in the query, documented here: http://docs.oracle.com/cd/E12839_01/apirefs.1111/e13946/ejb3_langref.html#ejb3_langref_constructor
See also this answer: JPQL Create new Object In Select Statement - avoid or embrace?