2013年9月6日星期五

hql

I want to use hql statement to query a table , of course, here is an entity class , and then check the data obtained is assigned an object.
find code examples.
------ Solution --------------------------------------------
a List list = session.createQuery ("from table as t where t.parameter =?"). setParameter (0, "parameter"). list (); kind of statement ?
------ For reference only -------------------------------------- -
positive solutions upstairs I also learned
------ For reference only ---------------------- -----------------
form User
enough
if not the entity
SQLQuery query = getSession (). createSQLQuery (hql). addEntity (clazz);
------ For reference only ------------- --------------------------
this better be loaded up
------ For reference only - -------------------------------------
in JPA the JPQL where you can so that I do not know where okay hql
String sql = "select new com.cl.bean.SimplePerson (p.name, p.sex) from Person p where p.id = ? 1 " ;


------ For reference only ---------------------------------- -----
Oh, I have this problem solved independently .
My approach is
List result = this.getHibernateTemplate.find ("from HrmEducation h where h.employeeId =?", employeeId);
if (result.size () == 0) return null
else return result.get (0);

没有评论:

发表评论