package cn.sasa.test; import java.util.Arrays; import java.util.List; import org.hibernate.Session; import org.hibernate.Transaction; import cn.sasa.domain.account; import cn.sasa.utils.HibernateUtils; public class TestSQL { @org.junit.Test public void test() { Session session = HibernateUtils.getCurrentSession(); Transaction tran = session.beginTransaction(); String sql="select * from account where id>:id"; var query = session.createSQLQuery(sql); // List<Object[]> list = query.list(); // for(Object[] item : list){ // System.out.println(Arrays.toString(item)); // } query.setParameter("id", 2); query.addEntity(account.class); List<account> aclist = query.list(); System.out.println(aclist); tran.commit(); session.close(); } }