I am using Embedded EJB to unit test my Entity Beans. I have 2 tables dept and emp, dept having a one-to-many association wuth emp.
if I define the association:
@javax.persistence.OneToMany(cascade = javax.persistence.CascadeType.ALL, fetch = javax.persistence.FetchType.EAGER) @javax.persistence.JoinColumn(name = "dept_id") public java.util.Collection<tv.probability.referenceimplementation.dto.EmpDTOImpl> getEmps() { return emps; }
@javax.persistence.Id @javax.persistence.GeneratedValue(strategy = javax.persistence.GenerationType.AUTO) public int getEmpId() { return empId; }
org.hibernate.exception.SQLGrammarException: could not load an entity: [tv.probability.referenceimplementation.dto.DeptDTOImpl#19]
Hibernate: select deptdtoimp0_.dept_id as dept1_0_1_, deptdtoimp0_.dept_name as dept2_0_1_, emps1_.dept_id as dept3_3_, emps1_.empId as empId3_, emps1_.empId as empId1_0_, emps1_.emp_name as emp2_1_0_ from dept deptdtoimp0_ left outer join emp emps1_ on deptdtoimp0_.dept_id=emps1_.dept_id where deptdtoimp0_.dept_id=? WARN 05-02 11:33:42,067 (JDBCExceptionReporter.java:logExceptions:71) -SQL Error: 1054, SQLState: 42S22 ERROR 05-02 11:33:42,070 (JDBCExceptionReporter.java:logExceptions:72) -null, message from server: "Unknown column 'emps1_.empId' in 'field list'"
It should work fine, but there is not enough information to see the issue.