List of usage examples for javax.persistence Query getSingleResult
Object getSingleResult();
From source file:com.june.app.site.repository.jpa.VideoRepositoryImpl.java
@Override public Video videoMain() { String queryString = "SELECT video FROM Video video WHERE video.useYn ='Y' ORDER BY video.regiDate desc"; Query query = this.em.createQuery(queryString); query.setMaxResults(1);//from w ww . j a va2 s. c o m return (Video) query.getSingleResult(); }
From source file:com.grummages.app.rest.entity.service.AddonRESTFacade.java
@GET @Path("count") @Produces("text/plain") @Transactional// ww w .j a v a 2 s . c o m public String count() { try { Query query = entityManager.createQuery("SELECT count(o) FROM Addon AS o"); return query.getSingleResult().toString(); } finally { entityManager.close(); } }
From source file:com.healthcit.cacure.dao.UserManagerDao.java
@Transactional(readOnly = true) public UserCredentials findByName(String uName) { Query query = this.em.createQuery("from UserCredentials where username = :uName"); query.setParameter("uName", uName); return (UserCredentials) query.getSingleResult(); }
From source file:org.jboss.spring.quickstarts.greeter.greeter_spring.domain.UserDaoImpl.java
@Transactional public User getForUsername(String username) { try {/*from ww w . j av a 2 s . c om*/ Query query = entityManager.createQuery("select u from User u where u.username = ?"); query.setParameter(1, username); return (User) query.getSingleResult(); } catch (NoResultException e) { return null; } }
From source file:de.inetsource.jsfforum.db.PostFacade.java
public int count(Thread thread) { Query q = em.createQuery("Select count(p.id) from Post p where p.threadId = :thread"); q.setParameter("thread", thread); return ((Long) q.getSingleResult()).intValue(); }
From source file:de.inetsource.jsfforum.db.ThreadFacade.java
public int countThreadsByForum(Forum forumId) { String SQL = "SELECT count(thread) FROM Thread thread WHERE thread.forumId = :forumId"; javax.persistence.Query q = getEntityManager().createQuery(SQL); q.setParameter("forumId", forumId); return ((Long) q.getSingleResult()).intValue(); }
From source file:com.grummages.app.rest.entity.service.UsersRESTFacade.java
@GET @Path("count") @Produces("text/plain") @Transactional/*from w ww .j a v a 2 s. c om*/ public String count() { try { Query query = entityManager.createQuery("SELECT count(o) FROM Users AS o"); return query.getSingleResult().toString(); } finally { entityManager.close(); } }
From source file:org.opentides.dao.impl.UserGroupDaoJpaImpl.java
@Override public UserGroup getDefaultUserGroup() { String queryString = getJpqlQuery("jpql.usergroup.findDefault"); Query query = getEntityManager().createQuery(queryString); return (UserGroup) query.getSingleResult(); }
From source file:com.grummages.app.rest.entity.service.AddressRESTFacade.java
@GET @Path("count") @Produces("text/plain") @Transactional//from w ww . j a va 2s . c o m public String count() { try { Query query = entityManager.createQuery("SELECT count(o) FROM Address AS o"); return query.getSingleResult().toString(); } finally { entityManager.close(); } }
From source file:com.grummages.app.rest.entity.service.ListingRESTFacade.java
@GET @Path("count") @Produces("text/plain") @Transactional/*from w w w . j a v a 2s .c o m*/ public String count() { try { Query query = entityManager.createQuery("SELECT count(o) FROM Listing AS o"); return query.getSingleResult().toString(); } finally { entityManager.close(); } }