Hello Team,
We have a scenario in which we are using hbmxml files, While it seems to work fine with Hibenrate version 4.3. When we upgraded hibernate orm version to 5.2, We started getting the following error:
ORM cannot be initialized. Root cause org.xml.sax.SAXParseException; systemId: file:/E:/APPS/PHX/DEV/approot/model/entity/user.hbmxml; lineNumber: 125; columnNumber: 16; The content of element type "subclass" must match "(meta*,tuplizer*,synchronize*,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,join*,subclass*,loader?,sql-insert?,sql-update?,sql-delete?,fetch-profile*,resultset*,(query|sql-query)*)".
The detailed stack trace is as shown below:
org.xml.sax.SAXParseException; systemId: file:/E:/APPS/PHX/DEV/approot/model/entity/user.hbmxml; lineNumber: 125; columnNumber: 16; The content of element type “subclass” must match “(meta*,tuplizer*,synchronize*,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array),join,subclass*,loader?,sql-insert?,sql-update?,sql-delete?,fetch-profile*,resultset*,(query|sql-query)*)”. java.lang.NullPointerException
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXConnector$1.getPublicId(StAXConnector.java:101)
at org.apache.xerces.util.SAXLocatorWrapper.getPublicId(Unknown Source)
at org.apache.xerces.xni.parser.XMLParseException.(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unknown Source)
at com.sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startElement(ValidatingUnmarshaller.java:101)
at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:75)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXEventConnector.handleStartElement(StAXEventConnector.java:261)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXEventConnector.bridge(StAXEventConnector.java:130)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:460)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:435)
at org.hibernate.boot.jaxb.internal.AbstractBinder.jaxb(AbstractBinder.java:171)
at org.hibernate.boot.jaxb.internal.MappingBinder.doBind(MappingBinder.java:61)
at org.hibernate.boot.jaxb.internal.AbstractBinder.doBind(AbstractBinder.java:102)
at org.hibernate.boot.jaxb.internal.AbstractBinder.bind(AbstractBinder.java:84)
at org.hibernate.boot.jaxb.internal.JaxpSourceXmlSource.doBind(JaxpSourceXmlSource.java:29)
at org.hibernate.boot.MetadataSources.addDocument(MetadataSources.java:409)
at org.hibernate.cfg.Configuration.addDocument(Configuration.java:462)
The generated hbmxml is as shown below:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<subclass discriminator-value="user" entity-name="user"
extends="cfc.model.entity.baseEntity" lazy="true" name="cfc.model.entity.user">
<bag name="loginSessions">
<key column="userID"/>
<one-to-many class="cfc.model.entity.loginSession"/>
</bag>
<bag name="permissions" table="user_permission">
<key column="userID"/>
<many-to-many class="cfc.model.entity.permission" column="permissionID"/>
</bag>
<bag cascade="save-update" name="groups" table="user_group">
<key column="userID"/>
<many-to-many class="cfc.model.entity.group" column="groupID"/>
</bag>
<bag cascade="save-update" name="groupAdmins" table="group_groupAdmin">
<key column="userID"/>
<many-to-many class="cfc.model.entity.group" column="groupID"/>
</bag>
<bag cascade="save-update" name="favorites">
<key column="userID"/>
<one-to-many class="cfc.modules.favorites.model.entity.favorite"/>
</bag>
<bag name="recipients" order-by="namedAddress">
<key column="userID"/>
<one-to-many class="cfc.model.entity.recipient"/>
</bag>
<bag name="alerts">
<key column="userID"/>
<one-to-many class="cfc.model.entity.alert"/>
</bag>
<bag name="orders">
<key column="userID"/>
<one-to-many class="cfc.model.entity.order"/>
</bag>
<bag name="carts">
<key column="userID"/>
<one-to-many class="cfc.model.entity.cart"/>
</bag>
<bag name="subscriptions">
<key column="userID"/>
<one-to-many class="cfc.model.entity.subscription"/>
</bag>
<bag name="trustees" table="trustee">
<key column="userID"/>
<many-to-many class="cfc.model.entity.user" column="trusteeID"/>
</bag>
<bag name="trusters" table="trustee">
<key column="trusteeID"/>
<many-to-many class="cfc.model.entity.user" column="userID"/>
</bag>
<bag name="reportingContactClients" table="client_reportingContact">
<key column="userID"/>
<many-to-many class="cfc.model.entity.client" column="clientID"/>
</bag>
<bag name="billingContactClients" table="client_billingContact">
<key column="userID"/>
<many-to-many class="cfc.model.entity.client" column="clientID"/>
</bag>
<bag name="relationshipManagerClients" table="client_relationshipManager">
<key column="userID"/>
<many-to-many class="cfc.model.entity.client" column="clientID"/>
</bag>
<bag cascade="save-update" name="alertProducts" table="alert">
<key column="userID"/>
<many-to-many class="cfc.model.entity.product" column="productID"/>
</bag>
<join table="`user`">
<key column="userID"/>
<property name="username" type="string">
<column name="username"/>
</property>
<property name="password" type="string">
<column name="password" sql-type="char(64)"/>
</property>
<property name="firstname" type="string">
<column name="firstname"/>
</property>
<property name="lastname" type="string">
<column name="lastname"/>
</property>
<property name="status" type="string">
<column name="status"/>
</property>
<property name="failedLoginsSinceLastLogin" type="int">
<column default="0" name="failedLoginsSinceLastLogin" not-null="true"/>
</property>
<property generated="insert" name="userGUID" type="string">
<column name="userGUID" not-null="true"/>
</property>
<property name="title" type="string">
<column name="title"/>
</property>
<property name="bio" type="string">
<column name="bio" sql-type="nvarchar(MAX)"/>
</property>
<property name="profilePictureFile" type="string">
<column name="profilePictureFile"/>
</property>
<property name="eSignatureFile" type="string">
<column name="eSignatureFile"/>
</property>
<property name="company" type="string">
<column name="company"/>
</property>
<property name="email" type="string">
<column name="email"/>
</property>
<property name="isSiteMinderUser" type="boolean">
<column default="0" name="isSiteMinderUser"
not-null="true" sql-type="bit"/>
</property>
<many-to-one class="cfc.model.entity.client"
column="clientID" name="client"/>
<many-to-one class="cfc.model.entity.costCenter"
column="costCenterID" name="userCostCenter"/>
<many-to-one class="cfc.model.entity.role" column="roleID" name="role"/>
</join>
<one-to-one class="cfc.model.entity.wholesaler"
name="wholesaler" property-ref="user"/>
<one-to-one class="cfc.model.entity.external_User"
name="externalUser" property-ref="user"/>
</subclass>
</hibernate-mapping>
I checked the difference between generated hbmxmls in both Hibernate 5.2 and Hibernate 4.3 and it looks almost similar apart rom DTD
we have the following DTD in Hibernate 5.2
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
In Hibernate 4.3, we are using the following DTD
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
i wanted to check if anything changed in between these two versions, The EntityResolver that i was using for Hibernate 4.3 was DEFAULT_DTD_RESOLVER which i changed to DTDEntityResolver for hibernate 5.2
Can someone please let me know if there are any changes or anything that i need to fix here.
Some pointers here will be highly useful for me.
Thanks in Advance!!