Example usage for javax.persistence Query getResultList

List of usage examples for javax.persistence Query getResultList

Introduction

In this page you can find the example usage for javax.persistence Query getResultList.

Prototype

List getResultList();

Source Link

Document

Execute a SELECT query and return the query results as an untyped List.

Usage

From source file:com.june.app.site.repository.jpa.VideoRepositoryImpl.java

@SuppressWarnings("unchecked")
@Override//from  w  w  w .ja  v a2s .c o  m
public Collection<Video> videoListWithPaging(Video vo) {

    int pageSize = vo.getPageSize();
    int pageNumber = (int) vo.getPageIndex();

    String queryString = "SELECT video FROM Video video WHERE video.useYn ='Y' ORDER BY video.regiDate desc";
    Query query = this.em.createQuery(queryString);
    query.setFirstResult((pageNumber - 1) * pageSize);
    query.setMaxResults(pageSize);

    return query.getResultList();
}

From source file:org.simbasecurity.core.domain.repository.SessionDatabaseRepository.java

@SuppressWarnings("unchecked")
@Override/*from   ww  w.j a  v  a2 s . c  o  m*/
public Session findBySSOToken(SSOToken ssoToken) {
    Query query = entityManager.createQuery("SELECT s FROM SessionEntity s WHERE s.ssoToken = :ssoToken")
            .setParameter("ssoToken", ssoToken.getToken());
    List<Session> resultList = query.getResultList();

    if (resultList.size() == 0) {
        return null;
    } else if (resultList.size() == 1) {
        return resultList.get(0);
    }

    throw new IllegalStateException("Multiple sessions found for token: '" + ssoToken + "'");

}

From source file:com.mothsoft.alexis.dao.RssFeedDaoImpl.java

public RssFeed findByUrl(String url) {
    final Query query = this.em.createQuery("FROM RssFeed WHERE url = :url");
    query.setParameter("url", url);

    @SuppressWarnings("unchecked")
    final List<RssFeed> results = query.getResultList();

    if (results.size() == 1) {
        return results.get(0);
    }// www.  j a v a  2 s  .  c  o  m

    return null;
}

From source file:net.chrissearle.flickrvote.dao.JpaChallengeDao.java

/**
 * Method getAll returns all challenges.
 *
 * @return all challenges.//ww  w  .  j a va  2 s .co m
 */
@SuppressWarnings("unchecked")
public List<Challenge> getAll() {
    Query query = entityManager.createQuery("select c from Challenge c");
    return (List<Challenge>) query.getResultList();
}

From source file:org.zkforge.zktodo2.BasicDao.java

/**
 * Retrieves a non-paged query//from ww w  .j  a  v a  2s.  co m
 */
@SuppressWarnings("unchecked")
public <T> List<T> findNamedQuery(final String namedQuery, Object... params) {
    Query query = entityManager.createNamedQuery(namedQuery);
    setParameters(query, params);
    return query.getResultList();
}

From source file:Department.java

  public Collection<Department> findAllDepartments() {
  Query query = em.createQuery("SELECT d FROM Department d");
  return (Collection<Department>) query.getResultList();
}

From source file:com.brienwheeler.svc.users.impl.UserEmailAddressDao.java

@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
@SuppressWarnings("unchecked")
public List<UserEmailAddress> findByUser(User user) {
    Query query = entityManager
            .createQuery("from UserEmailAddress where user = :user order by emailAddress.address");
    query.setParameter("user", user);
    return (List<UserEmailAddress>) query.getResultList();
}

From source file:com.impetus.kundera.graphbrowser.service.IMDBService.java

public void findActorByName() {
    Query query = em.createQuery("select a from Actor a where a.name=:name");
    query.setParameter("name", "Tom Cruise");
    List<Actor> actors = query.getResultList();
    System.out.println(actors);/*w  ww . j  ava2s  .  c o  m*/
}

From source file:com.tapas.evidence.repository.KindergartenRepositoryImpl.java

@Override
@SuppressWarnings("unchecked")
public List<Kindergarten> findAll() {
    final Long tenantId = ((EvidenceUserDetails) SecurityContextHolder.getContext().getAuthentication()
            .getPrincipal()).getTenantId();
    Query query = this.entityManager.createNamedQuery(Kindergarten.QUERY_NAME_FIND_ALL_BY_DELETED_FLAG);
    query.setParameter("deleted", Boolean.FALSE);
    query.setParameter("tenantId", tenantId);
    return query.getResultList();
}

From source file:org.kuali.mobility.push.dao.PushMessageDaoImpl.java

@SuppressWarnings("unchecked")
public List<PushMessage> findAllPushMessagesByLanguage(String language) {
    Query query = entityManager.createNamedQuery("PushMessage.findByLanguage");
    query.setParameter("language", language);
    return query.getResultList();
}