日期:2014-05-19 浏览次数:20692 次
/** * 判断用户是否存在 * @param username * @return */ public boolean exsit(String username){ long count = (Long)em.createQuery("select count(o) from Buyer o where o.username=?1") .setParameter(1, username).getSingleResult(); return count>0; } /** * 判断用户名及密码是否正确 * @param username * @param password * @return */ public boolean checkUser(String username, String password){ long count = (Long)em.createQuery("select count(o) from Buyer o where o.username=?1 and o.password=?2") .setParameter(1, username).setParameter(2, MD5.MD5Encode(password)).getSingleResult(); return count>0; }