Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] query a subpart of complex graph and return to a short object

Hi everyone,
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 ? And 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.

Thx


Back to the top