Hibernate--SQL
阿新 • • 發佈:2017-09-29
sys session object c println sql查詢 object query pre col
SQL查詢:
5.2之後的版本:
NativeQuery<Order> sqlQuery = session.createNativeQuery("select * from t_order", Order.class); List<Order> list = sqlQuery.list();
for(Order order : list) { System.out.println(order); }
5.2之前的版本:
SQLQuery sqlQuery = session.createSQLQuery("select * from t_order"); sqlQuery.addEntity(Order.class);
List<Order> list = sqlQuery.list();
5.1之前的版本:
SQLQuery sqlQuery = session.createSQLQuery("select * from t_order"); List<Object[]> list = sqlQuery.list();
for(Object[] order : list) { for(Object column : order) {
System.out.print(column); System.out.print(" "); } System.out.println(); }
Hibernate--SQL