Example #1
0
 /**
  * read user
  *
  * @param user user reference
  * @return user
  */
 @Override
 @SuppressWarnings("unchecked")
 public User read(User user) {
   Long id = user.getUserId();
   String username = user.getUsername();
   String email = user.getEmail();
   String password = user.getPassword();
   List<User> users = new ArrayList<>();
   users.addAll((List<User>) hibernateTemplate.findByNamedQuery("findUserById", id, password));
   users.addAll(
       (List<User>) hibernateTemplate.findByNamedQuery("findUserByUsername", username, password));
   users.addAll(
       (List<User>) hibernateTemplate.findByNamedQuery("findUserByEmail", email, password));
   return users.size() > 0 ? users.get(0) : null;
 }
Example #2
0
 /**
  * creates user in database
  *
  * @param user user reference
  */
 @Override
 public User create(User user) {
   Page page = new Page();
   hibernateTemplate.save(page);
   user.setPageId(page.getPageId());
   hibernateTemplate.save(user);
   return user;
 }