| Fetch profiles fail to load certain relations because of invalid cycle detection in MetamodelGraphWalker. Attached test case. Details: Have 5 entities - Start, Via1, Via2, Mid and Finish with following relations (all LAZY): Start n:1 Via1 n:1 Mid n:1 Finish Start n:1 Via2 n:1 Mid n:1 Finish Now, trying to use Fetch Profiles to load Start entity and all of its relations. I would expect Hibernate to execute following SQL select: SELECT * FROM Start s LEFT OUTER JOIN Via1 v1 (path Start-Via1) LEFT OUTER JOIN Mid JOIN Finish LEFT OUTER JOIN Via2 (path Start-Via2) LEFT OUTER JOIN Mid JOIN Finish Unfortunately, ic ompletely omits the second join from Mid to Finish, what I am getting is: SELECT * FROM Start s LEFT OUTER JOIN Via1 v1 (path Start-Via1) LEFT OUTER JOIN Mid JOIN Finish LEFT OUTER JOIN Via2 (path Start-Via2) LEFT OUTER JOIN Mid I dug deeper into this and found cycle detection in MetamodelGraphWalker, line 144. Basically, when MetamodelGraphWalker detects a relation that has already been visited, it considers it a cycle. But in my case it is not a cycle - I just came to the same relation twice using two different paths. From the user perspective, the fetch profiles seem to behave randomly - sometimes they fetch correct relations, sometimes they do not. I believe there should be a better cycle detection. |