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.branded.holdings.qpc.repository.jpa.JpaVisitRepositoryImpl.java

@Override
@SuppressWarnings("unchecked")
public List<Visit> findByPetId(Integer petId) {
    Query query = this.em.createQuery("SELECT visit FROM Visit v where v.pets.id= :id");
    query.setParameter("id", petId);
    return query.getResultList();
}

From source file:com.expressui.sample.dao.AccountTypeDao.java

@Override
public List<AccountType> findAll() {
    Query query = getEntityManager().createQuery("SELECT a FROM AccountType a ORDER BY a.displayName");
    setReadOnly(query);/* ww  w.j a  va 2s  . c o  m*/

    return query.getResultList();
}

From source file:com.june.app.board.repository.jpa.BoardMasterRepositoryImpl.java

@Override
@Cacheable(value = "bbsMst")
@SuppressWarnings("unchecked")
public Collection<BoardMaster> boardMasterList() {
    Query query = this.em
            .createQuery("SELECT boardMaster FROM BoardMaster boardMaster WHERE boardMaster.useYn ='Y'");
    return query.getResultList();
}

From source file:org.syncope.core.persistence.dao.impl.SchemaDAOImpl.java

@Override
public <T extends AbstractSchema> List<T> findAll(final Class<T> reference) {

    Query query = entityManager.createQuery("SELECT e FROM " + reference.getSimpleName() + " e");

    return query.getResultList();
}

From source file:at.irian.demo.jsfatwork.repository.jpa.JpaUserRepository.java

public User loadUser(String userName) {
    Query query = this.entityManager.createNamedQuery(FIND_USER_BY_NAME);
    query.setParameter(PARAMETER_USER, userName);

    List result = query.getResultList(); //don't use getSingleResult()
    if (result != null && result.size() == 1) {
        return (User) result.iterator().next();
    }//w  w  w.  j  av  a2  s . c o m
    return null;
}

From source file:com.mvcmusic.mvcmusicstore.models.GenreModel.java

@SuppressWarnings("unchecked")
public Genre findGenreById(int passId) {
    List<Genre> genreList = new ArrayList<Genre>();

    try {/*from w  w w  .jav  a  2 s .c  o  m*/
        Query q = em.createNamedQuery("Genre.findByGenreid");
        q.setParameter("genreid", passId);
        genreList = q.getResultList();
    } catch (Exception e) {
        System.out.println("ERROR::: " + e);
    }

    return genreList.get(0);
}

From source file:com.tamnd.app.core.repositories.jpa.AccountRepoImpl.java

@Override
public Account findAccountByName(String name) {
    Query query = em.createQuery("SELECT a FROM Account a WHERE a.userName=?1");
    query.setParameter(1, name);/*w  w  w.  java 2s .  c  om*/
    List<Account> accounts = query.getResultList();
    if (accounts.isEmpty()) {
        return null;
    } else {
        return accounts.get(0);
    }
}

From source file:edu.mum.dao.impl.EventsDaoImpl.java

@Override
public List<Event> findEventsByUserId(int userId) {
    Query query = this.entityManager.createQuery("SELECT e from Event e where e.eventOwner.id =:id");
    query.setParameter("id", userId);
    return query.getResultList();
}

From source file:springchat.service.MessagesServiceImpl.java

@Override
public List<MessageEntity> getMessages() {
    return eao.withQuery("SELECT e FROM " + MessageEntity.class.getName() + " e",
            new BaseEAO.ExecutableQuery<List<MessageEntity>>() {
                @Override//from  w  ww.j  a  v  a  2  s  .com
                @SuppressWarnings("unchecked")
                public List<MessageEntity> execute(Query query) {
                    query.setMaxResults(MESSAGES_LIMIT);
                    return query.getResultList();
                }
            });
}

From source file:com.tamnd.app.core.repositories.jpa.AccountRoleRepoImpl.java

@Override
public AccountRole findAccountRoleByName(String roleName) {
    Query query = em.createQuery("SELECT a FROM AccountRole a WHERE a.roleName=?1");
    query.setParameter(1, roleName);/* w  w  w  . j a  va  2 s . co m*/
    List<AccountRole> list = query.getResultList();
    if (list.isEmpty()) {
        return null;
    } else {
        return list.get(0);
    }
}