@Override public boolean isUpdatableEmail(String email, String username) { List<UserProfile> list = userProfileDao.findByCriteria(eq("email", email)); // there is no the same email address. if (list.size() == 0) return true; // There are more than two email address. it cannot be possible. if (list.size() > 1) return false; if (list.size() == 1) { UserProfile profile = list.get(0); if (profile.getUser().getUsername().equals(username)) return true; else return false; } return false; }
@Override public UserProfile findByEmail(String email) { List<UserProfile> list = userProfileDao.findByCriteria(eq("email", email)); return (list.size() == 0 ? null : list.get(0)); }
@Override public void upateUserProfile(UserProfile userProfile) { userProfileDao.merge(userProfile); userProfileDao.flush(); }