I am trying to upgrade the Hibernate version of our project from 4.3 to 5.2.I have gone through the steps required for upgrading by going through the following documents
and the upgrade documents for other releases as well. However after making the required changes, i am facing some runtime errors.
I took a very simple example model, where in my EntityModel looks like this:
EntityMetamodel(cemployees_create:[Attribute(name=LastName, type=string [non-identifier]),Attribute(name=FirstName, type=string [non-identifier]),Attribute(name=BirthDate, type=timestamp [non-identifier]),Attribute(name=HireDate, type=timestamp [non-identifier]),Attribute(name=Photo, type=binary [non-identifier]),Attribute(name=ReportsTo, type=cemployees_create [non-identifier,association]),Attribute(name=ReporteesArr, type=java.util.Collection(cemployees_create.ReporteesArr) [non-identifier,association])])
However in version 5.2 when its trying to buildAttribute in AttributeFactory.java, its throwing the following exception:
java.lang.IllegalArgumentException: Expecting collection type [org.hibernate.type.BagType]
at org.hibernate.metamodel.internal.AttributeFactory.determineCollectionType(AttributeFactory.java:937)
at org.hibernate.metamodel.internal.AttributeFactory$PluralAttributeMetadataImpl.<init>(AttributeFactory.java:786)
at org.hibernate.metamodel.internal.AttributeFactory$PluralAttributeMetadataImpl.<init>(AttributeFactory.java:767)
at org.hibernate.metamodel.internal.AttributeFactory.determineAttributeMetadata(AttributeFactory.java:548)
at org.hibernate.metamodel.internal.AttributeFactory.buildAttribute(AttributeFactory.java:77)
at org.hibernate.metamodel.internal.MetadataContext.wrapUp(MetadataContext.java:213)
at org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:220)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:297)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:452)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710)
This is happening when its trying to build the Attribute for Attribute(name=ReporteesArr, type=java.util.Collection(cemployees_create.ReporteesArr) [non-identifier,association])])
Just wanted to check if someone has faced this problem before or if there are any resolutions to it. The same thing works perfectly fine with Hibernate 4.3
Adding the hibernate Entity Mapping file as well:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="cfsuite.orm.manual.relationship.self_join">
<class entity-name="cemployees" table="Employees">
<tuplizer class="coldfusion.orm.hibernate.CFCTuplizer" entity-mode="dynamic-map"/>
<id column="EmployeeID" name="EmployeeID" type="integer">
<generator class="native"/>
</id>
<property column="LastName" name="LastName" type="string"/>
<property column="FirstName" name="FirstName" type="string"/>
<property column="Title" name="Title" type="string"/>
<property column="TitleOfCourtesy" name="TitleOfCourtesy" type="string"/>
<property column="BirthDate" name="BirthDate" type="date"/>
<property column="HireDate" name="HireDate" type="date"/>
<property column="Address" name="Address" type="string"/>
<property column="City" name="City" type="string"/>
<property column="Region" name="Region" type="string"/>
<property column="PostalCode" name="PostalCode" type="string"/>
<property column="Country" name="Country" type="string"/>
<property column="HomePhone" name="HomePhone" type="string"/>
<property column="Extension" name="Extension" type="string"/>
<property column="Photo" name="Photo" type="binary"/>
<property column="Notes" name="Notes" type="string"/>
<many-to-one column="ReportsTo" entity-name="cemployees" name="ReportsToObj"/>
<property column="PhotoPath" name="PhotoPath" type="string"/>
<bag cascade="all-delete-orphan" name="ReporteesArr">
<key column="ReportsTo"/>
<one-to-many entity-name="cemployees"/>
</bag>
</class>
</hibernate-mapping>