Envers无法读取映射的属性

Envers无法读取映射的属性

本文介绍了Hibernate / Envers无法读取映射的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用连接表实现多对多关系()。当我尝试重现它时,持久单元无法构建EntityManagerFactory。 Envers似乎无法读取映射的属性,虽然它看起来不错。我究竟做错了什么?使用额外列(和Envers)实现多对多关系的正确方法是什么?



Product.java

  @Entity 
@Audited
public class Product extends UserModel {
...
@OneToMany(mappedBy =product,orphanRemoval = true,cascade = CascadeType.ALL,fetch = FetchType.EAGER)
public List< ProductForm> forms = new ArrayList< ProductForm>();
...
}

Form.java

  @Entity 
@Audited
public class Form extends UserModel {
...
@OneToMany(mappedBy =form,fetch = FetchType.LAZY)
public List< ProductForm> products = new ArrayList< ProductForm>();
...
}

ProductForm.java

  @Entity 
@Table(name =Product_Form)
@IdClass(ProductForm.ProductFormId .class)
public class ProductForm {
@Id
@JoinColumn(name =product_id)
@ManyToOne
public Product product;

@Id
@JoinColumn(name =form_id)
@ManyToOne
public Form表单;

public ProductForm(Product product,Form form){
this.product = product;
this.form = form;

$ b @Embeddable
@SuppressWarnings(serial)
public class ProductFormId实现Serializable {
@Column(name =product_id)
公共长产品;

@Column(name =form_id)
public Long form;


堆栈跟踪 p>

  play.api.UnexpectedException:意外的异常[PersistenceException:[PersistenceUnit:defaultPersistenceUnit]无法构建EntityManagerFactory] ​​
在播放。 core.ReloadableApplication $$ anonfun $ get $ 1 $$ anonfun $ 1.apply(ApplicationProvider.scala:142)〜[play_2.10-2.1.1.jar:2.1.1]
at play.core.ReloadableApplication $$ anonfun $ get $ 1 $$ anonfun $ 1.apply(ApplicationProvider.scala:106)〜[play_2.10-2.1.1.jar:2.1.1]
at scala.Option.map(Option.scala:145) 〜[scala-library.jar:na]
在play.core.ReloadableApplication $$ anonfun $ get $ 1.apply(ApplicationProvider.scala:106)〜[play_2.10-2.1.1.jar:2.1.1 ]
在play.core.ReloadableApplication $$ anonfun $ get $ 1.apply(ApplicationProvider.scala:104)〜[play_2.10-2.1.1.jar:2.1.1]
at scala.util 。$ RightProjection.flatMap(Either.scala:523)[scala-library.jar:na]
由:javax.persistence.PersistenceExcept ion:[PersistenceUnit:defaultPersistenceUnit]无法在org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:930)〜[hibernate-entitymanager-4.2.0.Final.jar:4.2.0]上构建EntityManagerFactory
。最终]
在org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)〜[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
at org。 hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:72)〜[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java :63)〜[hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)〜[hibernate- jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
在play.db.jpa.JPAPlugin.onStart(JPAPlugin.java:35)〜[play-java-jpa_2.10 -2.1.1.jar:2.1.1]
导致:org.hibernate.MappingException:Unable读取models.ProductForm中产品的映射属性。
at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.getMappedBy(CollectionMetadataGenerator.java:642)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addOneToManyAttached(CollectionMetadataGenerator.java:187)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.envers .org.hibernate.envers.configuration.metadata.configuration.metadata.CollectionMetadataGenerator.addCollection(CollectionMetadataGenerator.java:169)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
。 AuditMetadataGenerator.addValueInSecondPass(AuditMetadataGenerator.java:223)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addValue(AuditMetadataGenerator .java:245)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addProperties( AuditMetadataGenerator.java:258)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]






