[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2667) 'illegal attempt to dereference collection' when using auto-join

Nick Folder (JIRA) noreply at atlassian.com
Sun Jul 22 17:00:52 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_27589 ] 

Nick Folder commented on HHH-2667:
----------------------------------

>From the Hibernate 3.2 Migration Guide:

"Query language changes
Implicit joins are more deterministic

With such mapping:

<class name='Currency' lazy='false'>
   ....
</class>

<class name='Asset'>
  <id name='id' ... </id>
  <many-to-one name='currency' class='Currency' fetch='select'/>
</class> 

and such HQL query:

select a.id, a.currency from Asset a

Since Hibernate 3.2.2 this query generates an inner join on Asset with Currency which means that Assets with a NULL currency are not returned by the query anymore.

This makes implicit joins more deterministic.

To get Assets with a NULL currency just use

select a.id, c from Asset a left join a.currency as c

Path expressions joining across a collection throw exception

The always illegal statement:

select f.bars.baz from Foo f

Now throws an exception. Despite the always present warning in the documentation that this is an illegal path expression if bars is a collection, users found this to be working in some cases with Hibernate 3.1. This is no longer the case, an error is thrown. As always, the correct syntax is an explicit join:

select b.baz from Foo f join f.bars b"


> 'illegal attempt to dereference collection' when using auto-join
> ----------------------------------------------------------------
>
>                 Key: HHH-2667
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2667
>             Project: Hibernate3
>          Issue Type: Bug
>    Affects Versions: 3.2.3, 3.2.4, 3.2.4.sp1
>         Environment: I have found that behaviour in version 3.2.4.sp1 and 3.2.3 (I didn't test 3.2.4 pre sp1)
> Database: ORACLE 10g
>            Reporter: Martin Kouba
>
> After upgrading to the latest Hibernate version I got this error.
> I try to use a statement like this
> from cat c where c.mate.id = 13
> the expected resulting SQL should be something like
> SELECT * FROM CAT C WHERE C.MATE_ID = 13
> which is much more performant than making a join
> from cat c join c.mate m where m.id = 13
> which would result in something like that
> SELECT * FROM CAT C INNER JOIN MATE M ON C.MATE_ID = M.ID WHERE M.ID = 13
> This works as expected in 3.1.3, 3.2.0 and 3.2.2
> It doesn't work with version 3.2.3 and with 3.2.4.sp1.

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