开发者

HIbernate Free Query

开发者 https://www.devze.com 2022-12-12 00:11 出处:网络
I would like to query using hib开发者_运维百科ernate given a particulay query string I did it like this:

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

精彩评论

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