Nested Join Criteria generates non-working SQL
----------------------------------------------
Key: EJB-380
URL:
http://opensource.atlassian.com/projects/hibernate/browse/EJB-380
Project: Hibernate Entity Manager
Issue Type: Bug
Environment: Hibernate version:
Core 3.2.6 GA
Annotations 3.3.1 GA
Entity Manager 3.3.2 GA
Name and version of the database you are using:
PostgreSQL 8.0.15
Reporter: Ristretto
Priority: Minor
A "org.postgresql.util.PSQLException: ERROR: table name "comp1x2_"
specified more than once" exception is thrown when executing the following query
using Criteria:
Criteria criteria = em.getSession().createCriteria(Customer.class);
criteria.createAlias("supplier", "supp1");
criteria.createAlias("supp1.company", "comp1");
criteria.add(Restrictions.eq("comp1.name", "Test Name"));
List<Customer> customers = criteria.list();
I have also tested the snippet of code with MySQL and obtained a similar MySQL exception.
The generated sql statement is as follows (Supplier is the superclass of Partner and
Provider and I'm using a Joined Table inheritance strategy) :
select [...] from Customer this_ inner join Supplier supp1x1_ on
this_.supplierId=supp1x1_.id
left outer join Provider supp1x1_1_ on supp1x1_.id=supp1x1_1_.id
left outer join Partner supp1x1_2_ on supp1x1_.id=supp1x1_2_.id
inner join Company comp1x2_ on supp1x1_1_.companyId=comp1x2_.id
inner join Company comp1x2_ on supp1x1_2_.companyId=comp1x2_.id where comp1x2_.name=?
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira