Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:2.1.7
[b]Mapping documents:
[b]Code between sessionFactory.openSession() and session.close():
Session ss = HibernateSessionFactory.currentSession();
Transaction tf= ss.beginTransaction();
tf=ss.beginTransaction();
List li = ss.find("from Sections s ");
Iterator it = li.iterator();
while (it.hasNext())
{
Sections sec = (Sections)it.next();
System.out.println("Section ID : "+sec.getSectionid());;
System.out.println("Section Nmae : "+sec.getSectionname());;
Set subli=(Set) sec.getSubjects();
Iterator subit= subli.iterator();
while (subit.hasNext())
{
Subject mysub =(Subject) subit.next();
System.out.println("Subject is : "+mysub.getSubjectname());
}
}
tf.commit();
[b]Full stack trace of any exception that occurs:
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:201)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)
at net.sf.hibernate.collection.Set.iterator(Set.java:130)
at myclient.MyClient.main(MyClient.java:66)
Caused by: net.sf.hibernate.exception.SQLGrammarException: could not initialize collection: [mypkg.Sections.subjects#555 ]
at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:30)
at net.sf.hibernate.collection.AbstractCollectionPersister.convert(AbstractCollectionPersister.java:728)
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:291)
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3303)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:195)
... 3 more
Caused by: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'sujbectid'.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeQuery(Unknown Source)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:88)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:990)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:965)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:93)
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:288)
... 5 more
Exception in thread "main"
[b]Name and version of the database you are using:sqlserver
Please help me out how to solve this lazy loading error.