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:org.simbasecurity.core.domain.repository.GroupDatabaseRepository.java

@SuppressWarnings("unchecked")
@Override// w  w  w  . j a v  a2  s  . c  om
public Group findByCN(String cn) {
    Query query = entityManager.createQuery("SELECT g FROM GroupEntity g WHERE g.cn = :cn").setParameter("cn",
            cn);
    List<Group> resultList = query.getResultList();

    if (resultList.size() == 0) {
        return null;
    } else if (resultList.size() == 1) {
        return resultList.get(0);
    }
    throw new IllegalStateException("Multiple users found for username: '" + cn + "'");
}

From source file:be.fedict.trust.service.dao.bean.AdministratorDAOBean.java

/**
 * {@inheritDoc}//w ww .jav  a2  s.  c  om
 */
@SuppressWarnings("unchecked")
public List<AdministratorEntity> listAdmins() {

    LOG.debug("list admins");
    Query query = this.entityManager.createNamedQuery(AdministratorEntity.QUERY_LIST_ALL);
    return (List<AdministratorEntity>) query.getResultList();
}

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

@Override
public List<EventRegister> getNotSelectedEventRegisterByEventId(int eventId) {
    Query query = this.entityManager
            .createQuery("SELECT er from EventRegister er where er.event.id=:id and er.user=null");
    query.setParameter("id", eventId);
    return query.getResultList();
}

From source file:eu.planets_project.tb.impl.persistency.ServiceRecordPersistencyImpl.java

@SuppressWarnings("unchecked")
public List<ServiceRecordImpl> getAllServiceRecords() {
    Query query = manager.createQuery("from ServiceRecordImpl");
    return (List<ServiceRecordImpl>) query.getResultList();
}

From source file:com.exp.tracker.services.impl.GroupServiceImpl.java

@Override
@Transactional(readOnly = true)/*from   ww w.  j a va2  s.c o  m*/
public Collection<GroupBean> getGroups() {
    List<GroupBean> groupList = new ArrayList<GroupBean>();
    Query queryGetAllGroups = em.createNamedQuery("getAllGroups");
    @SuppressWarnings("unchecked")
    List<GroupEntity> gl = queryGetAllGroups.getResultList();
    for (GroupEntity ge : gl) {
        groupList.add(new GroupBean(ge));
    }
    return groupList;
}

From source file:com.sct.descubriendoturuta.service.InsigniaServiceImpl.java

@Override
@Transactional//from w w w  .j av  a  2 s . c om
public List<Insignia> obtenerInsignias(int usuarioId) {

    Query query = em.createQuery("select i from Insignia i Where i.usuarioId");
    query.setParameter("p", usuarioId);

    return query.getResultList();
}

From source file:com.srinathavan.mwbng.core.repositories.jpa.JpaAccountRepo.java

@Override
public Account findAccountByName(String name) {
    Query query = em.createQuery("select a from Account a where a.username=?");
    query.setParameter(0, name);/*from w w w.ja v  a 2s  .  com*/
    List<Account> accounts = query.getResultList();
    if (accounts.size() == 0) {
        return null;
    }
    return accounts.get(0);
}

From source file:com.impetus.client.oraclenosql.OracleNoSQLTestBase.java

protected List executeNamedQuery(String namedQuery, Map<Object, Object> params) {
    Query query = em.createNamedQuery(namedQuery);
    setParams(params, query);//from   ww  w  .ja  v  a  2  s .co m
    return query.getResultList();
}

From source file:de.berlios.jhelpdesk.dao.jpa.TicketDAOJpa.java

public List<Ticket> getTicketsWithFilter(final TicketFilter filter) {
    return (List<Ticket>) this.jpaTemplate.execute(new JpaCallback() {
        public Object doInJpa(EntityManager em) throws PersistenceException {
            Query q = new QueryBuilder(filter, em).getFilteredQuery(false);
            return q.getResultList();
        }//from www.  j a va  2s  .  c om
    });
}

From source file:modelo.dao.GestionProductosImpl.java

@Override
public List<Producto> obtenerProductosCategoria(int user, int categoria) {
    Query q = em.createNamedQuery("Producto.findByUserSubcategoria");
    q.setParameter(1, user);//from  w  w w  .j  a va 2 s . co m
    q.setParameter(2, categoria);

    return q.getResultList();
}