Reputation: 57
Is there any hibernate criteria query exist equivalent to the following HQL?
"SELECT new TestTable(t.id,t.param1,t.param2,t.param3) FROM TestTable t"
Upvotes: 1
Views: 312
Reputation: 5178
In the case you want to load some columns of a table you may need Projection
Criteria crit = getSession().createCriteria(TestTable.class, "t");
ProjectionList projectionList = Projections.projectionList();
projectionList.add(Projections.property("id"));
projectionList.add(Projections.property("param1"));
projectionList.add(Projections.property("param2"));
projectionList.add(Projections.property("param1"));
crit.setProjection(projectionList);
List results = crit.list();
Upvotes: 1
Reputation: 7695
If all you are trying to do is query the rows of TestTable and get TestTable hibernate objects, just create a Criteria object on the class of the Hibernate object you are trying to retrieve.
Criteria crit = sess.createCriteria(TestTable.class);
List results = crit.list();
Upvotes: 0