开发者

HIbernate Free Query

I would like to query using hib开发者_运维百科ernate given a particulay query string I did it like this:

session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
List<String> result = session.createQuery("Select item_value from cb_items").list();  
session.getTransaction().commit();
session.clear();  
return result;

Is this right? or do i have to substitute the column name with the fields in my pojo/bean and the table name with my pojo/bean name


You have to substitute the column name with the field name, and the table name with the Entity's class name, and follow a little different sytax.


I missed the mapping in my hibernate.cfg.xml

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