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;
  |    }

and do not define the column in the emp EJB, but leave the container to infer 
it through the naming convention:

   @javax.persistence.Id @javax.persistence.GeneratedValue(strategy = 
javax.persistence.GenerationType.AUTO)
  |    public int getEmpId() {
  |       return empId;
  |    }
  | 

I get the exception:

org.hibernate.exception.SQLGrammarException: could not load an entity: 
[tv.probability.referenceimplementation.dto.DeptDTOImpl#19]

and the SQL:
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'"

This looks like a bug, but maybe I have misunderstood the inference of column 
names

Pete

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3921720#3921720

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3921720


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to