|
|
Re: Persistence.getPersistenceUtil [message #827664 is a reply to message #827558] |
Fri, 23 March 2012 16:20 |
Mitesh Pandey Messages: 7 Registered: March 2012 |
Junior Member |
|
|
Hi Chris,
Yes indeed, I was using javax.persistence_1. So after putting javax_persistence_2 , i have accessed to Persistence.getPersistenceUtil(). Thanks a lot.
For problem no 2, my exact requirement is as below
@entity
public class company
{
@Id
private int companyId
private String companyName;
@onetoMany
private list<employee> employee;
@onetoMany
private List<SubsidaryCompany> subsidaryCompany;
@onetoMany
private List<Department> department;
@onetoMany
private List<LawFirm> lawFirmHired;
}
@entity
public class employee
{
}
@entity
pubic class SubsidaryCompany
{
}
@entity
public class Department
{
}
@entity
public class LawFirm
{
}
Below is the sample data for example
Company
--------------------------
companyId companyName
1 walmart
2 tesco
Employee
-----------------------------------
EmployeeId EmployeeName companyId
1 Bob 1
2 Chan 1
SubsidaryCompany
------------------------------
SubCompanyId CompanyId
1 1
2 1
Department
---------------------------
DepartmentId CompanyId
1 1
2 1
LawFirm
----------------------
LawFirmId CompanyId
1 1
2 1
3 2
So for Walmart, it has two employee , 2 subsidary company, 2 department and 2 lawfirm and for tesco it has no employee, no subsidary, no department but 1 lawfirm hired
If i query company entity with companyId 2 (tesco), it will also load associated entity like employee, subsidaryCompany, department and lawfirm but except lawFirmHired all other attributes would be null.
So if I want to check what are the associated entities that are not empty or not null, I have to every attribute against null
In my actual scenario, an entity like company has more than 30 relationship.
I need a way to know what are the associated entities which are not null, rather than checking every attribute for null value
|
|
|
|
Powered by
FUDForum. Page generated in 0.02323 seconds