Hello
I get an error that reads "Hibernate lazy instantiation problem". What does this mean? I am reading from one table and inserting & deleting to/from 3 other tables. Any ideas? Thanks!
Hibernate version:
2.1.8
Code between sessionFactory.openSession() and session.close():
public void convert()
{
Session session = null;
Transaction tx = null;
T_psched currentPsched = null;
try
{
session = SessionManager.getSessionFactory().openSession();
tx = session.beginTransaction();
String previousStudy = "-1";
int previousPatid = -1;
int numDeleted = 0;
// get all the psched objects, ordered
Query pidQuery = session.getNamedQuery("allPatientsOrdered");
Iterator pschedIter = pidQuery.iterate();
// scan through each T_psched object
while(pschedIter.hasNext())
{
currentPsched = (T_psched) pschedIter.next();
if ((!(currentPsched.getT_pschedID().getStudy().equals(previousStudy))) ||
(currentPsched.getT_pschedID().getStudy().equals(previousStudy) &&
(currentPsched.getT_pschedID().getPatid() != previousPatid)))
{
// we have a different study/patid than previous iteration
// so save this study/patid do compare against on the next iteration
// and clear of legacy tables for this study/patid
previousStudy = new String(currentPsched.getT_pschedID().getStudy());
previousPatid = currentPsched.getT_pschedID().getPatid();
Object values[] = new Object[2];
values[0] = currentPsched.getT_pschedID().getStudy();
values[1] = new Integer(currentPsched.getT_pschedID().getPatid());
Type types[] = new Type[2];
types[0] = Hibernate.STRING;
types[1] = Hibernate.INTEGER;
// delete all the ddmiss objects for the current study/patid
numDeleted = session.delete("from T_ddmiss as ddmiss where ddmiss.t_ddmissID.study = ? and ddmiss.t_ddmissID.patid = ?",
values, types);
tx.commit();
// delete all the pat_sch objects for the current study/patid
numDeleted = session.delete("from T_pat_sch as pat_sch where pat_sch.t_pat_schID.study = ? and pat_sch.t_pat_schID.patid = ?",
values, types);
tx.commit();
// delete all the ddcmpl objects for the current study/patid
numDeleted = session.delete("from T_ddcmpl as ddcmpl where ddcmpl.t_ddcmplID.study = ? and ddcmpl.t_ddcmplID.patid = ?",
values, types);
tx.commit();
}
if (currentPsched.getComp() == 2)
{
// translate psched object into ddmiss object & save it
convertAndSaveDDMISS(currentPsched);
}
if ((currentPsched.getReq() == 1) && (currentPsched.getComp() != 1))
{
// translate psched object into pat_sch object & save it
convertAndSavePAT_SCH(currentPsched);
}
if (currentPsched.getComp() == 1)
{
// translate psched object into ddcmpl object & save it
convertAndSaveDDCMPL(currentPsched);
}
}
}
catch (Throwable e)
{
if(tx!=null && session!=null && session.isOpen())
{
try
{
tx.rollback();
}
catch (HibernateException he)
{
logger.error(he.getMessage(), he);
}
}
logger.fatal("General Exception", e);
if (currentPsched != null)
logger.info(currentPsched.toString());
logger.info(Constants.programName + " Ended");
SessionManager.disconnect();
System.exit(1);
}
finally
{
try
{
if (session.isOpen())
{
session.close();
session = null;
}
}
catch (HibernateException he)
{
logger.error(he.getMessage(), he);
}
}
}
Full stack trace of any exception that occurs:
com.smurf.common.delinquency.legacyConverter.convertDCFS.ConvertDCFS.convert(ConvertDCFS.java:189)
General Exception
net.sf.hibernate.LazyInitializationException: Hibernate lazy instantiation problem
at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:133)
at com.smurf.common.delinquency.legacyConverter.convertDCFS.ConvertDCFS.convert(ConvertDCFS.java:120)
at com.smurf.common.delinquency.legacyConverter.convertDCFS.ConvertDCFS.main(ConvertDCFS.java:81)
Caused by: ca.edbc.util.EdbcEx: No open cursor exists matching the requested ID.
at ca.edbc.jdbc.EdbcObj.readResults(EdbcObj.java:782)
at ca.edbc.jdbc.RsltFtch.load(RsltFtch.java:353)
at ca.edbc.jdbc.RsltCurs.load(RsltCurs.java:245)
at ca.edbc.jdbc.EdbcRslt.next(EdbcRslt.java:562)
at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:85)
at net.sf.hibernate.impl.IteratorImpl.next(IteratorImpl.java:127)
... 2 more
08/08/2005 13:46:34 - INFO
com.smurf.common.delinquency.legacyConverter.convertDCFS.ConvertDCFS.convert(ConvertDCFS.java:192)
com.smurf.common.delinquency.legacyConverter.tables.T_psched@4a6416f9
Name and version of the database you are using:
Ingres II
|