SQL检索方式

2.X
Query q=session.createSQLQuery(“select * from CUSTOMERS c where c.NAME like :name”,”c”,Customer.class);
q.setString(“name”,”zhang%”);
//q.setString(0,”zhang%”);      
List result=q.list();



3.X
Query q=session.createSQLQuery(“select * from CUSTOMERS c where c.NAME like :name”).addEntity(Customer.class);
q.setString(“name”,”zhang%”);
//q.setString(0,”zhang%”);
List result=q.list();

你可能感兴趣的:(java,sql,C++,c,C#)