JaxbHbmTuplizerType marshalling does not conform hibernate-mapping-4.0.xsd

Description

Problem description

Marshalling a JaxbHbmTuplizerType to Xml :

  • Does not take into account the entity mode attribute may be null whereas the xml-schema does not specifies it as use="required" (a NPE is thrown).

  • Does not serialize the entity mode properly. The Enum litteral is inserted (POJO, MAP) instead of the xsd-specified values ("pojo", "dynamic-map"). Creating a session factory with the generated Xml throws a org.hibernate.boot.InvalidMappingException.

As a consequences, the xml cannot be generated or the generated xml does not define a valid mapping file.

Steps to reproduce

See attached file.

Workaround

The first problem (NPE) may be avoided specifying explicitly the entity mode but the generated xml still cannot be added to a Configuration.

Fix

org.hibernate.boot.jaxb.hbm.internal.EntityModeConverter.toXml(EntityMode) should return entityMode.getExternalName() instead of entityMode.name() and handle a potentially null argument.

Edit

  • Updated test case

  • provide patch for fix.

Environment

None

Status

Assignee

Steve Ebersole

Reporter

Jean-Fran├žois Boeuf

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.0.7
5.1.0

Priority

Trivial
Configure