'Foreign key is not saving in @OneToMany relation

public class ReadLesson {        
    private int index;     

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "read_lesson_id")
    private LessonIntrod introduction;

    @OneToMany(mappedBy = "readlesson", cascade = CascadeType.ALL)
    private List<LesImage> images;

//getter n setters

}

public class LesImage {

    @Column(name = "imageid")
    private int imageid;

    @Column(name = "image")
    private String image;

    @ManyToOne
    @JoinColumn(name = "readlesson_id", nullable = false)
    private ReadLesson readlesson;

}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source