2015年11月26日 | Leave a comment 问题: String keyword=... String sql="select * from user where name like '%?%' "; Query q=emcrm.createNativeQuery(sql); q.setParameter(1, keyword); 12345 String keyword=...String sql="select * from user where name like '%?%' "; Query q=emcrm.createNativeQuery(sql); q.setParameter(1, keyword); 会查不到 解决: setParameter(1, “%”+keyword+”%”); //这外边会自动加 ” String sql="select * from user where name like ? "; Query q=emcrm.createNativeQuery(sql); q.setParameter(1, "%"+keyword+"%"); 1234 String sql="select * from user where name like ? "; Query q=emcrm.createNativeQuery(sql); q.setParameter(1, "%"+keyword+"%");