{code:java} @Entity @Audited public class EntityA { ... private EmbA emb; ... }
@Embeddable public class EmbA { ... @ManyToMany private List<EntityB> entityBList; ... }
@Entity @Audited public class EntityB { ... @ManyToMany(mappedBy = "emb.entityBList") private List<EntityA> entityAList2; ... } {code}
this generate this exception: org.hibernate.MappingException: Unable to read the mapped by attribute for entityAList2 in EntityA!
After I debug into the source code, I found the problem is here: {code: java} //org.hibernate.envers.configuration.internal.metadata.CollectionMetadataGenerator.java //line: 945 private String searchMappedBy(PersistentClass referencedClass, Table collectionTable) { final Iterator<Property> properties = referencedClass.getPropertyIterator(); while (properties.hasNext()) { final Property property = properties.next(); if (property.getValue() instanceof Collection) { //it skip the embeddable property which may contains relation property. ... } } } {code} |
|