I have these two entities
@Entity
@Table(name = "CallSession")
public class CallSession implements Serializable {
private long id;
private List<CallParticipant> members;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@OneToMany(mappedBy = "callSession", fetch = FetchType.LAZY)
public List<CallParticipant> getMembers() {
return members;
}
public void setMembers(List<CallParticipant> members) {
this.members = members;
}
}
@Entity
@Table(name = "CallParticipant")
public class CallParticipant implements Serializable {
private long id;
private CallSession callSession;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@ManyToOne
public CallSession getCallSession() {
return callSession;
}
public void setCallSession(CallSession callSession) {
this.callSession = callSession;
}
}
but when I invoke callSession.getMembers() method,
I get this Exception:
Unable to evaluate the expression Method threw 'org.hibernate.LazyInitializationException' exception.
I cannot make a head or tail of why I get this error? Why do I get this error and how can I fix this?