我有两个具有多对多关系的实体 CRImageType 和 CRVariable,如下所示:
CRImageType 实体:
@Entity
@Table(name = "imageviewer_crimagetype")
public class CRImageType implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
@Column(name = "ImTypeId")
private Long imTypeId;
@Column(name = "ImTypeName")
private String imTypeName;
@Column(name = "ImTypeDescription")
private String imTypeDescription;
@ManyToMany(cascade = {CascadeType.ALL})
@JoinTable(name="imageviewer_imtype_variable",
joinColumns={@JoinColumn(name="ImTypeId")},
inverseJoinColumns={@JoinColumn(name="VarId")})
private Set<CRVariable> crvariables = new HashSet<CRVariable>();
CRV 变量实体:
@Entity
@Table(name = "imageviewer_crvariable")
public class CRVariable implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
@Column(name = "VarId")
private Long varId;
@Column(name = "VarName")
private String varName;
@Column(name = "VarDescription")
private String varDescription;
@ManyToMany(mappedBy="crvariables")
private Set<CRImageType> crimagetypes = new HashSet<CRImageType>();
在我的数据库中,关系由两个表“imageviewer_crimagetype”和“imageviewer_crvariable”和第三个“imageviewer_imtype_variable”映射,用于它们的多对多关系。
我只想从表"imageviewer_imtype_variable"中删除关联记录。如何使用 HQL 查询来完成,因为我无法直接访问“imageviewer_imtype_variable 表。
我想要 SQL 查询的 HQL 等价物
delete from imageviewer_imtype_variable where ImTypeId='%%%'