Hibernate createQuery(".....")的几种不同用法
?
String category = "abc";//顺便写?
?
?
//第一种: Query query = em.createQuery("from Product as p where p.category = ?1"); query.setParameter(1, category);//第二种: Query query = session.createQuery("from test.Product product whereproduct.category=?"); query.setString(0, category);//第三种: Query query = em.createQuery("from Product as p wherep.category = :category"); query.setParameter("category", category);//第4种: Query query = em.createQuery("select p from Product p where p.id in (:ids)"); query.setParameter("ids", category);