Hi,
I am getting the error while having ManyToOne relation in Embeddable and I cannot move this relationship in Specific Classes inorder to have better design. I have search alot but all in vain. Please help me out. Below is the code snippet.
@Embeddable public class JobInfo implements Serializable { @Column(name = "STATUS") private String m_statusCode;
@Column(name = "Name") private String m_name; @ManyToOne @JoinColumn(name = PM_ID) private ProgramManager pm; }
@Entity public class Employee implements Serializable { @Id int emp_id; @Embedded JobInfo jobInfo; }
@Entity public class EmployeeSet implements Serializable { @Id int emp_set_id; @Embedded JobInfo jobInfo; }
Below class has one to many relationship with Employee as well as EmployeeSet and the primary key of this class is a foreign key in Employee and EmployeeSet table. I have to use bidirectionalRelationship.
@Entity public class ProgramManager implements Serializable { @Id int id; @OneToMany(mappedBy = "jobInfo.pm", cascade = CascadeType.ALL, orphanRemoval = true) private Set<Employee> m_employees = new HashSet<Employee>();
@OneToMany(mappedBy = "jobInfo.pm", cascade = CascadeType.ALL, orphanRemoval = true) private Set<EmployeeSet> m_employees = new HashSet<EmployeeSet>(); }
I am getting the following error while validating the mapping both for employee and employeeset =========================================================================================== Unable to read the mapped by attribute for m_employees in Employee at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.getMappedBy(CollectionMetadataGenerator.java:653) at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addOneToManyAttached(CollectionMetadataGenerator.java:187) at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addCollection(CollectionMetadataGenerator.java:169) at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addValueInSecondPass(AuditMetadataGenerator.java:223) at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addValue(AuditMetadataGenerator.java:245) at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addProperties(AuditMetadataGenerator.java:258) at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateSecondPass(AuditMetadataGenerator.java:519) at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:114) at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:120) at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:177) at org.hibernate.envers.event.EnversIntegrator.integrate(EnversIntegrator.java:64) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:303) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1790) at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914) ... 23 more
|