User Table
UserName pk fname lname
GroupMaster
GroupName pk UserName pk, fk
I want to insert data in GroupMaster but my problem is it has composite primary key
How can I insert data in table through entity manager object?
User Table
UserName pk fname lname
GroupMaster
GroupName pk UserName pk, fk
I want to insert data in GroupMaster but my problem is it has composite primary key
How can I insert data in table through entity manager object?
This can be done with the @Embeddable
annotation. Set up a new class that contains the values of the primary key -- in this case, a class with GroupName
and UserName
fields, annotate the class with @Embeddable
, then store an instance inside the @Entity
that requires the primary key.
Take a look at the following example: