Пример #1
0
 public List<User> fetchUsersBeginningByAndAddableToWorkout(final String prefix, final long id) {
   final Query query =
       entityManager.createQuery(
           "select u from UserImpl u, WorkoutImpl workout where u.name<>'googlebot' AND u.name LIKE CONCAT(:prefix, '%')"
               + " AND u not MEMBER OF workout.participants AND workout.id = :id ");
   query.setParameter("prefix", prefix);
   query.setParameter("id", id);
   return query.getResultList();
 }
Пример #2
0
 public void forgotPassword(final String email) throws UserNotFoundException, MailException {
   final Query query =
       entityManager.createQuery("select u from UserImpl u where u.email=:cryptedMail");
   query.setParameter("cryptedMail", CipherHelper.cipher(email));
   final List<UserImpl> list = query.getResultList();
   if (list.isEmpty()) throw new UserNotFoundException();
   for (final UserImpl user : list) {
     final String password = Helper.randomstring();
     user.setPassword(password);
     MailSender.forgotPasswordMail(user.getName(), password, email);
     entityManager.merge(user);
   }
 }
Пример #3
0
 public List<Track> fetchTracks() {
   final Query query = entityManager.createQuery("select t from TrackImpl t");
   return query.getResultList();
 }
Пример #4
0
 public List<Track> fetchTracks(final User user) {
   final Query query = entityManager.createQuery("select t from TrackImpl t where t.user =:user");
   query.setParameter("user", user);
   return query.getResultList();
 }
Пример #5
0
 private Query query(final String queryString) {
   return entityManager.createQuery(queryString);
 }