Java &引用@其中;及;级联=级联类型。全部;不同时工作
我有一个JPA实体(产品实体),它使用下面的Java &引用@其中;及;级联=级联类型。全部;不同时工作,java,spring-boot,jpa,Java,Spring Boot,Jpa,我有一个JPA实体(产品实体),它使用下面的@Where注释,同时,我使用cascade=CascadeType.ALL。(产品是父实体,存储是子实体) @OneToMany(cascade=CascadeType.ALL,mappedBy=“productid”) @不变的 @其中(子句=“isprimary='true'”) 私有列表存储列表; 当我想删除产品(父)实体时,会出现问题。由于“Product”实体与“Storage”实体有关系,并且我使用的是带有条件“isprimary=tr
@Where
注释,同时,我使用cascade=CascadeType.ALL
。(产品
是父实体,存储
是子实体)
@OneToMany(cascade=CascadeType.ALL,mappedBy=“productid”)
@不变的
@其中(子句=“isprimary='true'”)
私有列表存储列表;
当我想删除产品
(父)实体时,会出现问题。由于“Product
”实体与“Storage”实体有关系,并且我使用的是带有条件“isprimary=true”的“Where”注释,因此它不会删除isprimary=false的“Storage
”实体。
任何关于如何解决问题的建议。
我的要求是,如何删除所有存储(子)实体(无论has isprimary是真是假),同时,我还可以使用@Where anotation 可以添加第二个列表和其他条目:
@OneToMany(cascade = CascadeType.ALL, mappedBy = "productid")
@Immutable
@Where(clause = "isprimary='true'")
private List<Storage> storageList;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "productid")
@Immutable
@Where(clause = "isprimary='false'")
private List<Storage> storageListNotPrimary;
@OneToMany(cascade=CascadeType.ALL,mappedBy=“productid”)
@不变的
@其中(子句=“isprimary='true'”)
私有列表存储列表;
@OneToMany(cascade=CascadeType.ALL,mappedBy=“productid”)
@不变的
@其中(子句=“isprimary='false'”)
私有列表storageListNotPrimary;
可能会添加第二个列表和其他条目:
@OneToMany(cascade = CascadeType.ALL, mappedBy = "productid")
@Immutable
@Where(clause = "isprimary='true'")
private List<Storage> storageList;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "productid")
@Immutable
@Where(clause = "isprimary='false'")
private List<Storage> storageListNotPrimary;
@OneToMany(cascade=CascadeType.ALL,mappedBy=“productid”)
@不变的
@其中(子句=“isprimary='true'”)
私有列表存储列表;
@OneToMany(cascade=CascadeType.ALL,mappedBy=“productid”)
@不变的
@其中(子句=“isprimary='false'”)
私有列表storageListNotPrimary;