Hibernate version: 3.1.3
String sql = "select c.id as {c.id} from table s where s.field1 = :param or :param is null";
Query q = session.createSQLQuery(sql).addEntity("c",MyClass.class);
q.setParameter("param ",param ==null?"":param);
List list = q.list();
oracle 10 mytable includes 7 million row. field1 indexed.
but it runs than very very slow response.
but i changed sql (:param is null -> 'bla' is null):
String sql = "select c.id as {c.id} from table s where s.field1 = :param or 'bla' is null";
very fast...
please help me.
thank you...
|