PS我尝试将 @AuditMappedBy(mappedBy =product)添加到Product:

  play.api.UnexpectedException:意外的异常[PersistenceException:[PersistenceUnit:defaultPersistenceUnit]无法在play.core创建EntityManagerFactory] ​​
。 ReloadableApplication $$ anonfun $ get $ 1 $$ anonfun $ 1.apply(ApplicationProvider.scala:142)〜[play_2.10-2.1.1.jar:2.1.1]
at play.core.ReloadableApplication $$ anonfun $ (scala.Option.map)(Option.scala:145)〜[[play_2.10-2.1.1.jar:2.1.1]
获得$ 1 $$ anonfun $ 1.apply(ApplicationProvider.scala:106) scala-library.jar:na]
在play.core.ReloadableApplication $$ anonfun $ get $ 1.apply(ApplicationProvider.scala:106)〜[play_2.10-2.1.1.jar:2.1.1]
at play.core.ReloadableApplication $$ anonfun $ get $ 1.apply(ApplicationProvider.scala:104)〜[play_2.10-2.1.1.jar:2.1.1]
at scal a.util.Either $ RightProjection.flatMap(Either.scala:523)[scala-library.jar:na]
导致:javax.persistence.PersistenceException:[PersistenceUnit:defaultPersistenceUnit]无法构建EntityManagerFactory
在org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:930)〜[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.ejb.Ejb3Configuration .buildEntityManagerFactory(Ejb3Configuration.java:904)〜[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:72) 〜[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)〜[hibernate-jpa-2.0-api-1.0 .1.Final.jar:1.0.1.Final]
在javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)〜[hibernate-jpa-2.0-api-1.0.1.Final.jar: 1.0.1.Final]
在play.db.jpa .JPAPlugin.onStart(JPAPlugin.java:35)〜[play-java-jpa_2.10-2.1.1.jar:2.1.1]
引起:org.hibernate.MappingException:@AuditMappedBy指向一个属性不存在:models.ProductForm.product $ b $在org.hibernate.envers.configuration.ClassesAuditingData.forcePropertyInsertable(ClassesAuditingData.java:84)〜[hibernate-envers-4.2.0.Final.jar:4.2。 0.Final]
at org.hibernate.envers.configuration.ClassesAuditingData.updateCalculatedFields(ClassesAuditingData.java:70)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
在org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:85)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.envers .configuration.AuditConfiguration。< init>(AuditConfiguration.java:114)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.envers.configuration.AuditConfiguration .getFor(AuditConfiguration.java:164)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.F inal]
at org.hibernate.envers.event.EnversIntegrator.integrate(EnversIntegrator.java:64)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]






编辑 $ b

当我将 @Audited 添加到 ProductForm 仍然有相同的错误时,以下是最新的堆栈跟踪。

  play.api.UnexpectedException:意外的异常[PersistenceException:[PersistenceUnit:defaultPersistenceUnit]无法构建EntityManagerFactory] ​​
