Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.2.2.GA
Code between sessionFactory.openSession() and session.close():
Code:
session.beginTransaction();
for (Campaign camp : campaigns) {
for (Lot lot : (Set<Lot>)camp.getLots()) {
Hibernate.initialize(lot.getCampaign());
Hibernate.initialize(lot.getMsds());
Hibernate.initialize(lot.getLotAssgns());
for (LotAssgn lotAssgn : (Set<LotAssgn>)lot.getLotAssgns()) {
Hibernate.initialize(lotAssgn.getTrnfm());
Hibernate.initialize(lotAssgn.getTrnfm().getLotAssgns());
Hibernate.initialize(lotAssgn.getTrnfm().getMatl());
if( lotAssgn.getTrnfm().getMatl() != null ){
Hibernate.initialize(lotAssgn.getTrnfm().getMatl().getYard() );
Hibernate.initialize(lotAssgn.getTrnfm().getMatl().getYard().getYdgrp() );
}
Hibernate.initialize(lotAssgn.getLotNwAssgns());
Hibernate.initialize(lotAssgn.getLot());
Hibernate.initialize(lotAssgn.getLot().getCampaign());
}
//get the Msds, intialise
for (Msd msd : (Set<Msd>)lot.getMsds()) {
Hibernate.initialize(msd.getLotNwAssgns());
Hibernate.initialize(msd.getMs());
Hibernate.initialize(msd.getMs().getMssgl());
Hibernate.initialize(msd.getMs().getMsds());
Hibernate.initialize(msd.getMs().getDddes());
Hibernate.initialize(msd.getMs().getMbook());
Hibernate.initialize(msd.getMs().getMbook().getCoi());
Hibernate.initialize(msd.getMs().getMbook().getCoi().getMbooks());
Hibernate.initialize(msd.getMs().getMddes());
Hibernate.initialize(msd.getMs().getSddes());
Hibernate.initialize(msd.getMs().getWcmaByNxtwc());
Hibernate.initialize(msd.getMs().getWcmaByWcCd());
}
Query q1 = session.createQuery("from Cntl cntl where cntl.key = 'BW_EUSR'");
long t1 = System.currentTimeMillis();
q1.list();
System.out.println("t1 = " + ( System.currentTimeMillis() - t1 ));
}
Name and version of the database you are using:
Oracle9i Enterprise Edition Release 9.2.0.4.0
Ok alittle extra info, the Campaign loop goes through 5 times (currently) each campaign has 90 - 100 Lot's and each Lot has 1 - 11 Msd's (average 2), with all the intialisation done there are around 2000 entities loaded.
The problem I am having is every time the campaign loop goes through, the time taken to execute _ANY_ query jumps, by the end of all the campaign loops and intialisations it takes around 2 seconds to do even a simple query like the one shown, now if i _DO NOT_ begin the transaction it runs along fine, but even if after the intialisation i start the transaction all subsequent querying slows down to uselessness, now is this meant to happen or have I done something wrong, or perhaps hibernate is not acting as it should, though I assume that seen as though so many entities are loaded that whenever I do a query hibernate must check through the cache which takes alot of time :\