Could not write content: failed to lazily initialize a collection of role

后端 未结 9 1312
说谎
说谎 2021-02-08 02:48

I have One-To-Many relationship, here is my code

@Entity
@Table(name = \"catalog\")
public class Catalog {

    @Id
    @GeneratedValue(strategy = GenerationType         


        
9条回答
  •  孤独总比滥情好
    2021-02-08 03:32

    I had the same problem but a fixed by:

    @OneToMany
    @JoinColumn(name = "assigned_ingredient", referencedColumnName = "ingredient_id")
    @Fetch(FetchMode.JOIN) // Changing the fetch profile you can solve the problem
    @Where(clause = "active_ind = 'Y'")
    @OrderBy(clause = "meal_id ASC")
    private List ingredients;
    

    you can have more information here: https://vladmihalcea.com/the-best-way-to-handle-the-lazyinitializationexception/

提交回复
热议问题