I'm receiving the following exception and have looked around to understand what may be wrong but just don't understand what I'm doing wrong. My main attempt is to properly represent foreign key in Agent that refers to Minor_Stage_Configuration table FDS_Minor_Stage_Configuration_ID. I've read the documentation but don't fully understand how the two entities know about each other.
Agent.javaCode:Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on net.fractech.ops.fds.db.Agent.minorStageConfigIdFK references an unknown entity: int at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:107) at org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1580) at org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1503) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1419) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1375) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1519) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:193) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1100) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:689) at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:242) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1479) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 20 more
MinorStageConfig.javaCode:@Entity @Table(name="Agent") public class Agent implements Serializable { private int minorStageConfigIdFK; // the element name for this element in the table is Minor_Stage_Configuration_ID_FK @NotNull @ManyToOne @JoinColumn(name="Minor_Stage_Configuration_ID_FK") public int getMinorStageConfigIdFK() { return(this.minorStageConfigIdFK); } public void setMinorStageConfigIdFK(final int minorStageConfigIdFK_) { this.minorStageConfigIdFK = minorStageConfigIdFK_; } // rest of code}
Code:@Entity @Table(name="Minor_Stage_Configuration") public class MinorStageConfig implements Serializable { private List<Agent> agentList; private int id; private int minorStageIdFK; @OneToMany(mappedBy="minorStageConfigIdFK", targetEntity=Agent.class) public List<Agent> getAgentList() { return(this.agentList); } public void setAgentList(final List<Agent> agentList_) { this.agentList = agentList_; } @Id @GeneratedValue(strategy=GenerationType.AUTO) @NotNull @Column(name="FDS_Minor_Stage_Configuration_ID") public int getId() { return(this.id); } public void setId(final int id_) { this.id = id_; } // rest of code}


Reply With Quote