try {
Session s = NewHibernateUtil.getSessionFactory().openSession();
Criteria c = s.createCriteria(Product.class);
c.add(Restrictions.eq("Gender", "Men"));
c.setResultTransformer(c.DISTINCT_ROOT_ENTITY);
List<Product> pList = c.list();
String size = "<option>Select size</option>";
for (Product p : pList) {
size += "<option>"+p.getProductSize()+"</option>";
}
resp.getWriter().write(size);
} catch (Exception e) {
e.printStackTrace();
}
我需要从产品中删除所有重复的尺寸,但这对我的建议都不起作用
答案 0 :(得分:0)
更改行
c.setResultTransformer(c.DISTINCT_ROOT_ENTITY);
与
c.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
答案 1 :(得分:0)
尝试一下:
var config = new LoggingConfiguration();
NLog.LogManager.Configuration = config;
NServiceBus.Logging.LogManager.Use<NLogFactory>();