• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Composite key in hibernate 3

 
aman thind
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have 2 tables Employee and Department. They are connected via a third table Emp_Dept in which employee_Id and department_Id are foreign keys.In hibernate i am managing it through 4 entities.
EmpDeptPK has 2 fields Employee and Department and is an embeddable class.

EmpDept has one field EmpDeptPK as @EmbeddedId.

Employee entity is having
@OneToMany(fetch = FetchType.LAZY)
private Set<EmpDeptc> empDepts = new HashSet<EmpDept>(0);

Now i need to retrieve Employees and their departments if any.
This is my query:
select emp from Employee as emp where emp.employeeName = "abc";

And it is throwing SQLQuery exception saying table employee.employee_employee_Id does not exist.
I think problem is with my mapping. I am using hibernate 3. Any help will be appreciated.

Thanks
 
aman thind
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found the solution. If anybody wants solution, please message me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic