Friday, September 19, 2014

Composite key in hibernate

@Embeddable
public class RolesMenu {
    @Column(name = "RoleID")
    private String roleID;

    @Column(name = "MenuItemID")
    private String menuItemID;

    //getter, setter methods
}

 @Entity
 @Table(name = "RolesMenuItems")
 public class RolesMenuItems {

     @EmbeddedId
     private RolesMenu roleMenu;

  /*setter getter methods */
 }

No comments: