Issue Details (XML | Word | Printable)

Key: SPR-4332
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Juergen Hoeller
Reporter: Kenny MacLeod
Votes: 0
Watchers: 1
Operations

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

AnnotationSessionFactoryBean broken when specifying both XML mapping and Annotation classes

Created: 14/Jan/08 05:59 AM   Updated: 14/Jan/08 08:52 AM
Component/s: None
Affects Version/s: 2.5.1
Fix Version/s: 2.5.2

Time Tracking:
Not Specified


 Description  « Hide
We have an application which uses the Hibernate AnnotationSessionFactoryBean, and which (for legacy reasons) specifies some mapped classes using an XML file, and some others using annotated classes. Some of the mappings in the XML file referred to classes mapped by annotations, and vice versa.

Under 2.5, this worked fine. The bean would read the XML mapping file, then the annotated mappings, and "blend" them.

However, due to the change in 2.5.1 to LocalSessionFactoryBean (see SPR-2586), the XML mappings are eagerly compiled before the code in AnnotationSessionFactoryBean gets a look in, and because the XML mapping refers to annotation-mapped classes, this fails.

I was sure that this way of specifying mappings was valid and legal according to the documentation, but I can't seem to find the reference anywhere. It may have been wishful thinking on my part, and that this in fact a valid configuration.

 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Juergen Hoeller added a comment - 14/Jan/08 08:52 AM
Oops, that's an unintended side effect. Your configuration is of course valid.

I've fixed this for Spring 2.5.2, through introducing a "postProcessMappings" template method that AnnotationSessionFactoryBean implements now - invoked before "Configuration.buildMappings()".

This should be available in tonight's 2.5.2 snapshot (-368), available from http://static.springframework.org/downloads/nightly/snapshot-download.php?project=SPR
Please give it a try and let me know whether it works for you!

Juergen