Hibernate version: 3.05
I have the following sql string:
Code:
INFO - [NDDMetricService.getMetricBrowseFields] query: SELECT distinct new com.sbc.netrics.struts.database.NddMetric( NddMetric.metricId, NddMetric.metricNumber,NddMetric.metricName,NddMetric.metricDescription,NddMetric.dataSteward) FROM com.sbc.netrics.struts.database.NddMetric NddMetric WHERE large_xml <> 'Y' AND extract(xml_doc , '/metric_extended_attributes/*') like '%BUILD%' order by metric_name ASC
Which yields the following debug:
Code:
Hibernate: select * from ( select distinct nddmetric0_.METRIC_ID as col_0_0_, nddmetric0_.METRIC_NUMBER as col_1_0_, nddmetric0_.METRIC_NAME as col_2_0_, nddmetric0_.METRIC_DESCRIPTION as col_3_0_, nddmetric0_.DATA_STEWARD as col_4_0_ from NDD_METRIC nddmetric0_ where large_xml<>'Y' and (extract(xml_doc '/metric_extended_attributes/*')like '%BUILD%') order by metric_name ASC ) where rownum <= ?
And the following errors:
Code:
WARN - [JDBCExceptionReporter.logExceptions] SQL Error: 907, SQLState: 42000
ERROR - [JDBCExceptionReporter.logExceptions] ORA-00907: missing right parenthesis
Notice that the "," in "extract(xml_doc , '/metric_extended_attributes/*')" dissapears when the hibernate sql is displayed: "extract(xml_doc '/metric_extended_attributes/*')like '%BUILD%')"
which is likely the reason I'm getting an unbalanced paranthesis error. Why is hibernate parsing out the "," -- and HOW do I overcome this?
My tableService method:
Code:
public List getMetricBrowseFields(int pageSize
, int pageStart
, String orderByField
, String orderDirection
, String filterExpr) throws Exception
{
List nddMetricList;
try {
String sql = "SELECT distinct new com.sbc.netrics.struts.database.NddMetric( NddMetric.metricId," +
" NddMetric.metricNumber,NddMetric.metricName,NddMetric.metricDescription,NddMetric.dataSteward) " +
" FROM com.sbc.netrics.struts.database.NddMetric NddMetric ";
if (! filterExpr.equals("")) {
filterExpr = "large_xml <> 'Y' AND " + filterExpr;
log.info("filterX3: " + filterExpr);
sql = sql + " WHERE " + filterExpr + " ";
log.info("sql: " + sql);
}
sql = sql + " order by " + orderByField + " " + orderDirection;
Query query = HibernateUtil3.getCurrentSession().createQuery(sql);
query.setFirstResult(pageStart);
query.setMaxResults(pageSize);
query.setReadOnly(true);
log.info("query: " + query.getQueryString());
nddMetricList = query.list();
} catch (HibernateException ex) {
throw new InfrastructureException(ex);
}
return nddMetricList;
}
Lee