-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Query for Many-to-Many Mapping
PostPosted: Sun Oct 07, 2012 6:55 am 
Newbie

Joined: Sun Oct 07, 2012 6:36 am
Posts: 3
I am dealing with a scenario with a Many-to-Many mapping which is just like the example in Employee to Project through a Join table (ProjectAssociation) with other data in join table. This example is being mentioned so many times. This works fine for me. But I want to retrieve a List of Employees that are allocated to a given Project whom also belong to a given department. The department is a field in the Employee class. When I retrieve the list of Employess, i want them populated with the ProjectAssociations list as well since I can get the project information of employees of that particular department. Following are the entities. They are not complete. I want to just show how my Employee class is.

@Entity
public class Employee
{
private Long Id;

private Department department;

private List<ProjectAssocation> projects;
}
-------------------------------------------------------------------
private class Department
{
private Long id;

private String name;
}
------------------------------------------------------------------
@Entity
@IdClass(ProjectAssociationId.class)
public class ProjectAssociation
{
@Id
private Long employeeId;

@Id
private Long projectId;

@ManyToOne
@PrimaryKeyJoinColumn....
private Employee employee;

@ManyToOne(mappedBy="...")
private Project project;
}
------------------------------------------------------------------
public class Project
{
private Long id;

private String projectName;

private List<ProjectAssociation> employees;
}
------------------------------------------------------------------
Can someone please tell me the query to get the List of Employees belonging to a specific department (say Engineering) who have been allocated to Project(say Hibernate)


Top
 Profile  
 
 Post subject: Re: Query for Many-to-Many Mapping
PostPosted: Sun Oct 07, 2012 10:14 pm 
Newbie

Joined: Sun Oct 07, 2012 6:36 am
Posts: 3
I just realized that i have by mistake written to the wrong forum. It has mistakenly gone to the tools forum.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.