at play.core.ReloadableApplication $$ anonfun $ get $ 1 $$ anonfun $ 1.apply(ApplicationProvider.scala:142)〜[play_2.10-2.1.1.jar:2.1.1]
at play .core.ReloadableApplication $$ anonfun $ get $ 1 $$ anonfun $ 1.apply(ApplicationProvider.scala:106)〜[play_2.10-2.1.1.jar:2.1.1]
at scala.Option.map(在play.core.ReloadableApplication $$ anonfun $ get $ 1.apply(ApplicationProvider.scala:106)〜[play_2.10-2.1.1]中获得$ [$ scb-library.jar:na]的.jar:2.1。 1]
在play.core.ReloadableApplication $$ anonfun $获得$ 1.apply(ApplicationProvider.scala:104)〜[play_2.10-2.1.1.jar:2.1.1]
在scala。 util.Either $ RightProjection.flatMap(Either.scala:523)[scala-library.jar:na]
导致:javax.persistence.PersistenceException:[PersistenceUnit:defaultPersistenceUnit]无法构建EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:930)〜[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory (Ejb3Configuration.java:904)〜[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:72)〜[ hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
在javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)〜[hibernate-jpa-2.0-api-1.0.1 .Final.jar:1.0.1.Final]
在javax.pers istence.Persistence.createEntityManagerFactory(Persistence.java:47)〜[hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
at play.db.jpa.JPAPlugin.onStart (JPAPlugin.java:35)〜[play-java-jpa_2.10-2.1.1.jar:2.1.1]
原因:org.hibernate.MappingException:无法读取产品的映射依据属性models.ProductForm!
at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.getMappedBy(CollectionMetadataGenerator.java:642)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addOneToManyAttached(CollectionMetadataGenerator.java:187)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.envers .org.hibernate.envers.configuration.metadata.configuration.metadata.CollectionMetadataGenerator.addCollection(CollectionMetadataGenerator.java:169)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
。 AuditMetadataGenerator.addValueInSecondPass(AuditMetadataGenerator.java:223)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addValue(AuditMetadataGenerator .java:245)〜[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addProperties(
如果你的问题是由组合键引起的,那么如果可能的话,将你的休眠版本更新为5.2.2。因为此错误已在此版本中得到解决。



请参阅:


I am unable to implement many-to-many relation using join table (https://stackoverflow.com/a/7603036 & https://en.wikibooks.org/wiki/Java_Persistence/ManyToMany#Mapping_a_Join_Table_with_Additional_Columns). When I try to reproduce it persistence unit is unable to build EntityManagerFactory. It seems that Envers fails to read the mapped by attribute, although it looks good to me. What am I doing wrong? What is the right way™ to implement many-to-many relation with extra columns (and Envers)?

Product.java

@Entity
@Audited
public class Product extends UserModel {
...
    @OneToMany(mappedBy = "product", orphanRemoval = true, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    public List<ProductForm> forms = new ArrayList<ProductForm>();
...
}

Form.java

@Entity
@Audited
public class Form extends UserModel {
...
    @OneToMany(mappedBy = "form", fetch = FetchType.LAZY)
    public List<ProductForm> products = new ArrayList<ProductForm>();
...
}

ProductForm.java

@Entity
@Table(name = "Product_Form")
@IdClass(ProductForm.ProductFormId.class)
public class ProductForm {
    @Id
    @JoinColumn(name = "product_id")
    @ManyToOne
    public Product product;

    @Id
    @JoinColumn(name = "form_id")
    @ManyToOne
    public Form form;

    public ProductForm(Product product, Form form) {
        this.product = product;
        this.form = form;
    }

    @Embeddable
    @SuppressWarnings("serial")
    public class ProductFormId implements Serializable {
        @Column(name = "product_id")
        public Long product;

        @Column(name = "form_id")
        public Long form;
    }
}

Stack trace

play.api.UnexpectedException: Unexpected exception[PersistenceException: [PersistenceUnit: defaultPersistenceUnit] Unable to build EntityManagerFactory]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$1.apply(ApplicationProvider.scala:142) ~[play_2.10-2.1.1.jar:2.1.1]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$1.apply(ApplicationProvider.scala:106) ~[play_2.10-2.1.1.jar:2.1.1]
    at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
    at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:106) ~[play_2.10-2.1.1.jar:2.1.1]
    at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:104) ~[play_2.10-2.1.1.jar:2.1.1]
    at scala.util.Either$RightProjection.flatMap(Either.scala:523) [scala-library.jar:na]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: defaultPersistenceUnit] Unable to build EntityManagerFactory
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:930) ~[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) ~[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:72) ~[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) ~[hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) ~[hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
    at play.db.jpa.JPAPlugin.onStart(JPAPlugin.java:35) ~[play-java-jpa_2.10-2.1.1.jar:2.1.1]
Caused by: org.hibernate.MappingException: Unable to read the mapped by attribute for products in models.ProductForm!
    at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.getMappedBy(CollectionMetadataGenerator.java:642) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addOneToManyAttached(CollectionMetadataGenerator.java:187) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addCollection(CollectionMetadataGenerator.java:169) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addValueInSecondPass(AuditMetadataGenerator.java:223) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addValue(AuditMetadataGenerator.java:245) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addProperties(AuditMetadataGenerator.java:258) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]


PS I tried to add @AuditMappedBy(mappedBy = "product") to Product:

play.api.UnexpectedException: Unexpected exception[PersistenceException: [PersistenceUnit: defaultPersistenceUnit] Unable to build EntityManagerFactory]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$1.apply(ApplicationProvider.scala:142) ~[play_2.10-2.1.1.jar:2.1.1]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$1.apply(ApplicationProvider.scala:106) ~[play_2.10-2.1.1.jar:2.1.1]
    at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
    at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:106) ~[play_2.10-2.1.1.jar:2.1.1]
    at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:104) ~[play_2.10-2.1.1.jar:2.1.1]
    at scala.util.Either$RightProjection.flatMap(Either.scala:523) [scala-library.jar:na]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: defaultPersistenceUnit] Unable to build EntityManagerFactory
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:930) ~[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) ~[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:72) ~[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) ~[hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) ~[hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
    at play.db.jpa.JPAPlugin.onStart(JPAPlugin.java:35) ~[play-java-jpa_2.10-2.1.1.jar:2.1.1]
Caused by: org.hibernate.MappingException: @AuditMappedBy points to a property that doesn't exist: models.ProductForm.product
    at org.hibernate.envers.configuration.ClassesAuditingData.forcePropertyInsertable(ClassesAuditingData.java:84) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.configuration.ClassesAuditingData.updateCalculatedFields(ClassesAuditingData.java:70) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:85) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:114) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:164) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.event.EnversIntegrator.integrate(EnversIntegrator.java:64) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]


