-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: ManyToOne in @Embeddable getting exception.
PostPosted: Fri Feb 07, 2014 8:29 am 
Newbie

Joined: Fri Feb 07, 2014 7:58 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.