第二题
String hql = "select o.customer.name, o.tradedate, o.status, o.amount " +
"from t_order o " +
"where o.tradedate between '2015-05-01' and '2015-06-01' " +
"and o.status in ('已发货', '已付款') and o.amount > 1000 " +
"order by o.status, o.tradedate desc, o.amount desc";
String hql = "select o.customer.name, o.tradedate, o.status, o.amount " +
"from t_order o " +
"where o.tradedate between '2015-05-01' and '2015-06-01' " +
"and o.status in ('已发货', '已付款') and o.amount > 1000 " +
"order by o.status, o.tradedate desc, o.amount desc";
只要from字句的情况下,hibernate默认会查询该持久化类的所有实例,及该持久化类映射配置的所有属性信息。当hibernate框架,将HQL语句解析成SQL语句的时候,就会查询该持久化类映射的数据表中,所有的映射字段信息,并将返回的结果封装为该持久化类的对象集合。
2018-01-18