Edit

When I add @Audited to ProductForm is still get same error, below is the newest stack trace.

play.api.UnexpectedException: Unexpected exception[PersistenceException: [PersistenceUnit: defaultPersistenceUnit] Unable to build EntityManagerFactory]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$1.apply(ApplicationProvider.scala:142) ~[play_2.10-2.1.1.jar:2.1.1]
    at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$1.apply(ApplicationProvider.scala:106) ~[play_2.10-2.1.1.jar:2.1.1]
    at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
    at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:106) ~[play_2.10-2.1.1.jar:2.1.1]
    at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:104) ~[play_2.10-2.1.1.jar:2.1.1]
    at scala.util.Either$RightProjection.flatMap(Either.scala:523) [scala-library.jar:na]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: defaultPersistenceUnit] Unable to build EntityManagerFactory
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:930) ~[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) ~[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:72) ~[hibernate-entitymanager-4.2.0.Final.jar:4.2.0.Final]
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) ~[hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) ~[hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
    at play.db.jpa.JPAPlugin.onStart(JPAPlugin.java:35) ~[play-java-jpa_2.10-2.1.1.jar:2.1.1]
Caused by: org.hibernate.MappingException: Unable to read the mapped by attribute for products in models.ProductForm!
    at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.getMappedBy(CollectionMetadataGenerator.java:642) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addOneToManyAttached(CollectionMetadataGenerator.java:187) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addCollection(CollectionMetadataGenerator.java:169) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addValueInSecondPass(AuditMetadataGenerator.java:223) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addValue(AuditMetadataGenerator.java:245) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
    at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addProperties(AuditMetadataGenerator.java:258) ~[hibernate-envers-4.2.0.Final.jar:4.2.0.Final]
解决方案

If you problem is caused by Composite keys, then update your hibernate version to 5.2.2 if possible. Because this bug was fixed in this version.

See: https://hibernate.atlassian.net/browse/HHH-7625

这篇关于Hibernate / Envers无法读取映射的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 14:15