Issue Details (XML | Word | Printable)

Key: SPR-2305
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Juergen Hoeller
Reporter: Josh Moore
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Spring Framework

FilterDefinitions should be added to Hibernate LocalSessionFactoryBean before *.hbm.xml and *.cfg.xml

Created: 16/Jul/06 07:13 AM   Updated: 28/Sep/06 08:32 AM
Component/s: SpringDA
Affects Version/s: 1.2.8, 2.0 RC2, 2.0 RC3, 2.0 RC4
Fix Version/s: 2.0 final, 1.2.9

Time Tracking:
Not Specified

File Attachments: 1. Text File localsessionfactorybean.patch (0.5 kB)
2. File LocalSessionFactoryBean.patch2 (2 kB)

Environment: Hibernate 3.2.cr2


 Description  « Hide
FilterDefinitions defined by FilterDefinitionFactoryBeans should be added to the Hibernate configuration before other configuration files (*.hbm.xml and *.cfg.xml) are added to prevent null pointer exceptions in org.hibernate.cfg.HbmBinder.parseFilter (line 2895)

Such null pointer exceptions occur only when the filters defined in the <class> mappings rely on the <filter-def/> for the condition, i.e. if the filter-def has a condition defined and the filter elements in the class mappings do not, then a null pointer exception will occur.

This is apparently a known problem from the Hibernate team. From HbmBinder.parseFilter line 2888 (3.2.cr2):

//TODO: bad implementation, cos it depends upon ordering of mapping doc
// fixing this requires that Collection/PersistentClass gain access
// to the Mappings reference from Configuration (or the filterDefinitions
// map directly) sometime during Configuration.buildSessionFactory
// (after all the types/filter-defs are known and before building
// persisters).

Not reporting to Hibernate team -- this implies there is some partial ordering of additions to the Hibernate configuration, and Spring will apparently be responsible for knowing what that ordering is.

 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Josh Moore added a comment - 16/Jul/06 07:39 AM
Confirmed that the attached patch will make this work (in my case).

Didn't see any infrastructure for actually running hibernate tests (with hsqldb, for example) in the Spring /test directory. Any suggestions?

If desired I can submit a test that I can compile, but won't necessarily work within the Spring build system.

Josh Moore added a comment - 16/Jul/06 07:43 AM
Forgot to mention, patch is against 2.0-rc2 (with dependencies download).

Josh Moore added a comment - 28/Sep/06 03:53 AM
Same patch updated for 2.0-M4. Also, this issue has been reported to Hibernate:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2091

Juergen Hoeller added a comment - 28/Sep/06 08:30 AM
Thanks for pointing this out! I've refined Spring's LocalSessionFactoryBean to register filter definitions before loading any mapping files. This doesn't hurt, so we can easily keep it that way even once the Hibernate team fixes those config order issues.

Juergen