一种方法,使用 in(:参数)
List names=new ArrayList();
names.add("user");
names.add("admin");
Query query = JPA.em().createQuery("from CasUserInfo where user_name in(:names)");
query.setParameter("names", names);
List users = query.getResultList();
renderJSON(users);
一种方法,使用原生sql查询
Query query = JPA.em().createNativeQuery(condition.toString());
List result = query.getResultList();
if (result != null) {
for (int i = 0; i < result.size(); i++) {
Object[] objects = (Object[]) result.get(i);
syso(objects[0].toString());
网友评论