Hi, I was wondering if any fellow hibernate users could clear up a point of confusion for me. I've searched around on the web but I can't find a definitive answer. In the absence of HQL or Criteria "overrides" will/must hibernate always use left outer joins to eagerly fetch data for single valued related entities?
My own experience is this
-When the relationship is defined by the top level entity being queried (depth 0), hibernate will use an inner join to the related table (depth 1) if the @ManyToOne is marked optional=false -When the relationship is owned by the top level entity being queried (depth 0), hibernate will use an outer join to the related table (depth 1) if the @ManyToOne is marked as optional=true
These two points make perfect sense to me. My third observation is what confuses me
-Related entities more then 1 level deep in the object graph are retrieved using an outer join, completely irrespective of the value of the optional on the @ManyToOne or @OneToOne relationship.
Is this just how it works? Is it possible to force inner joins to be used for optional=false relationships? It seems inconsistent but I'm probably missing something. Currently using 3.3.2 GA.
Thanks.
|