Sunday 15 January 2012

hibernate - What is the correct syntax for an ejbql query that traverses four levels of many to one relationships -


In JPA (Hibernate) I have a simple data model that has many relationships from one and the other to one:

/ P> <-> City -> State -> Governor -> Nation -> Continent

Where the state is for a state, there is one for the state governor;

I want to get an example of a single town with my unique ID and use it Nbndit state, governor, country and continent want to get the interest. I believe that proper isabil:

  choose from city to t Add to t.state s join fetch s.governor g fetch g.nation n Join fetch N.continent c where t.id =? Id  

The Hebrewman generates the right SQL from this ejbql, but when I do my town. GetState () GetGovernor () I bring a vacant object back to my governor. Why is not the hibernate governor coming? It seems that it does not want to populate the trees at more than one level. Anyone is watching what I am doing wrong?

Do not worry my syntax above really works my problem from some previous activity to hibernate The session was not trying to silence and was receiving a cached version of the object that was not too populated, after fixing that problem, everything is fine.


No comments:

Post a Comment