hibernate3.0 like子句处理中文有一个问题, 3.1已得到修正。3.0版可以通过设置参数解决。改正如下:
String str = "张";
String hql = "from Customer c where c.name like ?";
Query query = session.createQuery(hql).setString(0, str+"_");
String str = "张";
String hql = "from Customer c where c.name like ?";
Query query = session.createQuery(hql).setString(0, str+"_");
2016-09-15
String hql = "SELECT o.customer.name,o.tradeDate AS tradeDate,o.status AS status,o.amount AS amount FROM Order AS o "
+ " WHERE (o.tradeDate BETWEEN '2005-05-01' AND '2015-06-01') AND o.status IN ('已经货','已付款') AND o.amount > 1000 ORDER BY o.status ASC,o.tradeDate DESC,o.amount DESC";
+ " WHERE (o.tradeDate BETWEEN '2005-05-01' AND '2015-06-01') AND o.status IN ('已经货','已付款') AND o.amount > 1000 ORDER BY o.status ASC,o.tradeDate DESC,o.amount DESC";
全部都没加泛型。List返回时,最好加上Object泛型,即List<Object>;Map返回时,最好加上String,Object泛型,即Map<String,Object>
2016-09-13