【发布时间】:2018-04-21 07:28:49
【问题描述】:
我有一个 notificationTypes 表,权限表。这些是通过桥接表 notification_types_permission 链接的。 当所有实体都是新的时,它工作正常。 我的问题是,当我尝试使用现有权限插入新的通知类型时,该时间权限也尝试插入新的。 我的表和实体结构如下所示。
CREATE TABLE `notification_types` (
`Id` BIGINT(16) NOT NULL AUTO_INCREMENT,
`TypeName` VARCHAR(80) NOT NULL,
`InsertedDttm` DATETIME NULL,
`InsertedBy` BIGINT(16) NULL,
`UpdatedDttm` DATETIME NULL,
`UpdatedBy` BIGINT(16) NULL,
PRIMARY KEY (`Id`));
CREATE TABLE `notification_types_permission` (
`Id` BIGINT(16) NOT NULL AUTO_INCREMENT,
`NotificationTypes_ID` BIGINT(16) NOT NULL,
`permissions_ID` int(11) NOT NULL,
PRIMARY KEY (`Id`), FOREIGN KEY (NotificationTypes_ID)
REFERENCES `frontoffice`.notification_types(id), FOREIGN KEY (permission_Id)
REFERENCES `frontoffice`.`permission`(id));
public class NotificationTypes {
@Id
private Long id;
private String typeName;
@Temporal(TemporalType.TIMESTAMP)
private Date insertedDttm;
private Long insertedBy;
@Temporal(TemporalType.TIMESTAMP)
private Date updatedDttm;
private Long updatedBy;
@OneToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
private List<RLPermissions> permissions;
}
【问题讨论】:
标签: java mysql hibernate jpa persistence