我有这两个实体:
@Entity
@Table(name = "commande")
public class Commande implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "name")
private String name;
@OneToMany(mappedBy = "commande")
@JsonIgnore
private Set<Piece> pieces = new HashSet<>();
@Entity
@Table(name = "piece")
public class Piece implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "ref")
private String ref;
@ManyToOne
private Commande commande;
当我加载实体Commande时,如果有与此命令相关联的部分,我希望其属性部分不为空。 我怎样才能做到这一点?
谢谢。