|query a subpart of complex graph and get a smallest object [message #989614]
||Thu, 06 December 2012 18:19
| J LM
Registered: December 2012
I need some advice about querying a complex graph of entities in order to return a simple object.
Assume I have a Customer which has a onetoone to a person entity which has too a onetoone to an address entity. Each of those entities have their own fields.
I need only 2 fields : the name of the customer and the zipcode of the address but not the other fields (I didn't mention that the Customer owns other relations to other types of entities)
My need is just for readonly.
The number of Customers is really huge and I must get those 2 informations really quick. I must avoid pre-caching but my question is more general.
Is it possible to use something as projections, fetch groups or something else to get those 2 fields to a single object different from the graph of the Customer entity ? How ? Could it be JPA2 compliant ?
I could use SQL as I see how to do this in sql but it would mean coupling a sql query to physical tables that are already defined in my mappings of entities. So will need to maintain the two if a change must occur on the tables.
I could create a view in db this would mean too to maintain the sql query behind the view.
Powered by FUDForum
. Page generated in 0.03667 seconds