小编Sky*_*nzz的帖子

Spring boot 无法计算表达式方法抛出 'org.hibernate.LazyInitializationException' 异常。使用 getter、ManyToMany 关系

我有两个类ParticipantTimeWindow。多个参与者可以注册多个 TimeWindow,因此存在 ManyToMany 关系

@Entity
@Table
public class Participant {
    @Id
    @SequenceGenerator(
            name = "participant_sequence",
            sequenceName = "particant_sequence",
            allocationSize = 1
    )
    @GeneratedValue(
            strategy = GenerationType.SEQUENCE,
            generator = "participant_sequence"
    )
    private Long id;
    private String name;
    private String number;
    private String details;

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "ParticipantCreneaux")
    private Collection<TimeWindow> registeredTimeWindow;


    public Participant() {

    }
    public Participant(String nom, String num, String details) {
        this.name = nom;
        this.number = num;
        this.details = details;
        this.registeredTimeWindow = new ArrayList<>(); …
Run Code Online (Sandbox Code Playgroud)

java spring hibernate jpa spring-boot

15
推荐指数
2
解决办法
4万
查看次数

标签 统计

hibernate ×1

java ×1

jpa ×1

spring ×1

spring-boot ×1