[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3856) Base class alias used where joined subclass alias should have been used.

Sagar Kar (JIRA) noreply at atlassian.com
Mon Apr 13 13:13:17 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3856?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32856#action_32856 ] 

Sagar Kar commented on HHH-3856:
--------------------------------

Yes, I agree it should be on the second outer join. 
I tried to debug and looked at hibernate's src code but it is overwhelming for me to understand how the query is generated and where I can fix it.
I tried to find if someone has already posted a similar bug but couldn't find any.
Is there a hiberntate developer's guide or something where I can get more insight into hibernates architecture?


> Base class alias used where joined subclass alias should have been used.
> ------------------------------------------------------------------------
>
>                 Key: HHH-3856
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3856
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-sql
>    Affects Versions: 3.2.2
>         Environment: Windows XP. Hibernate 3.2.2 ga. Database Oracle 10g
>            Reporter: Sagar Kar
>         Attachments: hibernate issue.zip
>
>
> We have defined a where clause on the <class name="A" table="A" where="ind = 'A'"> tag in the parent class.
> B is a joined subclass of A. B has a one to one relationship to another class X.
> When we try the following statement 
>       session.get(X.class, 1L);
> It generates the following query
> Hibernate: 
>     /* load hibernate.X */ select
>         x0_.ID as ID3_1_,
>         x0_.IND as IND3_1_,
>         b1_.id as ID1_0_,
>         b1_1_.IND as IND1_0_,
>         b1_.X_ID as X2_2_0_ 
>     from
>         X x0_ 
>     left outer join
>         B b1_ 
>             on x0_.ID=b1_.X_ID 
>             and (
>                 b1_1_.ind = 'A'
>             )  
>     left outer join
>         A b1_1_ 
>             on b1_.id=b1_1_.ID 
>     where
>         x0_.ID=?
> If you look at the "on " condition for B you will notice that its using b1_1_.ind='A' which is the parent's alias which hasn't been defined yet.
> Hence we get a invalid identifier error.
> It looks like the generated query is faulty.
> Do we already have a fix for this?
> I have attached the error log, hbm files, the test class and the oracle table create script.
> 		

-- 
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