5 Replies Latest reply on Oct 19, 2010 4:31 AM by Leo van den berg

    LazyInitializationException issue

    csenes csenes Newbie

      when I use entitiyManager persist method, after InitializationException occur and I couldnt fix it , I tried to use example on internet for fixing like hibernateSessionRequestFilter, neither it didnt work for me, my fetchType is lazy and I dont want to change to eager for performance, is there anybody meet this thing and solve it ,I wait your response please help me

        • 1. Re: LazyInitializationException issue
          Leo van den berg Master

          Hi,


          Please send some code, because it is very difficult to help you without any background information.


          Leo

          • 2. Re: LazyInitializationException issue
            csenes csenes Newbie

            org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.domain.kaliteyonsist.entity.Users.yetkiliOlunanStandartlar, no session or session was closed



            this is an error message which I got and I am putting users entity class code 





            users entity



            package org.domain.kaliteyonsist.entity;

            // Generated 24.Mar.2009 17:38:00 by Hibernate Tools 3.2.2.GA

            import java.io.UnsupportedEncodingException;
            import java.security.NoSuchAlgorithmException;
            import java.util.ArrayList;
            import java.util.Date;
            import java.util.HashSet;
            import java.util.List;
            import java.util.Locale;
            import java.util.Set;

            import javax.persistence.CascadeType;
            import javax.persistence.Column;
            import javax.persistence.Entity;
            import javax.persistence.FetchType;
            import javax.persistence.GeneratedValue;
            import javax.persistence.GenerationType;
            import javax.persistence.Id;
            import javax.persistence.JoinColumn;
            import javax.persistence.JoinTable;
            import javax.persistence.ManyToMany;
            import javax.persistence.ManyToOne;
            import javax.persistence.OneToMany;
            import javax.persistence.OneToOne;
            import javax.persistence.OrderBy;
            import javax.persistence.Table;
            import javax.persistence.Temporal;
            import javax.persistence.TemporalType;

            import org.domain.kaliteyonsist.general.Crypto;
            import org.hibernate.annotations.Cascade;
            import org.hibernate.validator.Email;
            import org.hibernate.validator.Length;
            import org.hibernate.validator.NotNull;
            import org.jboss.seam.annotations.Name;
            import org.jboss.seam.annotations.security.management.UserPassword;
            import org.jboss.seam.annotations.security.management.UserPrincipal;
            import org.jboss.seam.annotations.security.management.UserRoles;

            /**
            * @author Onur
            */
            @Entity
            @Name("users")
            @Table(name = "OYS_USERS")
            public class Users extends AuditBase implements java.io.Serializable {

                    private static final long serialVersionUID = 1L;

                    @Id
                    @GeneratedValue(strategy = GenerationType.AUTO)
                    @Column(name = "T_ID", precision = 22, scale = 0)
                    @NotNull
                    private Long id;

                    @ManyToOne(fetch = FetchType.LAZY)
                    @JoinColumn(name = "T_DEPARTMAN")
                    private Departman departman;

                    @ManyToMany(fetch = FetchType.LAZY)
                    @JoinTable(name = "USER_TO_DEPARTMAN", joinColumns = { @JoinColumn(name = "T_USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "T_DEPARTMAN_ID") })
                    @OrderBy("ad ASC")
                    private List<Departman> vekilDepartmanList = new ArrayList<Departman>(0);
                   
                    @ManyToMany(fetch = FetchType.LAZY)
                    @JoinTable(name = "AYS_ANKET_TO_USER", joinColumns = { @JoinColumn(name = "T_USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "T_ANKETISLEMI_ID") })
                    private List<AnketIslemi> anketler;

                    @ManyToMany(fetch = FetchType.LAZY)
                    @JoinTable(name = "EYS_EGITIM_TO_KATILIMCI", joinColumns = { @JoinColumn(name = "T_KATILIMCI_ID") }, inverseJoinColumns = { @JoinColumn(name = "T_EGITIM_ID") })
                    private List<Egitim> egitimList = new ArrayList<Egitim>(0);

                    @ManyToMany(fetch = FetchType.LAZY)
                    @JoinTable(name = "DYS_USERS_TO_STANDART", joinColumns = { @JoinColumn(name = "T_USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "T_STANDART_ID") })
                    private List<Standart> yetkiliOlunanStandartlar = new ArrayList<Standart>(0);

                    @ManyToOne(fetch = FetchType.LAZY)
                    @JoinColumn(name = "T_MESLEK")
                    private Meslek meslek;

                    @ManyToOne(fetch = FetchType.LAZY)
                    @JoinColumn(name = "T_UNVAN")
                    private Unvan unvan;

                    @ManyToOne(fetch = FetchType.LAZY)
                    @JoinColumn(name = "T_CV")
                    private Cv cv;

                    @ManyToOne(fetch = FetchType.LAZY)
                    @JoinColumn(name = "T_PHOTO")
                    private UserPhoto userPhoto;

                    @Column(name = "T_AD", length = 50)
                    @Length(max = 50)
                    private String ad;

                    @Column(name = "T_SOYAD", length = 50)
                    @Length(max = 50)
                    private String soyad;

                    @UserPassword(hash = "md5")
                    @Column(name = "T_PAROLA", length = 250)
                    @Length(max = 250)
                    private String parola;

                    @UserPrincipal
                    @Column(name = "T_EMAIL", length = 250, unique = true)
                    @Length(max = 250)
                    @Email
                    private String mail;
                    @Column(name = "T_KULLANICI_KODU", length = 20, unique = true)
                    @Length(max = 20)
                    private String kullaniciKodu;

                    @Column(name = "T_OGRENIMDURUMU", length = 250)
                    @Length(max = 250)
                    private String ogrenimDurumu;

                    @Column(name = "T_ASKERLIKDURUMU", length = 250)
                    @Length(max = 250)
                    private String askerlikDurumu;

                    @Column(name = "T_CINSIYET", precision = 1, scale = 0)
                    private Boolean cinsiyet;

                    @Column(name = "T_YABANCIDIL1")
                    private String yabanciDil1;

                    @Column(name = "T_YABANCIDIL2")
                    private String yabanciDil2;

                    @Column(name = "T_YABANCIDIL3")
                    private String yabanciDil3;

                    @Temporal(TemporalType.TIMESTAMP)
                    @Column(name = "T_GIRISTARIHI", length = 7)
                    private Date girisTarihi;

                    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Dokuman.class, mappedBy = "kontrol")
                    @OrderBy("baslik ASC")
                    private Set<Dokuman> kontrolDokumans = new HashSet<Dokuman>(0);

                    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Dokuman.class, mappedBy = "onaylayan")
                    @OrderBy("baslik ASC")
                    private Set<Dokuman> onaylayanDokumans = new HashSet<Dokuman>(0);

                    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Dokuman.class, mappedBy = "hazirlayan")
                    @OrderBy("baslik ASC")
                    private Set<Dokuman> hazirlayanDokumans = new HashSet<Dokuman>(0);

                    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Message.class, mappedBy = "alan")
                    @Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
                    private Set<Message> gelenMessages = new HashSet<Message>(0);

                    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Oneri.class, mappedBy = "istekYapanKullanici")
                    @OrderBy("acilisTarihi ASC")
                    private Set<Oneri> oneriList = new HashSet<Oneri>(0);

                    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = MTSikayetleri.class, mappedBy = "istekYapanKullanici")
                    @OrderBy("acilisTarihi ASC")
                    private Set<MTSikayetleri> mTSikayetleriList = new HashSet<MTSikayetleri>(0);

                    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Dof.class, mappedBy = "istekYapanKullanici")
                    @OrderBy("acilisTarihi ASC")
                    private Set<Dof> dofList = new HashSet<Dof>(0);
                    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Oneri.class, mappedBy = "istemiBaslatanKullanici")
                    @OrderBy("acilisTarihi ASC")
                    private Set<Oneri> istemiBaslatilanOnerilerList = new HashSet<Oneri>(0);

                    @OneToOne(mappedBy = "tetkikci", cascade = { CascadeType.MERGE,
                                    CascadeType.REFRESH })
                    private Tetkikci tetkik;

                    @OneToOne(fetch = FetchType.LAZY, mappedBy = "user")
                    private OneriUser oneriUser;

                    @OneToOne(fetch = FetchType.LAZY, mappedBy = "user")
                    private MTSikayetleriUser mTSikayetleriUser;

                    @OneToOne(fetch = FetchType.LAZY, mappedBy = "user")
                    private DofUser dofUser;

                    @ManyToMany(fetch = FetchType.LAZY)
                    @JoinTable(name = "TYS_TOPLANTI_TO_OYS_USER", joinColumns = { @JoinColumn(name = "T_USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "T_TOPLANTI_ID") })
                    @OrderBy("toplantiTarihi ASC")
                    private List<Toplanti> toplantilar;

                    @UserRoles
                    @ManyToMany(fetch = FetchType.LAZY)
                    @JoinTable(name = "KYS_USER_TO_ROL", joinColumns = { @JoinColumn(name = "T_USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "T_ROL_ID") })
                    private List<Rol> roller = new ArrayList<Rol>(0);

                    @Column(name = "T_AKTIF", precision = 1, scale = 0)
                    private Boolean aktif = true;

                    public Users() {
                    }

                    public Users(Long id, Meslek meslek, Departman departman) {
                            this.id = id;
                            this.meslek = meslek;
                            this.departman = departman;
                    }

                    public Users(Long id, Meslek meslek, Departman departman, String ad,
                                    String soyad, String parola, String mail) {
                            this.id = id;
                            this.meslek = meslek;
                            this.departman = departman;
                            this.ad = ad;
                            this.soyad = soyad;
                            this.parola = parola;
                            this.mail = mail;
                    }

                    public Users(Long id, Meslek meslek, Departman departman,
                                    List<Departman> departmanList, String ad, String soyad,
                                    String parola, String mail) {
                            this.id = id;
                            this.meslek = meslek;
                            this.departman = departman;
                            this.ad = ad;
                            this.soyad = soyad;
                            this.parola = parola;
                            this.mail = mail;
                            this.vekilDepartmanList = new ArrayList<Departman>(departmanList);
                    }

                    public Users(Users user) {
                            this.id = user.id;
                            this.meslek = user.meslek;
                            this.departman = user.departman;
                            this.vekilDepartmanList = new ArrayList<Departman>(user
                                            .getVekilDepartmanList());
                            this.ad = user.ad;
                            this.soyad = user.soyad;
                            this.parola = user.parola;
                            this.mail = user.mail;
                            this.kullaniciKodu = user.kullaniciKodu;
                            this.askerlikDurumu = user.askerlikDurumu;
                            this.cinsiyet = user.cinsiyet;
                            this.girisTarihi = user.girisTarihi;
                            this.ogrenimDurumu = user.ogrenimDurumu;
                            this.unvan = user.unvan;
                            this.userPhoto = user.userPhoto;
                            this.yabanciDil1 = user.yabanciDil1;
                            this.yabanciDil2 = user.yabanciDil2;
                            this.yabanciDil3 = user.yabanciDil3;
                            this.cv = user.cv;
                            this.gelenMessages = new HashSet<Message>(user.gelenMessages);
                            this.hazirlayanDokumans = new HashSet<Dokuman>(user.hazirlayanDokumans);
                            this.kontrolDokumans = new HashSet<Dokuman>(user.kontrolDokumans);
                            this.onaylayanDokumans = new HashSet<Dokuman>(user.onaylayanDokumans);
                            this.roller = new ArrayList<Rol>(user.roller);
                            this.toplantilar = new ArrayList<Toplanti>(user.toplantilar);

                    }

                    public Long getId() {
                            return this.id;
                    }

                    public void setId(Long id) {
                            this.id = id;
                    }

                    public Meslek getMeslek() {
                            return this.meslek;
                    }

                    public void setMeslek(Meslek meslek) {
                            this.meslek = meslek;
                    }

                    public Departman getDepartman() {
                            return this.departman;
                    }

                    public void setDepartman(Departman departman) {
                            this.departman = departman;
                    }

                    public String getAd() {
                            return this.ad;
                    }

                    public void setAd(String ad) {
                            this.ad = ad;
                    }

                    public String getSoyad() {
                            return this.soyad;
                    }

                    public void setSoyad(String soyad) {
                            this.soyad = soyad;
                    }

                    public String getParola() {
                            return this.parola;
                    }

                    public void setParola(String parola) {
                            try {
                                    this.parola = Crypto.SHA(parola);
                            } catch (NoSuchAlgorithmException e) {
                                    e.printStackTrace();
                            } catch (UnsupportedEncodingException e) {
                                    e.printStackTrace();
                            }
                    }

                    public String getMail() {
                            return mail;
                    }

                    public void setMail(String mail) {
                            this.mail = mail.toLowerCase(Locale.ENGLISH);
                    }

                    public Unvan getUnvan() {
                            return unvan;
                    }

                    public void setUnvan(Unvan unvan) {
                            this.unvan = unvan;
                    }

                    public UserPhoto getUserPhoto() {
                            return userPhoto;
                    }

                    public void setUserPhoto(UserPhoto userPhoto) {
                            this.userPhoto = userPhoto;
                    }

                    public Cv getCv() {
                            return cv;
                    }

                    public void setCv(Cv cv) {
                            this.cv = cv;
                    }

                    public String getOgrenimDurumu() {
                            return ogrenimDurumu;
                    }

                    public void setOgrenimDurumu(String ogrenimDurumu) {
                            this.ogrenimDurumu = ogrenimDurumu;
                    }

                    public String getAskerlikDurumu() {
                            return askerlikDurumu;
                    }

                    public void setAskerlikDurumu(String askerlikDurumu) {
                            this.askerlikDurumu = askerlikDurumu;
                    }

                    public Boolean getCinsiyet() {
                            return cinsiyet;
                    }

                    public void setCinsiyet(Boolean cinsiyet) {
                            this.cinsiyet = cinsiyet;
                    }

                    public String getYabanciDil1() {
                            return yabanciDil1;
                    }

                    public void setYabanciDil1(String yabanciDil1) {
                            this.yabanciDil1 = yabanciDil1;
                    }

                    public String getYabanciDil2() {
                            return yabanciDil2;
                    }

                    public void setYabanciDil2(String yabanciDil2) {
                            this.yabanciDil2 = yabanciDil2;
                    }

                    public String getYabanciDil3() {
                            return yabanciDil3;
                    }

                    public void setYabanciDil3(String yabanciDil3) {
                            this.yabanciDil3 = yabanciDil3;
                    }

                    public Date getGirisTarihi() {
                            return girisTarihi;
                    }

                    public void setGirisTarihi(Date girisTarihi) {
                            this.girisTarihi = girisTarihi;
                    }

                    public void cleanValues() {
                            this.ad = null;
                            this.askerlikDurumu = null;
                            this.cinsiyet = null;
                            this.cv = null;
                            this.departman = null;
                            this.girisTarihi = null;
                            this.setHazirlayanDokumans(new HashSet<Dokuman>(0));
                            this.id = null;
                            this.setKontrolDokumans(new HashSet<Dokuman>(0));
                            this.mail = null;
                            this.meslek = null;
                            this.ogrenimDurumu = null;
                            this.setOnaylayanDokumans(new HashSet<Dokuman>(0));
                            this.parola = null;
                            this.soyad = null;
                            this.unvan = null;
                            this.userPhoto = null;
                            this.yabanciDil1 = null;
                            this.yabanciDil2 = null;
                            this.yabanciDil3 = null;
                    }

                    @Override
                    public String toString() {
                            return "org.domain.kaliteyonsist.entity.users[id=" + id + "]";
                    }

                    public void setTetkik(Tetkikci tetkik) {
                            this.tetkik = tetkik;
                    }

                    public Tetkikci getTetkik() {
                            return tetkik;
                    }

                    public void setRoller(List<Rol> roller) {
                            this.roller = roller;
                    }

                    public List<Rol> getRoller() {
                            return roller;
                    }

                    public void setToplantilar(List<Toplanti> toplantilar) {
                            this.toplantilar = toplantilar;
                    }

                    public List<Toplanti> getToplantilar() {
                            return toplantilar;
                    }

                    public void setGelenMessages(Set<Message> gelenMessages) {
                            this.gelenMessages = gelenMessages;
                    }

                    public Set<Message> getGelenMessages() {
                            return gelenMessages;
                    }

                    public void setKontrolDokumans(Set<Dokuman> kontrolDokumans) {
                            this.kontrolDokumans = kontrolDokumans;
                    }

                    public Set<Dokuman> getKontrolDokumans() {
                            return kontrolDokumans;
                    }

                    public void setOnaylayanDokumans(Set<Dokuman> onaylayanDokumans) {
                            this.onaylayanDokumans = onaylayanDokumans;
                    }

                    public Set<Dokuman> getOnaylayanDokumans() {
                            return onaylayanDokumans;
                    }

                    public void setHazirlayanDokumans(Set<Dokuman> hazirlayanDokumans) {
                            this.hazirlayanDokumans = hazirlayanDokumans;
                    }

                    public Set<Dokuman> getHazirlayanDokumans() {
                            return hazirlayanDokumans;
                    }

                    public void setAktif(Boolean aktif) {
                            this.aktif = aktif;
                    }

                    public Boolean getAktif() {
                            return aktif;
                    }

                    public void setOneriUser(OneriUser oneriUser) {
                            this.oneriUser = oneriUser;
                    }

                    public OneriUser getOneriUser() {
                            return oneriUser;
                    }

                    public void setOneriList(Set<Oneri> oneriList) {
                            this.oneriList = oneriList;
                    }

                    public Set<Oneri> getOneriList() {
                            return oneriList;
                    }

                    public void setKullaniciKodu(String kullaniciKodu) {
                            this.kullaniciKodu = kullaniciKodu;
                    }

                    public String getKullaniciKodu() {
                            return kullaniciKodu;
                    }

                    public void setIstemiBaslatilanOnerilerList(
                                    Set<Oneri> istemiBaslatilanOnerilerList) {
                            this.istemiBaslatilanOnerilerList = istemiBaslatilanOnerilerList;
                    }

                    public Set<Oneri> getIstemiBaslatilanOnerilerList() {
                            return istemiBaslatilanOnerilerList;
                    }

                    public void setDofUser(DofUser dofUser) {
                            this.dofUser = dofUser;
                    }

                    public DofUser getDofUser() {
                            return dofUser;
                    }

                    public void setDofList(Set<Dof> dofList) {
                            this.dofList = dofList;
                    }

                    public Set<Dof> getDofList() {
                            return dofList;
                    }

                    public void setAnketler(List<AnketIslemi> anketler) {
                            this.anketler = anketler;
                    }

                    public List<AnketIslemi> getAnketler() {
                            return anketler;
                    }

                    public void setVekilDepartmanList(List<Departman> vekilDepartmanList) {
                            this.vekilDepartmanList = vekilDepartmanList;
                    }

                    public List<Departman> getVekilDepartmanList() {
                            return vekilDepartmanList;
                    }

                    public void setEgitimList(List<Egitim> egitimList) {
                            this.egitimList = egitimList;
                    }

                    public List<Egitim> getEgitimList() {
                            return egitimList;
                    }

                    public void setMTSikayetleriList(Set<MTSikayetleri> mTSikayetleriList) {
                            this.mTSikayetleriList = mTSikayetleriList;
                    }

                    public Set<MTSikayetleri> getMTSikayetleriList() {
                            return mTSikayetleriList;
                    }

                    public void setMTSikayetleriUser(MTSikayetleriUser mTSikayetleriUser) {
                            this.mTSikayetleriUser = mTSikayetleriUser;
                    }

                    public MTSikayetleriUser getMTSikayetleriUser() {
                            return mTSikayetleriUser;
                    }

                    public void setYetkiliOlunanStandartlar(
                                    List<Standart> yetkiliOlunanStandartlar) {
                            this.yetkiliOlunanStandartlar = yetkiliOlunanStandartlar;
                    }

                    public List<Standart> getYetkiliOlunanStandartlar() {
                            return yetkiliOlunanStandartlar;
                    }

            }


            • 3. Re: LazyInitializationException issue
              csenes csenes Newbie

              wtf ? I write again


              org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.domain.kaliteyonsist.entity.Users.yetkiliOlunanStandartlar, no session or session was closed


              this is an error message which I got and I am putting users entity class code




              users entity





              @Entity
              @Name("users")
              @Table(name = "OYS_USERS")
              public class Users extends AuditBase implements java.io.Serializable {
              
                   private static final long serialVersionUID = 1L;
              
                   @Id
                   @GeneratedValue(strategy = GenerationType.AUTO)
                   @Column(name = "T_ID", precision = 22, scale = 0)
                   @NotNull
                   private Long id;
              
                   @ManyToOne(fetch = FetchType.LAZY)
                   @JoinColumn(name = "T_DEPARTMAN")
                   private Departman departman;
              
                   @ManyToMany(fetch = FetchType.LAZY)
                   @JoinTable(name = "USER_TO_DEPARTMAN", joinColumns = { @JoinColumn(name = "T_USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "T_DEPARTMAN_ID") })
                   @OrderBy("ad ASC")
                   private List<Departman> vekilDepartmanList = new ArrayList<Departman>(0);
                   
                   @ManyToMany(fetch = FetchType.LAZY)
                   @JoinTable(name = "AYS_ANKET_TO_USER", joinColumns = { @JoinColumn(name = "T_USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "T_ANKETISLEMI_ID") })
                   private List<AnketIslemi> anketler;
              
                   @ManyToMany(fetch = FetchType.LAZY)
                   @JoinTable(name = "EYS_EGITIM_TO_KATILIMCI", joinColumns = { @JoinColumn(name = "T_KATILIMCI_ID") }, inverseJoinColumns = { @JoinColumn(name = "T_EGITIM_ID") })
                   private List<Egitim> egitimList = new ArrayList<Egitim>(0);
              
                   @ManyToMany(fetch = FetchType.LAZY)
                   @JoinTable(name = "DYS_USERS_TO_STANDART", joinColumns = { @JoinColumn(name = "T_USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "T_STANDART_ID") })
                   private List<Standart> yetkiliOlunanStandartlar = new ArrayList<Standart>(0);
              
                   @ManyToOne(fetch = FetchType.LAZY)
                   @JoinColumn(name = "T_MESLEK")
                   private Meslek meslek;
              
                   @ManyToOne(fetch = FetchType.LAZY)
                   @JoinColumn(name = "T_UNVAN")
                   private Unvan unvan;
              
                   @ManyToOne(fetch = FetchType.LAZY)
                   @JoinColumn(name = "T_CV")
                   private Cv cv;
              
                   @ManyToOne(fetch = FetchType.LAZY)
                   @JoinColumn(name = "T_PHOTO")
                   private UserPhoto userPhoto;
              
                   @Column(name = "T_AD", length = 50)
                   @Length(max = 50)
                   private String ad;
              
                   @Column(name = "T_SOYAD", length = 50)
                   @Length(max = 50)
                   private String soyad;
              
                   @UserPassword(hash = "md5")
                   @Column(name = "T_PAROLA", length = 250)
                   @Length(max = 250)
                   private String parola;
              
                   @UserPrincipal
                   @Column(name = "T_EMAIL", length = 250, unique = true)
                   @Length(max = 250)
                   @Email
                   private String mail;
                   @Column(name = "T_KULLANICI_KODU", length = 20, unique = true)
                   @Length(max = 20)
                   private String kullaniciKodu;
              
                   @Column(name = "T_OGRENIMDURUMU", length = 250)
                   @Length(max = 250)
                   private String ogrenimDurumu;
              
                   @Column(name = "T_ASKERLIKDURUMU", length = 250)
                   @Length(max = 250)
                   private String askerlikDurumu;
              
                   @Column(name = "T_CINSIYET", precision = 1, scale = 0)
                   private Boolean cinsiyet;
              
                   @Column(name = "T_YABANCIDIL1")
                   private String yabanciDil1;
              
                   @Column(name = "T_YABANCIDIL2")
                   private String yabanciDil2;
              
                   @Column(name = "T_YABANCIDIL3")
                   private String yabanciDil3;
              
                   @Temporal(TemporalType.TIMESTAMP)
                   @Column(name = "T_GIRISTARIHI", length = 7)
                   private Date girisTarihi;
              
                   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Dokuman.class, mappedBy = "kontrol")
                   @OrderBy("baslik ASC")
                   private Set<Dokuman> kontrolDokumans = new HashSet<Dokuman>(0);
              
                   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Dokuman.class, mappedBy = "onaylayan")
                   @OrderBy("baslik ASC")
                   private Set<Dokuman> onaylayanDokumans = new HashSet<Dokuman>(0);
              
                   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Dokuman.class, mappedBy = "hazirlayan")
                   @OrderBy("baslik ASC")
                   private Set<Dokuman> hazirlayanDokumans = new HashSet<Dokuman>(0);
              
                   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Message.class, mappedBy = "alan")
                   @Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
                   private Set<Message> gelenMessages = new HashSet<Message>(0);
              
                   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Oneri.class, mappedBy = "istekYapanKullanici")
                   @OrderBy("acilisTarihi ASC")
                   private Set<Oneri> oneriList = new HashSet<Oneri>(0);
              
                   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = MTSikayetleri.class, mappedBy = "istekYapanKullanici")
                   @OrderBy("acilisTarihi ASC")
                   private Set<MTSikayetleri> mTSikayetleriList = new HashSet<MTSikayetleri>(0);
              
                   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Dof.class, mappedBy = "istekYapanKullanici")
                   @OrderBy("acilisTarihi ASC")
                   private Set<Dof> dofList = new HashSet<Dof>(0);
                   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Oneri.class, mappedBy = "istemiBaslatanKullanici")
                   @OrderBy("acilisTarihi ASC")
                   private Set<Oneri> istemiBaslatilanOnerilerList = new HashSet<Oneri>(0);
              
                   @OneToOne(mappedBy = "tetkikci", cascade = { CascadeType.MERGE,
                             CascadeType.REFRESH })
                   private Tetkikci tetkik;
              
                   @OneToOne(fetch = FetchType.LAZY, mappedBy = "user")
                   private OneriUser oneriUser;
              
                   @OneToOne(fetch = FetchType.LAZY, mappedBy = "user")
                   private MTSikayetleriUser mTSikayetleriUser;
              
                   @OneToOne(fetch = FetchType.LAZY, mappedBy = "user")
                   private DofUser dofUser;
              
                   @ManyToMany(fetch = FetchType.LAZY)
                   @JoinTable(name = "TYS_TOPLANTI_TO_OYS_USER", joinColumns = { @JoinColumn(name = "T_USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "T_TOPLANTI_ID") })
                   @OrderBy("toplantiTarihi ASC")
                   private List<Toplanti> toplantilar;
              
                   @UserRoles
                   @ManyToMany(fetch = FetchType.LAZY)
                   @JoinTable(name = "KYS_USER_TO_ROL", joinColumns = { @JoinColumn(name = "T_USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "T_ROL_ID") })
                   private List<Rol> roller = new ArrayList<Rol>(0);
              
                   @Column(name = "T_AKTIF", precision = 1, scale = 0)
                   private Boolean aktif = true;
              





              • 5. Re: LazyInitializationException issue
                Leo van den berg Master

                Hi,


                You're using the same entity for authentication and as a part of your richer domain model.
                I don't have the part where you pesist, I am assuming that it has to do with persisting the provided entity and re-displaying it.


                The JPA-identity store authentication only understands the basic annotations for authentication and doesn't use/handle any of your added associations. So in that sense it is normal that you get lazy-init exceptions if you try to handle that the User entity.


                I am still guessing here, but you could:


                - Use the default authentication methods and use User as a normal entity (normal mapping and not use the special annotations),
                - Create a sub-class for User (ApplicationUser) where you add all the associations,
                - Change the jpa-identity-store to load all needed associations.


                Again, still a first guess, because it wuld be helpful if you explain where you exactly persist and for what reason (save user data handling an adssociated class?)


                Leo.