我有以下实体:
public class **Product** implements Serializable {
@Id
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "Id_Gen")
private Long id;
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
@Fetch(value=FetchMode.JOIN)
@JoinColumn(name = "PRODUCT_DETAILS_TABLE")
private ProductJsonDetails productJsonDetails;
}
@Table(name = "PRODUCT_DETAILS_TABLE")
public class **ProductJsonDetails** implements Serializable {
@Id
@Access(AccessType.PROPERTY)
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "Id_Gen")
private Long id;
@JsonIgnore
@OneToOne(fetch = FetchType.LAZY, mappedBy = "productJsonDetails")
private Product product;
@JsonIgnore
@Column(name = "**XYZ_JSON**")
private String **detailsJson**;
}
}
列 XyZ_JSON 包含以下格式的字符串
{“name”:“ABC”,“type”:{“id”:“LMN”,输入:“CCC”}}
我想设置如下标准:
DetachedCriteria criteria = DetachedCriteria.forClass(Product.class,“product”);
criteria.createAlias("product.productJsonDetails", "productJsonDetails", JoinType.LEFT_OUTER_JOIN);
critera.add(Restrictions.eq(“productJsonDetails.type.id”,“1”)) - >>>这会引发错误。
如何设置对字符串json ???
的Id元素的限制