【发布时间】:2019-02-18 08:37:34
【问题描述】:
我正在使用 spring-boot,并且我有一个实体类(A 类),其中包含来自不同类(B 类)的元素列表。
一般情况下,列表包含订单列表,并且没有时间戳。
我想将 A 类的对象保存到 MySql DB,同时保持列表的插入顺序。 这可能吗?
谢谢, 视频
@Entity
public class A {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToMany(targetEntity = B.class, fetch = FetchType.EAGER)
private List<B> orders;
}
@Entity
public class B {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String order;
}
【问题讨论】:
标签: hibernate spring-boot spring-jdbc