I believe your intention is to use the Company Id as one of the properties to uniquely identify an employee.
In order to do that , you need to have an IdClass composite of the properties ( empid, companyid) that uniquely
identify the employee in a separate class; and Have a relationship with the Company entity in the
Employee entity and as well use it as @Id property. Something like ,
(Note : the above code might not be the exact code, but something in the same lines. refer to the below link for details)
Refer to JPA Composite Primary Keys, for detailed explanation.
Go through the JPA 2.0 examples in the above link
Joined: Jul 23, 2009
Thanks a lot sanjay and james.It works .thanks a lot for the link and suggestion.