Hibernate version: 3.0
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Code:
// Within an interceptor
private boolean initialAuditExists(String tableName, String rowIdAsString) {
boolean rv = false;
String countQuery = "select count(d) from myproduct.audit.transaction.TransactionAuditInterceptor d "
+ "where d.tablename=:tableName and d.rowidasstring=:rowIdAsString";
String[] paramNames = new String[]{"tableName", "rowIdAsString"};
Object[] paramValues = new Object[]{tableName, rowIdAsString};
Session tempSession = null;
try {
tempSession = HibernateAdapter.openSession(session.connection());
Integer count = (Integer) HibernateAdapter.getScalarQuery(tempSession, countQuery, paramNames, paramValues);
if (null != count && 0 < count.intValue()) {
rv = true;
}
} catch (HibernateException e) {
logger.error(e);
} finally {
if (null != tempSession ) {
tempSession.close();
}
}
return rv;
}
Full stack trace of any exception that occurs:
2005-11-04 15:42:33,955 [main] WARN org.hibernate.hql.QuerySplitter - no persistent classes found for query class: select count(d) from myproduct.audit.transaction.TransactionAuditInterceptor d where d.tablename=:tableName and d.rowidasstring=:rowIdAsString
Name and version of the database you are using:
SQL Server 2000 SP4
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
In the example above, the operation is always returning false because the count is null. I've verified that there is data that matches the query. Is there a typo in my query?