Hi,
You need to give more details, for example the full stack trace and
where is running your client.
Also, if you don't need lazy initialization, you should use EAGER.
Regards,
Florent
gembin wrote:
> hi all,
> i have some problem with Lazy Loading with hibernate
>
> public class UserEntity{
>
> @ManyToMany
> @JoinTable(name="USER_ROLE",
> joinColumns=
> @JoinColumn(name="UR_USER_ID",
> referencedColumnName="USER_ID"),
> inverseJoinColumns=
> @JoinColumn(name="UR_ROLE_ID",
> referencedColumnName="ROLE_ID"))
> private Collection<RoleEntity> roles=Collections.EMPTY_LIST;
> public Collection<RoleEntity> getRoles() {
> return roles;
> }
> public void setRoles(Collection<RoleEntity> roles) {
> this.roles = roles;
> }
> }
>
> userEntity=IUserPersistenceService.findUser(1);
> when i use userEntity.getRoles(); i got exception:
>
> Exception in thread "main" org.hibernate.LazyInitializationException: failed
> to lazily initialize a collection of role:
> org.example.entity.UserEntity.roles, no session or session was closed
>
>
> how to solve this problem?
>