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

Activity

Show:
Gail Badner
February 24, 2016, 12:12 AM

Please provide a .hbm.xml mapping that reproduces the NPE.

Jean-François Boeuf
February 24, 2016, 9:46 AM
Edited

The issue is marshalling the JaxbHbmTuplizerType to xml. I know it is not a hibernate main feature and that's why I gave the lower priority. But as the JAXB bindings exist, let make them work... Might be very useful to generate mapping definition programmatically. I provided test cases with with the pull request that reproduce the problem. The simplest .hbm.xml that reproduces the problem is :

{{<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/orm/hbm">
<class>
<tuplizer class="org.hibernate.tuple.entity.DynamicMapEntityTuplizer"/>
<id/>
</class>
</hibernate-mapping>}}

This xml defines a valid mapping, but the generated binding cannot be reverted to xml (Try to marshall the generated JaxbHbmHibernateMapping back to xml).

Steve Ebersole
February 25, 2016, 3:06 AM

Same general comments as

Vlad Mihalcea
July 26, 2016, 8:24 AM

Applied PR upstream.

Fixed

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

Priority

Trivial
Configure