納品されたダイアグラムの適切なマッピングを作成する際に、いくつかの大きな問題があります。次のようになります。
さて、これまでのところ、うまくいけば問題ありません(ゲッター/セッターは省略されています)。完全な図ではないので無視してUSERS
ください。DOMAIN_ID
機能グループ
@Entity
@Table(name = "FUNCTIONALITY_GROUP")
public class FunctionalityGroup implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "FUNCTIONALITY_GROUP_ID")
private Long functionalityGroupId;
@Column(name = "FUNCTIONALITY_GROUP_NM")
private String functionalityGroupName;
@Column(name = "FUNCTIONALITY_GROUP_DESC")
private String functionalityGroupDesc;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "funcionalityGroupId")
private List<Functionality> functionalityList;
}
機能性
@Entity
@Table(name = "FUNCTIONALITY")
public class Functionality implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "FUNCTIONALITY_ID")
private Long functionalityId;
@Column(name = "FUNCTIONALITY_NM")
private String functionalityGroupName;
@Column(name = "FUNCTIONALITY_DESC")
private String functionalityGroupDesc;
@Column(name = "FUNCTIONALITY_GROUP_ID")
private Long funcionalityGroupId;
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "ROLE_FUNCTIONALITY",
joinColumns = {@JoinColumn(name = "FUNCTIONALITY_ID")},
inverseJoinColumns = {@JoinColumn(name = "ROLE_ID")})
private List<Role> roleList;
}
役割
@Entity
@Table(name = "ROLE")
public class Role implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ROLE_ID")
private Integer roleId;
@Column(name = "ROLE_NM")
private String roleName;
@Column(name = "ROLE_DESC")
private String roleDesc;
@Column(name = "OBJECT_TYPE")
private String objectType;
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "roleList")
private List<Functionality> functionalityListy;
}
ユーザー
@Entity
@Table(name = "USERS")
public class Users implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "USER_ID")
private Long userId;
@Column(name = "USER_DESC")
private String userDesc;
@Column(name = "FIRST_NM")
private String firstNM;
@Column(name = "LAST_NM")
private String lastNM;
@Column(name = "IS_ENABLED")
private String isEnabled;
}
Role_Member と Role_Member_Entry をオブジェクトの世界でどのようにマップして処理する必要があるのか わかりません。ありがとう!
通常、ユーザーを多対多のロールで接続しますが、エンティティ Role_Member_Entry がすべてを台無しにします。