-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Nested Join Criteria generates non-working SQL
PostPosted: Tue Aug 12, 2008 10:22 am 
Newbie

Joined: Tue Aug 12, 2008 10:05 am
Posts: 3
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

Problem

Hi Experts

I have applied the solution as given in http://forum.hibernate.org/viewtopic.php?t=947709 regarding the deeply nested join problem but haven't been able to find a working solution. I keep getting the following exception and have no idea why:
    org.postgresql.util.PSQLException: ERROR: table name "comp1x2_" specified more than once

As you can see from the exception I am currently using PostgreSQL for the database but I have also tested the snippet of code with MySQL and obtained a similar MySQL exception. The Hibernate Criteria code snippet producing the exception is as follows:
Code:
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();


Any help would be appreciated!

Ristretto


Last edited by Ristretto on Tue Aug 19, 2008 9:28 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Same Problem
PostPosted: Thu Aug 14, 2008 8:19 am 
Newbie

Joined: Tue Aug 12, 2008 9:48 am
Posts: 1
Location: South Africa
Have you found a solution? I am struggling with the same problem.


Top
 Profile  
 
 Post subject: Re: Same Problem
PostPosted: Tue Aug 19, 2008 9:18 am 
Newbie

Joined: Tue Aug 12, 2008 10:05 am
Posts: 3
clschulz63 wrote:
Have you found a solution? I am struggling with the same problem.

Not yet! This is still a major headache for me. I would greatly appreciate any help or nudge in the right direction. I could be using the Criteria API incorrectly although I would have expected a hibernate exception if that were the case. Please help!


Top
 Profile  
 
 Post subject: SQL
PostPosted: Tue Aug 19, 2008 11:18 am 
Newbie

Joined: Tue Aug 12, 2008 10:05 am
Posts: 3
I'm posting the last part of the generated SQL for the criteria and hopefully it will help in identifying the problem. Supplier is the superclass of Partner and Provider and I'm using a Joined Table inheritance strategy.
Code:
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=?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.