Cannot marshall JaxbHbmBasicAttributeType to xml if the "generated" attribute is not specified

Description

bug description

Marshalling a JaxbHbmBasicAttributeType to xml throws a NPE if the generated attribut has not been set whereas the generated attribute of property-element is not declared as use="required" in the hibernate-mapping-4.0.xsd.

Step to reproduce

See attached test case

Workaround

explicitely set the generated attribute for JaxbHbmBasicAttributeType. It defaults to never, this value can be safely used.

Fix

handle a null argument in org.hibernate.boot.jaxb.hbm.internal.GenerationTimingConverter.toXml(GenerationTiming). See attached patch.

Environment

None

Activity

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

, IIUC, null should not be passed to GenerationTimingConverter#toXml. Please provide an hbm.xml mapping that causes this to happen..

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

The issue is marshalling the JaxbHbmBasicAttributeType 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>
<id/>
<property name="attributeName"/>
</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:05 AM

As you mention, this is outside the scope of Hibernate's use of the JAX bindings. We tend to write these kind of reports off as unsupported usages. This one is trivial enough that I think we can handle it. As long as the attached test really works as a regression (aka, I can use it to reproduce the problem currently) then I will consider it.

Jean-François Boeuf
March 4, 2016, 2:24 PM

Thanks to considerate my request. Please, only take into account the test included in the pull request which is much better than the one attached to this bug report (and I made a mistake attaching the .class instead of .java). I've just re-based my branches on master; the provided tests still reproduce the issues and all tests are still OK after fixing.

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

backportDecision

None

Components

Affects versions

Priority

Trivial
Configure