Ticket #1364 (closed enhancement: fixed)

Opened 2 years ago

Last modified 22 months ago

Update Hibernate when HHH-4065 has been fixed

Reported by: nicklas Owned by: nicklas
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

comment:1 Changed 2 years ago by nicklas

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

comment:2 Changed 2 years ago by nicklas

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

comment:3 Changed 2 years ago by nicklas

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

comment:4 Changed 2 years ago by nicklas

(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 Changed 2 years ago by nicklas

  • Milestone changed from BASE 2.x+ to BASE 2.15

comment:6 Changed 2 years ago by nicklas

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

Updated to Hibernate 3.5.0.CR1.

comment:7 Changed 2 years ago by nicklas

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 Changed 2 years ago by nicklas

  • Status changed from new to assigned
  • Owner changed from everyone to nicklas

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

comment:9 Changed 2 years ago by nicklas

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

This fixes the join issue.

comment:10 Changed 22 months ago by nicklas

  • Status changed from assigned to closed
  • Resolution set to fixed

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