Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.0.5
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="pts.data">
<class name="TesterV" table="tester_v2" mutable="false" schema="ngptd.ptd_admin">
<composite-id>
<key-property name="testerName" column="tester_name" type="java.lang.String" />
<key-property name="testerType" column="tester_type" type="java.lang.String" />
</composite-id>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Criteria crit = session.createCriteria(TesterV.class);
/* Do SELECT */
Projection proj = Projections.property("testerName");
crit.setProjection(proj);
/* Do WHERE */
Disjunction disj = Restrictions.disjunction();
disj.add(Restrictions.eq("testerType", "TUBES"));
disj.add(Restrictions.eq("testerType", "GENERATOR"));
crit.add(disj);
crit.add(Expression.like("testerName","?"));
/* Do ORDER BY*/
crit.addOrder(Order.desc("testerName"));
/* Get Results */
List testers = crit.list();
System.out.println(testers);
Full stack trace of any exception that occurs:
Name and version of the database you are using:MSSQL 2000
The generated SQL (show_sql=true):
Hibernate: select this_.tester_name as y0_ from ngptd.ptd_admin.tester_v2 this_ where (this_.tester_type=? or this_.tester_type=?) and this_.tester_name like ? order by this_.tester_name desc
Debug level Hibernate log excerpt:
When I add the above like expression, or any variation of that expression that I can possibly think of, Hibernate brings back 0 results. I've tried different tables, different strings, different columns. Has this happened to anyone else before?