error hibernate failed to lazily initialize a collection of role | java php laravel linux mysql sql bootstrap html css query java php laravel linux mysql sql bootstrap html css query: error hibernate failed to lazily initialize a collection of role

Tuesday, November 20, 2012

error hibernate failed to lazily initialize a collection of role

failed to lazily initialize a collection of role: com.ipi.bean.Dologs.DtldologsSet, no session or session was closed

q> Waw error ketika nambahin @OneToMany pada header Dologs

q> @ManyToOne
[sourcecode language="java"]
@JoinColumn(name="DTL_NO_DOLOG", referencedColumnName="HDR_NO_DOLOG", insertable = false, updatable = false)
@ManyToOne(cascade=CascadeType.ALL)
private Dologs dologs;
[/sourcecode]

q> Sebelumnya

[sourcecode language="java"]
@OneToMany(mappedBy="dologs")
private Set<TrioH100Dtldologs> dtlDologsSet;
[/sourcecode]

q> Sesudah ditambahin fetch=FetchType.EAGER , error menghilang

[sourcecode language="java"]
@OneToMany(fetch=FetchType.EAGER,mappedBy="dologs")
private Set<TrioH100Dtldologs> dtlDologsSet;
[/sourcecode]

2 comments:

  1. kalau mau pake lazy tinggal tambahin
    @Fetch(FetchMode.JOIN)

    ReplyDelete

saifiahmada.com adalah blog belajar programming Indonesia, membahas lengkap materi bahasa pemrograman: code HTML, CSS, Bootstrap, Desain, PHP, MySQL, coding Java, Query, SQL, dan dunia linux