日期:2014-05-17 浏览次数:20966 次
	public User getUser(String id) {
		String hql = "from User user where user.id=?";
		Query query = sessionFactory.getCurrentSession().createQuery(hql);
		query.setString(0, id);
		return (User)query.uniqueResult();
	}
	
	public User findById(String id) {
		if (id == null) {
			return null;
		}
		String hql = "select user from User user where lower(user.id) like lower(:id) and user.product is null";
		try {
			return this.entityManager.createQuery(hql, User.class).setFlushMode(FlushModeType.COMMIT).setParameter("id", "%"+id).getSingleResult();
		} catch(NoResultException e) {
			// TODO: handle exception
		}
		return null;
	}