JEE bootstrapping should only parse and validate mapping files once

Description

Currently mapping files get parsed and validated twice during JEE bootstrapping:

  1. once in org.hibernate.ejb.Ejb3Configuration#addXMLEntities (from org.hibernate.ejb.Ejb3Configuration#configure, from org.hibernate.ejb.HibernatePersistence#createContainerEntityManagerFactory)

  2. again to actually add it to the configuration from org.hibernate.ejb.Ejb3Configuration#addClassesToSessionFactory (from org.hibernate.ejb.Ejb3Configuration#configure, from org.hibernate.ejb.HibernatePersistence#createContainerEntityManagerFactory)

AFAICT, the first occurrence is used to identify classes for potential enhancement.

Environment

None

Activity

Show:
Steve Ebersole
September 8, 2010, 9:46 PM

If I understand correctly, after the call to addXMLEntities we no longer really need the local List<String> xmlFiles variable for anything other than to pass it to (eventually) addClassesToSessionFactory so that they get added to the configuration. Seems to me the solution here is to save the parsed and validated DOM tree, once that code is fixed up ( see ), and pass that DOM tree into the config via a method that indicates it has already been validated.

Steve Ebersole
September 8, 2010, 9:51 PM

Note : org.hibernate.cfg.AnnotationConfiguration#add(org.dom4j.Document) (3.5) / org.hibernate.cfg.Configuration#add(XmlDocument) (3.6) would be the right place I guess.

Emmanuel Bernard
September 9, 2010, 10:11 AM

The only thing that rings a bell is that the code might use the file name for better error handling down the road but if you ahve not encountered that in the code path, that should be fine.

Steve Ebersole
September 9, 2010, 1:22 PM

This is handled much differently on trunk. In 3.5 and prior eventually you always added a Document to the Configuration, which of course lost the ability to report on source file names. I improved that in 3.6 to use a custom XmlDocument instead that wraps the Document with some other information called an Origin.

So I'll roll this change back on the 3.5 branch.

Steve Ebersole
September 9, 2010, 1:52 PM

rolling this back on 3.5 branch for error reporting concern

Fixed

Assignee

Steve Ebersole

Reporter

Steve Ebersole

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure