简体   繁体   English

org.hibernate.LazyInitializationException:无法延迟初始化role:ticketCircuitInfo的集合,无法初始化代理-没有会话

[英]org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role:ticketCircuitInfo, could not initialize proxy - no Session

I have 2 bean classes( ticketEntity , ticketCircuitInfo ) mapped to 1 table each 我有2个bean类( ticketEntityticketCircuitInfo )分别映射到1个表

I also have 1 ticketEntity(primary key) that can have multiple ticketCircuitInfo(forign key) 我也有1个ticketEntity(primary key) ,可以有多个ticketCircuitInfo(forign key)

The ticketEntity bean has the following properties: ticketEntity bean具有以下属性:

@Id
@Column(name = "ticket_id", unique = true, nullable = false)
private String ticketId;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "ticket", cascade      =CascadeType.ALL)
private Set<TicketCircuitInfo> ticketCircuitInfo;

The ticketCircuitInfo bean has the following properties: ticketCircuitInfo bean具有以下属性:

@GenericGenerator(name = "generator", strategy = "foreign",
parameters = @Parameter(name = "property", value = "ticket"))
@Id
@Column(name = "ticket_id", unique = true, nullable = false)
private String ticketId;
@ManyToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
private TicketEntity ticket;`

I'm getting: 我越来越:

com.sun.jdi.InvocationException occurred invoking method. com.sun.jdi.InvocationException发生了调用方法。

While debugging on the line ticket.ticketCircuitInfo() . 在行上进行调试ticket.ticketCircuitInfo()

further exception being printed is: 正在打印的另一个例外是:

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role:ticketCircuitInfo, could not initialize proxy - no Session org.hibernate.LazyInitializationException:无法延迟初始化role:ticketCircuitInfo的集合,无法初始化代理-没有会话

You should look into your service layer and add @Transactional to the service layer method.. 您应该查看服务层,并将@Transactional添加到服务层方法。

Please refer to : How to solve the “failed to lazily initialize a collection of role” Hibernate exception 请参考: 如何解决“无法延迟初始化角色集合”的Hibernate异常

You can change from 您可以从

@ManyToOne(fetch = FetchType.LAZY)

to

@ManyToOne(fetch = FetchType.EAGER)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Dropwizard org.hibernate.LazyInitializationException:无法延迟初始化集合无法初始化代理-没有会话 - Dropwizard org.hibernate.LazyInitializationException: failed to lazily initialize a collection could not initialize proxy - no Session Hibernate org.hibernate.LazyInitializationException:懒得初始化角色集合: - Hibernate org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.hibernate.LazyInitializationException:懒得初始化角色集合 - org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role 引起原因:org.hibernate.LazyInitializationException:无法延迟初始化角色集合: - Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: Hibernate:LazyInitializationException:懒得初始化一个角色集合。 无法初始化代理 - 没有会话 - Hibernate: LazyInitializationException: failed to lazily initialize a collection of role. Could not initialize proxy - no Session org.hibernate.LazyInitializationException:无法在另一个环境中延迟初始化角色集合 - org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role in another environment org.hibernate.LazyInitializationException:在Spring Security中登录期间无法延迟初始化角色集合 - org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role during login in spring security org.hibernate.LazyInitializationException: 使用 Javers 时无法延迟初始化角色集合 - org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role while using Javers org.hibernate.LazyInitializationException:未能延迟初始化角色集合:studentsystem2.ikubinfo.entity.Student.classes - org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: studentsystem2.ikubinfo.entity.Student.classes Hibernate 无法延迟初始化角色集合 无法初始化代理 - 没有 Session - Hibernate failed to lazily initialize a collection of role could not initialize proxy - no Session
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM