use of javax.persistence.NoResultException in project webpieces by deanhiller.
the class UserDbo method findWithJoin.
public static UserDbo findWithJoin(EntityManager mgr, int id) {
Query query = mgr.createNamedQuery("findByIdWithRoleJoin");
query.setParameter("id", id);
try {
return (UserDbo) query.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
use of javax.persistence.NoResultException in project cas by apereo.
the class GoogleAuthenticatorMongoDbTokenRepository method get.
@Override
public GoogleAuthenticatorToken get(final String uid, final Integer otp) {
try {
final Query query = new Query();
query.addCriteria(Criteria.where("userId").is(uid).and("token").is(otp));
final GoogleAuthenticatorToken r = this.mongoTemplate.findOne(query, GoogleAuthenticatorToken.class, this.collectionName);
return r;
} catch (final NoResultException e) {
LOGGER.debug("No record could be found for google authenticator id [{}]", uid);
}
return null;
}
use of javax.persistence.NoResultException in project cas by apereo.
the class MongoDbGoogleAuthenticatorTokenCredentialRepository method get.
@Override
public OneTimeTokenAccount get(final String username) {
try {
final Query query = new Query();
query.addCriteria(Criteria.where("username").is(username));
final GoogleAuthenticatorAccount r = this.mongoTemplate.findOne(query, GoogleAuthenticatorAccount.class, this.collectionName);
if (r != null) {
return decode(r);
}
} catch (final NoResultException e) {
LOGGER.debug("No record could be found for google authenticator id [{}]", username);
}
return null;
}
use of javax.persistence.NoResultException in project quickstart by wildfly.
the class EJBUserDao method getForUsername.
@Override
public User getForUsername(String username) {
try {
Query query = entityManager.createQuery("select u from User u where u.username = :username");
query.setParameter("username", username);
return (User) query.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
use of javax.persistence.NoResultException in project quickstart by wildfly.
the class ManagedBeanUserDao method getForUsername.
public User getForUsername(String username) {
try {
User user;
try {
utx.begin();
Query query = entityManager.createQuery("select u from User u where u.username = :username");
query.setParameter("username", username);
user = (User) query.getSingleResult();
} catch (NoResultException e) {
user = null;
}
utx.commit();
return user;
} catch (Exception e) {
try {
utx.rollback();
} catch (SystemException se) {
throw new RuntimeException(se);
}
throw new RuntimeException(e);
}
}
Aggregations