Opened 15 years ago

Closed 14 years ago

#1364 closed enhancement (fixed)

Update Hibernate when HHH-4065 has been fixed

Reported by: Nicklas Nordborg Owned by: Nicklas Nordborg
Priority: major Milestone: BASE 2.15
Component: core Version:
Keywords: Cc:

Description

The update to Hibernate 3.3.2 in #1350 had a nasty bug as a side-effect. It was possible to workaround this bug with a very ugly hack (see [5037]). Hopefully the Hibernate developers will fix the problem so that we can remove the hack.

Hibernate issue tracker: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4065

Change History (10)

comment:1 by Nicklas Nordborg, 14 years ago

Seems like the Hibernate developers are now working on this :)

comment:2 by Nicklas Nordborg, 14 years ago

An now it has been fixed! Scheduled to appear in 3.3.3 and 3.5.

comment:3 by Nicklas Nordborg, 14 years ago

Hibernate has released 3.5-beta-3 which includes the fix. I'll try it and see how it works.

comment:4 by Nicklas Nordborg, 14 years ago

(In [5220]) References #1364: Update Hibernate when HHH-4065 has been fixed

Updates Hibernate to 3.5.0-beta-3. The fix for HHH-4065 seems to work so I have removed the hack. I have not found any other problems either, but I'll leave this ticket open since we should upgrde to 3.5.0.GA when it is released.

comment:5 by Nicklas Nordborg, 14 years ago

Milestone: BASE 2.x+BASE 2.15

comment:6 by Nicklas Nordborg, 14 years ago

(In [5246]) References #1364: Update Hibernate when HHH-4065 has been fixed

Updated to Hibernate 3.5.0.CR1.

comment:7 by Nicklas Nordborg, 14 years ago

I have found an issue that is probably related to the new version. It is about how a specific HQL is translated to SQL.

Consider the following HQL which is used to list all samples which hasn't been connected to a well on a plate:

SELECT smp FROM SampleData smp 
LEFT JOIN bioWell.bioPlate alj1
WHERE bioWell.bioPlate.name IS NULL
ORDER BY name ASC

Hibernate is smart enough to match the 'bioWell.bioPlate' in the left join with the same in the where part. The generated SQL is (with Hibernate 3.2):

select ....
from `BioMaterials` sampledata0_ 
left outer join `BioWells` biowelldat1_ on sampledata0_.`biowell_id`=biowelldat1_.`id`
left outer join `BioPlates` bioplateda2_ on biowelldat1_.`bioplate_id`=bioplateda2_.`id` 
where sampledata0_.`discriminator`=2 and (bioplateda2_.`name` is null) 
order by sampledata0_.`name` ASC

With Hibernate 3.5 the following SQL is generated instead:

select ....
from `BioMaterials` sampledata0_ 
left outer join `BioWells` biowelldat1_ on sampledata0_.`biowell_id`=biowelldat1_.`id` 
left outer join `BioPlates` bioplateda2_ on biowelldat1_.`bioplate_id`=bioplateda2_.`id` 
cross join `BioPlates` bioplateda4_ 
where sampledata0_.`discriminator`=2 and biowelldat1_.`bioplate_id`=bioplateda4_.`id` and (bioplateda4_.`name` is null) 
order by sampledata0_.`name` ASC

There is now an extra "cross join" to the BioPlates table and the query doesn't return the expected result.

The solution is probably to use the alias assigned to the left join in the restriction:

SELECT smp FROM SampleData smp 
LEFT JOIN bioWell.bioPlate alj1
WHERE alj1.name IS NULL
ORDER BY name ASC

comment:8 by Nicklas Nordborg, 14 years ago

Owner: changed from everyone to Nicklas Nordborg
Status: newassigned

The old joining behavior was actually a Hibernate bug: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4091

comment:9 by Nicklas Nordborg, 14 years ago

(In [5261]) References #1364: Update Hibernate when HHH-4065 has been fixed

This fixes the join issue.

comment:10 by Nicklas Nordborg, 14 years ago

Resolution: fixed
Status: assignedclosed

(In [5305]) Fixes #1364: Update Hibernate when HHH-4065 has been fixed

3.5.0 has now been released by the Hibernate team.

Note: See TracTickets for help on using tickets.