Hibernate version:2.1.X
Code in Persister:
public List getParent(String ssn, String pin) throws HibernateException,Exception {
List result = null;
try {
Session session = HibernateSessionFactory.currentSession();
StringBuffer sql = new StringBuffer();
sql.append("from CswCaseParent1 as cp where (cp.clientSsnId = ").append(ssn)
.append(" AND cp.clientPinId = ").append(pin)
.append(") OR (cp.respondentSsnId = ").append(ssn)
.append(" AND cp.respondentPinId =").append(pin).append(")");
Query q1 = session.createQuery(sql.toString());
result = q1.list();
} catch (HibernateException e) {
log.error("HibernateException occured while getting the parent information...", e);
throw new HibernateException("HibernateException occured while getting the parent information...",e);
} catch (Exception e) {
log.error("Exception occured while getting the parent information..." , e);
throw new Exception("Exception occured while getting the parent information...",e);
}finally {
//log.debug("closing the HibernateSessionFactory..");
try {
HibernateSessionFactory.closeSession();
} catch (Exception e) {
throw new Exception("Exception occured while closing the HibernateSessionFactory..",e);
}
}
return result;
}
Code between sessionFactory.openSession() and session.close():
public static Session currentSession() throws HibernateException {
Session session = (Session) threadLocal.get();
if (session == null) {
if (sessionFactory == null) {
try {
//cfg.configure(CONFIG_FILE_LOCATION);
cfg.configure(new File("C:/Program Files/WebSphere/AppServer/hibernate.cfg.xml"));
sessionFactory = cfg.buildSessionFactory();
}
catch (Exception e) {
log.error("%%%% Error Creating SessionFactory %%%%", e);
throw new HibernateException(e);
}
}
session = sessionFactory.openSession();
threadLocal.set(session);
}
return session;
}
/**
* Close the single hibernate session instance.
*
* @throws HibernateException
*/
public static void closeSession() throws HibernateException,Exception {
Session session = (Session) threadLocal.get();
threadLocal.set(null);
try
{
if (session != null) {
session.close();
}
}
catch (Exception e) {
log.error("%%%% Error Closing SessionFactory %%%%", e);
throw new Exception("Exception while Closing SessionFactory..",e);
}
}
Full stack trace of any exception that occurs:
Not Exception.Issue related to performance
Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):
select cswcasepar0_.CASE_ID as CASE_ID, cswcasepar0_.COUNTY_CD as COUNTY_CD, cswcasepar0_.CLIENT_SSN_ID as CLIENT_S3_, cswcasepar0_.PIN_ID as PIN_ID, cswcasepar0_.CLIENT_PIN_ID as CLIENT_P5_, cswcasepar0_.CLIENT_NM as CLIENT_NM, cswcasepar0_.NET_DUE_AMT as NET_DUE_7_, cswcasepar0_.RESPONDENT_BIRTH_DT as RESPONDE8_, cswcasepar0_.RESPONDENT_ADDRESS_TYPE_CD as RESPONDE9_, cswcasepar0_.RESPONDENT_UPDATE_SSN_ID as RESPOND10_, cswcasepar0_.PAYMENT_FROM_DT as PAYMENT11_, cswcasepar0_.PAYMENT_TO_DT as PAYMENT12_, cswcasepar0_.RESPONDENT_SSN_ID as RESPOND13_, cswcasepar0_.RESPONDENT_PIN_ID as RESPOND14_, cswcasepar0_.RESPONDENT_NM as RESPOND15_, cswcasepar0_.CREATE_DT as CREATE_DT, cswcasepar0_.MODIFY_DT as MODIFY_DT, cswcasepar0_.CONTROL_CYCLE_NBR as CONTROL18_, cswcasepar0_.NCP_UPDATE_DT as NCP_UPD19_ from CSW_CASE_PARENT cswcasepar0_ where ((cswcasepar0_.CLIENT_SSN_ID='050547490' )AND(cswcasepar0_.CLIENT_PIN_ID='26021' ))OR((cswcasepar0_.RESPONDENT_SSN_ID='050547490' )AND(cswcasepar0_.RESPONDENT_PIN_ID='26021' ))
Hi there,
We are developing a hibernate(2.1.X) based application.We got a message from our DBA to use
Quote:
bind variables, not literals
.
What exactly that means.Here is my code ..What exactly i should do to use bind variables?
Any help is much appreciated.Thanks In Advance