I have a performance problem with a subquery using the criteria API.
The subquery is based on a base class, which is mapped all into the
same table, but uses <join>'s to separate data.

The problem is, the subquery always joins all the tables from all the
subclasses, even if they are not used and do not influence the result
(left outer join).

  <class name="A">
    <subclass name="B">
      <join table="B">
      </join>
    </subclass>
  </class>

Generated SQL:

  select .... from X
  where A_FK in
  (select id from A
    left outer join B on ...)

What I could do is make the join fetching by select:

  <join fetch="select">

But this would influence fetching in general, which is not what I
want.

Is there any way to optimize just this subquery? Could this be
considered a bug, or should I report this as a feature request (to
remove the joins in a subquery)?

PS: AFAIK, there isn't any (recommended) use for this joined tables in
the subquery. You can't really address these tables. Theoretically you
can use one of the properties of the inherited classes, but this is
not very recommendable because criteria "guesses" the type to be
filtered and just takes the first subtype declaring a property with
that name. When there are other subtypes with such a property, the
result will be unpredictable.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to