i debug the process:
public Object execute(HibernateCallback action, boolean exposeNativeSession) throws DataAccessException {
Session session = getSession();
boolean existingTransaction = SessionFactoryUtils.isSessionTransactional(session, getSessionFactory());
if (existingTransaction) {
logger.debug("Found thread-bound Session for HibernateTemplate");
}
FlushMode previousFlushMode = null;
try {
previousFlushMode = applyFlushMode(session, existingTransaction);
enableFilters(session);
Session sessionToExpose = (exposeNativeSession ? session : createSessionProxy(session));
Object result = action.doInHibernate(sessionToExpose);
flushIfNecessary(session, existingTransaction);
return result;
}
catch (HibernateException ex) {
throw convertHibernateAccessException(ex);
}
catch (SQLException ex) {
throw convertJdbcAccessException(ex);
}
catch (RuntimeException ex) {
// Callback code threw application exception...
throw ex;
}
finally {
if (existingTransaction) {
logger.debug("Not closing pre-bound Hibernate Session after HibernateTemplate");
disableFilters(session);
if (previousFlushMode != null) {
session.setFlushMode(previousFlushMode);
}
}
else {
// Never use deferred close for an explicitly new Session.
if (isAlwaysUseNewSession()) {
SessionFactoryUtils.closeSession(session);
}
else {
SessionFactoryUtils.closeSessionOrRegisterDeferredClose(session, getSessionFactory());
}
}
}
}
when debug into:
Session sessionToExpose = (exposeNativeSession ? session : createSessionProxy(session));
the console shows:
Hibernate: /* load com.shenzhenair.medet.bo.users.Username */ select username0_.USERNAME as USERNAME0_, username0_.LONGNAME as LONGNAME19_0_, username0_.DEPARTMENT as DEPARTMENT19_0_, username0_.FUNCTIONNAMETYPE as FUNCTION4_19_0_, username0_.VERSIONNO as VERSIONNO19_0_, username0_.UPDATEDWHEN as UPDATEDW6_19_0_, username0_.UPDATEDBY as UPDATEDBY19_0_, username0_.USERID as USERID19_0_, username0_.PASSWORD as PASSWORD19_0_, username0_.USERMENU as USERMENU19_0_, username0_.VALID_IN_DB as VALID11_19_0_ from AMICOS.USERNAME username0_ where username0_.USERNAME=?
but run to next command:
Object result = action.doInHibernate(sessionToExpose);
it shows that the result is null!
in fact, in database there is a results, why it canot show?
|