-->
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.  [ 2 posts ] 
Author Message
 Post subject: DetachedCriteria SQL miss implicit join used as sub-select
PostPosted: Fri Aug 11, 2006 1:52 pm 
Newbie

Joined: Fri Mar 10, 2006 3:21 am
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.1

Mapping documents:
Two classes: Project (1--*) ProjectTask
The Project has a customer field, and the ProjectTask has a project field that links to the parent project object.


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
MySQL 5

The generated SQL (show_sql=true):


Debug level Hibernate log excerpt:

I am using the criteria query which contains a subselect that is done using th DetachedCriteria. However, the same DetachedCriteria generates correct SQL if used alone, but failed to generate the implicit join when used as a subselect of another criteria.

The following is the DetachedQuery:
Code:
            DetachedCriteria dc = DetachedCriteria.forClass(ProjectTask.class, "task").
            createAlias("project", "proj").
                setProjection(Projections.property("task.id")).
                add(Restrictions.eq("proj.customerName", "my_customer"));


When used alone:
Code:
            cusEmp.getExecutableCriteria(session).list();

It generates SQL:
Code:
select this_.id as y0_ from project_task this_ inner join project proj1_ on this_.project_id=proj1_.id where proj1_.customer_name=?



However, when put it as a subselect of another criteria, the SQL generated misses the implicit join between ProjectTask and Project. The following is the subselect SQL string:
Code:
(select this0__.id as y0_ from project_task this0__ where proj1_.customer_name=?)


As you can see, the SQL is not valid because it does not even mention the table project.

I think this is a bug, can someone confirm this?


Top
 Profile  
 
 Post subject: same problem
PostPosted: Mon Aug 14, 2006 4:11 pm 
Newbie

Joined: Sat Mar 11, 2006 4:15 pm
Posts: 15
I appear to have hit the same bug:
http://forum.hibernate.org/viewtopic.ph ... achedquery


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.