[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5613) Inheritance relation creates left outer join in stead of inner join btwn child and parent

Marc Schipperheyn (JIRA) noreply at atlassian.com
Fri Oct 1 09:56:57 EDT 2010


Inheritance relation creates left outer join in stead of inner join btwn child and parent
-----------------------------------------------------------------------------------------

                 Key: HHH-5613
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5613
             Project: Hibernate Core
          Issue Type: Improvement
          Components: core
    Affects Versions: 3.5.4
            Reporter: Marc Schipperheyn
            Priority: Minor


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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list