Hibernate 4.3到5.2升级的问题

时间:2017-06-02 11:44:47

标签: java hibernate upgrade hibernate-onetomany hibernate-session

我正在尝试将项目的Hibernate版本从 4.3 升级到 5.2 。我已经通过以下文档完成了升级所需的步骤

以及其他版本的升级文档。 但是,在进行必要的更改后,我遇到了一些运行时错误。

我采用了一个非常简单的示例模型,其中我的EntityModel看起来像这样:

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])])

但是在版本 5.2 中,当它试图在AttributeFactory.java中构建buildAttribute时,它抛出以下异常:

route

当它尝试构建属性时会发生这种情况 属性(name = ReporteesArr,type = java.util.Collection(cemployees_create.ReporteesArr)[non-identifier,association])])

只是想检查某人之前是否遇到此问题,或者是否有任何解决方法。使用Hibernate 4.3

可以完美地完成同样的工作

添加hibernate实体映射文件:

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)

0 个答案:

没有答案