mercredi 24 décembre 2014

JPA: Search for an associated entity in an entity hierarchy

I've a PARENT Entity which has 1-M associations with other child table entities. Those child entities may further have associations with other table entities. In my application we load the PARENT entity and subsequent child entities also get loaded along with it.

Example:



[PARENT]
-X
--X1
--X2
---X2a
-Y
--Y1
--Y1
-Z
--Z1

I am stuck in an implementation where I have to search for a particular child entity object which could be anywhere in PARENT entity's hierarchy; update that child entity and save the Parent object.



E.g.: PARENT > X2 > X2a is to be updated.



Problem is there is no certain level of hierarchy i've to search through. I did try to implement JPA Metamodel and reflection api but couldnt find anything which could help me search for the entity in the loaded PARENT entity.


Can someone guide me to right way?






Aucun commentaire:

Enregistrer un commentaire