• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

@Embeddable containing @ManyToOne resulting in Exception

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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. 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;
}

@Table(Employee)
@Entity
public class Employee implements Serializable
{
@Id 
int emp_id;

@Embedded
JobInfo jobInfo;

Other attributes....
}

@Table(EmployeeSet)
@Entity
public class EmployeeSet implements Serializable
{
@Id 
int emp_set_id;

@Embedded
JobInfo jobInfo;

Other attributes....
}

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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic