Hi, even I had set everything to eager and/or tried to wrap around a session/transaction. I still get a LazyInitializationException (stack trace see below) if I tried to store objects loaded from the db to an xml-file.
Does PersitentBag, PersitentList and so on don't work with XML-Encoder? Or do I have to specify an Persitence-Delegate for them? Cause Hibernate don't replace them, even the whole list was loaded before. Or do you have any other idea to get to work. Or is there any easy way to convert any subclass of PersistentCollection to java.util classes?
Thanks.
Greetings Michael
Code:
14:38:00,765 DEBUG SQL:401 - select taxes0_.Steuerdaten_id as Steuerda1_4_, taxes0_.taxes_id as taxes2_4_, taxes0_.SO_Pos as SO3_4_, steuerobje1_.id as id4_0_, steuerobje1_.anteilAusgabenProduktion as anteilAu2_4_0_, steuerobje1_.anteilAusgabenVertrieb as anteilAu3_4_0_, steuerobje1_.anteilAusgabenVerwaltung as anteilAu4_4_0_, steuerobje1_.VERSION_OPTLOCK as VERSION5_4_0_, steuerobje1_.collectionComponent_id as collecti8_5_0_, steuerobje1_.comment as comment5_0_, steuerobje1_.hkTax_id as hkTax9_5_0_, steuerobje1_.inHK as inHK5_0_, steuerobje1_.lastPeriod as lastPeriod5_0_, steuerobje1_.liquiWirksam as liquiWir4_5_0_, steuerobje1_.name as name5_0_, steuerobje1_.perioden as perioden5_0_, steuerobje1_.type as type5_0_, taxbasesam2_.id as id18_1_, taxbasesam2_.bmgTyp as bmgTyp18_1_, taxbasesam2_.comment as comment18_1_, taxbasesam2_.name as name18_1_, taxbasesam2_.tarifImp_id as tarifImp2_21_1_, taxbasesam2_.taxbase as taxbase21_1_, universalt3_.id as id6_2_, universalt3_.additiveLevels as additive3_6_2_, universalt3_.comment as comment6_2_, universalt3_.inflation as inflation6_2_, universalt3_.selfDeductible as selfDedu6_6_2_, universalt3_.storageName as storageN7_6_2_, universalt3_.tarifOfTax as tarifOfTax6_2_, universalt3_.TarifArt as TarifArt6_2_, valueprodu4_.id as id13_3_, valueprodu4_.commentary as commentary13_3_, valueprodu4_.funktion as funktion13_3_, valueprodu4_.einbezogen as einbezogen14_3_, valueprodu4_.einbezogenAS as einbezog2_14_3_ from Steuerdaten_SteuerObjekt taxes0_ left outer join SteuerObjekt steuerobje1_ on taxes0_.taxes_id=steuerobje1_.id left outer join TaxBaseSammelbaustein taxbasesam2_ on steuerobje1_.collectionComponent_id=taxbasesam2_.id left outer join UniversalTarif universalt3_ on taxbasesam2_.tarifImp_id=universalt3_.id left outer join ValueProductionCosts valueprodu4_ on steuerobje1_.hkTax_id=valueprodu4_.id where taxes0_.Steuerdaten_id=?
12781 [AWT-EventQueue-0] DEBUG org.hibernate.SQL - select taxes0_.Steuerdaten_id as Steuerda1_4_, taxes0_.taxes_id as taxes2_4_, taxes0_.SO_Pos as SO3_4_, steuerobje1_.id as id4_0_, steuerobje1_.anteilAusgabenProduktion as anteilAu2_4_0_, steuerobje1_.anteilAusgabenVertrieb as anteilAu3_4_0_, steuerobje1_.anteilAusgabenVerwaltung as anteilAu4_4_0_, steuerobje1_.VERSION_OPTLOCK as VERSION5_4_0_, steuerobje1_.collectionComponent_id as collecti8_5_0_, steuerobje1_.comment as comment5_0_, steuerobje1_.hkTax_id as hkTax9_5_0_, steuerobje1_.inHK as inHK5_0_, steuerobje1_.lastPeriod as lastPeriod5_0_, steuerobje1_.liquiWirksam as liquiWir4_5_0_, steuerobje1_.name as name5_0_, steuerobje1_.perioden as perioden5_0_, steuerobje1_.type as type5_0_, taxbasesam2_.id as id18_1_, taxbasesam2_.bmgTyp as bmgTyp18_1_, taxbasesam2_.comment as comment18_1_, taxbasesam2_.name as name18_1_, taxbasesam2_.tarifImp_id as tarifImp2_21_1_, taxbasesam2_.taxbase as taxbase21_1_, universalt3_.id as id6_2_, universalt3_.additiveLevels as additive3_6_2_, universalt3_.comment as comment6_2_, universalt3_.inflation as inflation6_2_, universalt3_.selfDeductible as selfDedu6_6_2_, universalt3_.storageName as storageN7_6_2_, universalt3_.tarifOfTax as tarifOfTax6_2_, universalt3_.TarifArt as TarifArt6_2_, valueprodu4_.id as id13_3_, valueprodu4_.commentary as commentary13_3_, valueprodu4_.funktion as funktion13_3_, valueprodu4_.einbezogen as einbezogen14_3_, valueprodu4_.einbezogenAS as einbezog2_14_3_ from Steuerdaten_SteuerObjekt taxes0_ left outer join SteuerObjekt steuerobje1_ on taxes0_.taxes_id=steuerobje1_.id left outer join TaxBaseSammelbaustein taxbasesam2_ on steuerobje1_.collectionComponent_id=taxbasesam2_.id left outer join UniversalTarif universalt3_ on taxbasesam2_.tarifImp_id=universalt3_.id left outer join ValueProductionCosts valueprodu4_ on steuerobje1_.hkTax_id=valueprodu4_.id where taxes0_.Steuerdaten_id=?
14:38:17,468 ERROR LazyInitializationException:19 - failed to lazily initialize a collection, no session or session was closed
org.hibernate.14:38:00,765 DEBUG SQL:401 - select taxes0_.Steuerdaten_id as Steuerda1_4_, taxes0_.taxes_id as taxes2_4_, taxes0_.SO_Pos as SO3_4_, steuerobje1_.id as id4_0_, steuerobje1_.anteilAusgabenProduktion as anteilAu2_4_0_, steuerobje1_.anteilAusgabenVertrieb as anteilAu3_4_0_, steuerobje1_.anteilAusgabenVerwaltung as anteilAu4_4_0_, steuerobje1_.VERSION_OPTLOCK as VERSION5_4_0_, steuerobje1_.collectionComponent_id as collecti8_5_0_, steuerobje1_.comment as comment5_0_, steuerobje1_.hkTax_id as hkTax9_5_0_, steuerobje1_.inHK as inHK5_0_, steuerobje1_.lastPeriod as lastPeriod5_0_, steuerobje1_.liquiWirksam as liquiWir4_5_0_, steuerobje1_.name as name5_0_, steuerobje1_.perioden as perioden5_0_, steuerobje1_.type as type5_0_, taxbasesam2_.id as id18_1_, taxbasesam2_.bmgTyp as bmgTyp18_1_, taxbasesam2_.comment as comment18_1_, taxbasesam2_.name as name18_1_, taxbasesam2_.tarifImp_id as tarifImp2_21_1_, taxbasesam2_.taxbase as taxbase21_1_, universalt3_.id as id6_2_, universalt3_.additiveLevels as additive3_6_2_, universalt3_.comment as comment6_2_, universalt3_.inflation as inflation6_2_, universalt3_.selfDeductible as selfDedu6_6_2_, universalt3_.storageName as storageN7_6_2_, universalt3_.tarifOfTax as tarifOfTax6_2_, universalt3_.TarifArt as TarifArt6_2_, valueprodu4_.id as id13_3_, valueprodu4_.commentary as commentary13_3_, valueprodu4_.funktion as funktion13_3_, valueprodu4_.einbezogen as einbezogen14_3_, valueprodu4_.einbezogenAS as einbezog2_14_3_ from Steuerdaten_SteuerObjekt taxes0_ left outer join SteuerObjekt steuerobje1_ on taxes0_.taxes_id=steuerobje1_.id left outer join TaxBaseSammelbaustein taxbasesam2_ on steuerobje1_.collectionComponent_id=taxbasesam2_.id left outer join UniversalTarif universalt3_ on taxbasesam2_.tarifImp_id=universalt3_.id left outer join ValueProductionCosts valueprodu4_ on steuerobje1_.hkTax_id=valueprodu4_.id where taxes0_.Steuerdaten_id=?
12781 [AWT-EventQueue-0] DEBUG org.hibernate.SQL - select taxes0_.Steuerdaten_id as Steuerda1_4_, taxes0_.taxes_id as taxes2_4_, taxes0_.SO_Pos as SO3_4_, steuerobje1_.id as id4_0_, steuerobje1_.anteilAusgabenProduktion as anteilAu2_4_0_, steuerobje1_.anteilAusgabenVertrieb as anteilAu3_4_0_, steuerobje1_.anteilAusgabenVerwaltung as anteilAu4_4_0_, steuerobje1_.VERSION_OPTLOCK as VERSION5_4_0_, steuerobje1_.collectionComponent_id as collecti8_5_0_, steuerobje1_.comment as comment5_0_, steuerobje1_.hkTax_id as hkTax9_5_0_, steuerobje1_.inHK as inHK5_0_, steuerobje1_.lastPeriod as lastPeriod5_0_, steuerobje1_.liquiWirksam as liquiWir4_5_0_, steuerobje1_.name as name5_0_, steuerobje1_.perioden as perioden5_0_, steuerobje1_.type as type5_0_, taxbasesam2_.id as id18_1_, taxbasesam2_.bmgTyp as bmgTyp18_1_, taxbasesam2_.comment as comment18_1_, taxbasesam2_.name as name18_1_, taxbasesam2_.tarifImp_id as tarifImp2_21_1_, taxbasesam2_.taxbase as taxbase21_1_, universalt3_.id as id6_2_, universalt3_.additiveLevels as additive3_6_2_, universalt3_.comment as comment6_2_, universalt3_.inflation as inflation6_2_, universalt3_.selfDeductible as selfDedu6_6_2_, universalt3_.storageName as storageN7_6_2_, universalt3_.tarifOfTax as tarifOfTax6_2_, universalt3_.TarifArt as TarifArt6_2_, valueprodu4_.id as id13_3_, valueprodu4_.commentary as commentary13_3_, valueprodu4_.funktion as funktion13_3_, valueprodu4_.einbezogen as einbezogen14_3_, valueprodu4_.einbezogenAS as einbezog2_14_3_ from Steuerdaten_SteuerObjekt taxes0_ left outer join SteuerObjekt steuerobje1_ on taxes0_.taxes_id=steuerobje1_.id left outer join TaxBaseSammelbaustein taxbasesam2_ on steuerobje1_.collectionComponent_id=taxbasesam2_.id left outer join UniversalTarif universalt3_ on taxbasesam2_.tarifImp_id=universalt3_.id left outer join ValueProductionCosts valueprodu4_ on steuerobje1_.hkTax_id=valueprodu4_.id where taxes0_.Steuerdaten_id=?
14:38:17,468 ERROR LazyInitializationException:19 - failed to lazily initialize a collection, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.PersistentList.listIterator(PersistentList.java:347)
at java.util.AbstractList.equals(Unknown Source)
at java.beans.DefaultPersistenceDelegate.equals(Unknown Source)
at java.beans.DefaultPersistenceDelegate.doProperty(Unknown Source)
at java.beans.DefaultPersistenceDelegate.initBean(Unknown Source)
at java.beans.DefaultPersistenceDelegate.initialize(Unknown Source)
at java.beans.PersistenceDelegate.writeObject(Unknown Source)
at java.beans.Encoder.writeObject(Unknown Source)
at java.beans.XMLEncoder.writeObject(Unknown Source)
at java.beans.Encoder.writeExpression(Unknown Source)
at java.beans.XMLEncoder.writeExpression(Unknown Source)
at java.beans.PersistenceDelegate.writeObject(Unknown Source)
at java.beans.Encoder.writeObject(Unknown Source)
at java.beans.XMLEncoder.writeObject(Unknown Source)
at java.beans.Encoder.writeObject1(Unknown Source)
at java.beans.Encoder.cloneStatement(Unknown Source)
at java.beans.Encoder.writeStatement(Unknown Source)
at java.beans.XMLEncoder.writeStatement(Unknown Source)
at java.beans.DefaultPersistenceDelegate.invokeStatement(Unknown Source)
at java.beans.java_util_Collection_PersistenceDelegate.initialize(Unknown Source)
at java.beans.PersistenceDelegate.initialize(Unknown Source)
at java.beans.DefaultPersistenceDelegate.initialize(Unknown Source)
at java.beans.PersistenceDelegate.initialize(Unknown Source)
at java.beans.DefaultPersistenceDelegate.initialize(Unknown Source)
at java.beans.PersistenceDelegate.writeObject(Unknown Source)
at java.beans.Encoder.writeObject(Unknown Source)
at java.beans.XMLEncoder.writeObject(Unknown Source)
at java.beans.Encoder.writeExpression(Unknown Source)
at java.beans.XMLEncoder.writeExpression(Unknown Source)
at java.beans.PersistenceDelegate.writeObject(Unknown Source)
at java.beans.Encoder.writeObject(Unknown Source)
at java.beans.XMLEncoder.writeObject(Unknown Source)
at java.beans.Encoder.writeObject1(Unknown Source)
at java.beans.Encoder.cloneStatement(Unknown Source)
at java.beans.Encoder.writeStatement(Unknown Source)
at java.beans.XMLEncoder.writeStatement(Unknown Source)
at java.beans.XMLEncoder.writeObject(Unknown Source)
at de.zew.vitax.gui.main.menu.sim.ModellMenu$4.doWork(ModellMenu.java:385)
at de.zew.vitax.io.XML_WriteOperations.openXMLEncoder(XML_WriteOperations.java:278)
at de.zew.vitax.io.XML_WriteOperations.access$1(XML_WriteOperations.java:232)
at de.zew.vitax.io.XML_WriteOperations$2.run(XML_WriteOperations.java:423)
: failed to lazily initialize a collection, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.PersistentList.listIterator(PersistentList.java:347)
at java.util.AbstractList.equals(Unknown Source)
at java.beans.DefaultPersistenceDelegate.equals(Unknown Source)
at java.beans.DefaultPersistenceDelegate.doProperty(Unknown Source)
at java.beans.DefaultPersistenceDelegate.initBean(Unknown Source)
at java.beans.DefaultPersistenceDelegate.initialize(Unknown Source)
at java.beans.PersistenceDelegate.writeObject(Unknown Source)
at java.beans.Encoder.writeObject(Unknown Source)
at java.beans.XMLEncoder.writeObject(Unknown Source)
at java.beans.Encoder.writeExpression(Unknown Source)
at java.beans.XMLEncoder.writeExpression(Unknown Source)
at java.beans.PersistenceDelegate.writeObject(Unknown Source)
at java.beans.Encoder.writeObject(Unknown Source)
at java.beans.XMLEncoder.writeObject(Unknown Source)
at java.beans.Encoder.writeObject1(Unknown Source)
at java.beans.Encoder.cloneStatement(Unknown Source)
at java.beans.Encoder.writeStatement(Unknown Source)
at java.beans.XMLEncoder.writeStatement(Unknown Source)
at java.beans.DefaultPersistenceDelegate.invokeStatement(Unknown Source)
at java.beans.java_util_Collection_PersistenceDelegate.initialize(Unknown Source)
at java.beans.PersistenceDelegate.initialize(Unknown Source)
at java.beans.DefaultPersistenceDelegate.initialize(Unknown Source)
at java.beans.PersistenceDelegate.initialize(Unknown Source)
at java.beans.DefaultPersistenceDelegate.initialize(Unknown Source)
at java.beans.PersistenceDelegate.writeObject(Unknown Source)
at java.beans.Encoder.writeObject(Unknown Source)
at java.beans.XMLEncoder.writeObject(Unknown Source)
at java.beans.Encoder.writeExpression(Unknown Source)
at java.beans.XMLEncoder.writeExpression(Unknown Source)
at java.beans.PersistenceDelegate.writeObject(Unknown Source)
at java.beans.Encoder.writeObject(Unknown Source)
at java.beans.XMLEncoder.writeObject(Unknown Source)
at java.beans.Encoder.writeObject1(Unknown Source)
at java.beans.Encoder.cloneStatement(Unknown Source)
at java.beans.Encoder.writeStatement(Unknown Source)
at java.beans.XMLEncoder.writeStatement(Unknown Source)
at java.beans.XMLEncoder.writeObject(Unknown Source)
at de.zew.vitax.gui.main.menu.sim.ModellMenu$4.doWork(ModellMenu.java:385)
at de.zew.vitax.io.XML_WriteOperations.openXMLEncoder(XML_WriteOperations.java:278)
at de.zew.vitax.io.XML_WriteOperations.access$1(XML_WriteOperations.java:232)
at de.zew.vitax.io.XML_WriteOperations$2.run(XML_WriteOperations.java:423)