在为交付的图表进行正确映射时,我遇到了一些大问题。它看起来像这样:
现在,到目前为止,我这样做了,希望它没问题(省略 getter/setter)。你会注意到USERS
has 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 破坏了一切。