I am working on an existing domain model and using Hibernate Annotations. I have problem mapping an entity and need some help/inputs/ideas/suggestions.
Here is the scenario, I have 4 tables: 1) Oraganization (Org_id(primary key), Org_num, Org_name, etc...) 2) Office (Off_id (primary key), Org_id, Off_name, etc...) 3) Service (Svc_id (primary key), Svc_desc) 4) Office_Service (Off_id, Svc_id)
The issue is with mapping the SERVICES attribute in Organization entity. In my Organization entity I want list of service and my services are not directly linked to Organization. I have to write a custom SQL query to get the list, but I am not sure how to map. My Organization entity is some thing like this
@Entity @Table(name = "Oraganizations") public class EmploymentNetwork implements Serializable {
@Id @Column(name = "Org_id") private String orgId;
@Column(name = "Org_num") private String orgNumber;
@OneToMany //???? private List<Service> services; }
I can't use JOINS, NAMEDNATIVEQUERY or....
Hope there is a way to map the scenario, looking forward for suggestions and ideas.
|