I have
@Entity
@Table(name = "Offer")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue(value = "OFF")
@DiscriminatorColumn(name = "DTYPE", length = 3)
public class Offer
@Entity
@DiscriminatorValue("JOB")
@SecondaryTable(name="JobOffer", pkJoinColumns =
{
@PrimaryKeyJoinColumn(name = "offerId", referencedColumnName = "offerId")
}
)
public class JobOffer extends Offer
When I run a detached Criteria query
DetachedCriteria dc = DetachedCriteria.forClass(JobOffer.class)
.add(
Restrictions.in("id", ids));
return getHibernateTemplate().findByCriteria(dc);
I see in the query something like this
from Offer this_
left outer join
JobOffer this_1_ on this_.offerID=this_1_.offerId
where this_.DTYPE='JOB' and this_.offerID in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
It would seem to me that it would make more sense to have an inner join here b/c JobOffer is a child of Offer and therefore must have a table relationship. Every row in JobOffer table should have a corresponding row in Offer table.
I would imagine that an outer join performs less than an inner join because the amount of rows evaluated would be less.