List of usage examples for javax.persistence Query getSingleResult
Object getSingleResult();
From source file:com.grummages.app.rest.entity.service.PaymentRESTFacade.java
@GET @Path("count") @Produces("text/plain") @Transactional/*from w w w .ja v a 2s. c o m*/ public String count() { try { Query query = entityManager.createQuery("SELECT count(o) FROM Payment AS o"); return query.getSingleResult().toString(); } finally { entityManager.close(); } }
From source file:service.ItemRESTFacade.java
@GET @Path("count") @Produces(MediaType.TEXT_PLAIN)/*from ww w .j a v a 2 s .co m*/ @Transactional public String count() { try { Query query = entityManager.createQuery("SELECT count(o) FROM Item AS o"); return query.getSingleResult().toString(); } finally { entityManager.close(); } }
From source file:service.ResourceRESTFacade.java
@GET @Path("count") @Produces("text/plain") @Transactional/* ww w.ja va 2 s . c o m*/ public String count() { try { Query query = entityManager.createQuery("SELECT count(o) FROM Resource AS o"); return query.getSingleResult().toString(); } finally { entityManager.close(); } }
From source file:org.syncope.core.persistence.dao.impl.ReportDAOImpl.java
@Override public int count() { Query countQuery = entityManager.createNativeQuery("SELECT COUNT(id) FROM " + Report.class.getSimpleName()); return ((Number) countQuery.getSingleResult()).intValue(); }
From source file:com.grummages.app.rest.entity.service.CreditCardRESTFacade.java
@GET @Path("count") @Produces("text/plain") @Transactional//from ww w .j ava2s. com public String count() { try { Query query = entityManager.createQuery("SELECT count(o) FROM CreditCard AS o"); return query.getSingleResult().toString(); } finally { entityManager.close(); } }
From source file:org.spring.data.gemfire.app.dao.provider.JpaUserDao.java
public int count() { Query userCountQuery = entityManager.createNativeQuery(COUNT_USERS_SQL); return Integer.valueOf(String.valueOf(userCountQuery.getSingleResult())); }
From source file:com.grummages.app.rest.entity.service.AuthoritiesRESTFacade.java
@GET @Path("count") @Produces("text/plain") @Transactional/*from w w w.j ava2 s . c o m*/ public String count() { try { Query query = entityManager.createQuery("SELECT count(o) FROM Authorities AS o"); return query.getSingleResult().toString(); } finally { entityManager.close(); } }
From source file:uk.co.threeonefour.ifictionary.web.user.dao.JpaUserDao.java
@Transactional @Override/* w w w .ja v a 2 s . com*/ public User findUser(String userId) { String query = "SELECT u FROM User AS u WHERE userId=:userId"; EntityManager em = entityManager; Query q = em.createQuery(query.toString()); q.setParameter("userId", userId); try { return (User) q.getSingleResult(); } catch (NoResultException e) { return null; } }
From source file:com.healthcit.cacure.dao.QuestionTableDao.java
@Override public TableQuestion getById(Long id) { Query query = em.createQuery("from TableQuestion q where id = :Id"); query.setParameter("Id", id); return (TableQuestion) query.getSingleResult(); }
From source file:org.beeInvestment.repository.jpa.JpaRepositoryImpl.java
public T findById(int id) { Query query = this.em.createQuery(jpql + " WHERE item.id =:id"); query.setParameter("id", id); return (T) query.getSingleResult(); }