aspose file tools
The moose likes Object Relational Mapping and the fly likes Composite key in hibernate 3 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Composite key in hibernate 3" Watch "Composite key in hibernate 3" New topic
Author

Composite key in hibernate 3

aman thind
Ranch Hand

Joined: Jun 29, 2007
Posts: 71
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
SCJP,SCWCD
JAVA utte mar JAVA,mit JAVA
aman thind
Ranch Hand

Joined: Jun 29, 2007
Posts: 71
Found the solution. If anybody wants solution, please message me.
 
 
subject: Composite key in hibernate 3
 
Threads others viewed
That's what I meant by tough EJB-QL
hibernate 1:M relationships & cascade
one to many mapping
Doubt in Mapping Associations
jsp:useBean type is not working?
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture