The following is my code:
Code:
@SuppressWarnings("unchecked")
public static void main(String[] args) {
HibernateUtil.getSession();
List b = new ArrayList();
b.add("1");
b.add("2");
List a = new org.hibernate.collection.PersistentList();
a.addAll(b);
}
And I got the following exception:
Code:
17:25:01,628 INFO SettingsFactory:294 - Deleted entity synthetic identifier rollback: disabled
17:25:01,628 INFO SettingsFactory:309 - Default entity-mode: pojo
17:25:01,628 INFO SettingsFactory:313 - Named query checking : enabled
17:25:01,691 INFO SessionFactoryImpl:161 - building session factory
17:25:02,644 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
17:25:02,816 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.write(AbstractPersistentCollection.java:183)
at org.hibernate.collection.PersistentList.addAll(PersistentList.java:189)
at com.rim.mvs.configio.exception.Test.main(Test.java:35)
Exception in thread "main" 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.write(AbstractPersistentCollection.java:183)
at org.hibernate.collection.PersistentList.addAll(PersistentList.java:189)
at com.rim.mvs.configio.exception.Test.main(Test.java:35)
Does anyone can point out what the problem is? Thanks.
Allen