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:cz.fi.muni.pa036.airticketbooking.dao.impl.SeatReservationDaoImpl.java

@Override
public List<SeatReservation> getAll() {
    try {/*from w  ww  .j  a v a  2 s . c o m*/
        Query q = em.createQuery("FROM SeatReservation");
        List<SeatReservation> planes = q.getResultList();

        return Collections.unmodifiableList(planes);
    } catch (PersistenceException | IllegalArgumentException ex) {
        throw new DataAccessException(ex.getMessage(), ex) {
        };
    }
}

From source file:com.acmeair.jpa.service.BookingServiceImpl.java

@Override
public List<Booking> getBookingsByUser(String user) {
    Query q = em.createQuery("SELECT obj FROM Booking obj where obj.customer.id=?1");
    q.setParameter(1, user);/* w ww.j  a  va 2s . com*/

    List<Booking> results = (List<Booking>) q.getResultList();

    return results;
}

From source file:de.voolk.marbles.persistence.services.AuthentificationService.java

@Override
@SuppressWarnings("unchecked")
public List<User> findAllUsers() {
    Query query = entityManager.createNamedQuery("user:listAll");
    return query.getResultList();
}

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

public List<Comment> getAllComments(long experimentID) {
    Query query = manager.createQuery("from CommentImpl where experimentID=:expid");
    query.setParameter("expid", experimentID);
    return (List<Comment>) query.getResultList();
}

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

public List<Comment> getCommentsByParent(long commentID) {
    // TODO Move Entity declaration us so that we access Comments not CommenImpls?
    Query query = manager.createQuery("from CommentImpl where parentID=:parentid");
    query.setParameter("parentid", commentID);
    return (List<Comment>) query.getResultList();
}

From source file:com.thingtrack.konekti.dao.impl.internal.AreaDaoImpl.java

@SuppressWarnings("unchecked")
@Override/*from   w  w  w  .ja  v a 2 s .  c om*/
public List<Area> getAll(User user) throws Exception {
    String queryString = "SELECT p FROM " + getEntityName() + " p";

    if (user.getActiveLocation() != null)
        queryString += " WHERE p.location = :location";

    Query query = (Query) getEntityManager().createQuery(queryString);

    if (user.getActiveLocation() != null)
        query.setParameter("location", user.getActiveLocation());

    return query.getResultList();
}

From source file:gumga.framework.application.GumgaCrudAndQueryNotOnlyTypedRepositoryImpl.java

@Override
public List getResultList(String hql, Map<String, Object> param, int firstresult, int maxResult) {
    javax.persistence.Query query = entityManager.createQuery(hql);
    query.setMaxResults(maxResult);//from  w w w.ja va2  s. c  o m
    query.setFirstResult(firstresult);
    addParam(query, param);
    return query.getResultList();
}

From source file:org.opentides.dao.impl.UserGroupDaoJpaImpl.java

@SuppressWarnings("unchecked")
@Override//  w w  w  .ja  v  a 2  s  . c  o  m
public List<UserGroup> getOldDefaultUserGroups(Long... groupIds) {
    String queryString = getJpqlQuery("jpql.usergroup.findOldDefault");
    Query query = getEntityManager().createQuery(queryString);
    query.setParameter("groupIds", Arrays.asList(groupIds));

    return query.getResultList();
}

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

@SuppressWarnings("unchecked")
public Role findByName(String roleName) {
    Query query = entityManager.createQuery("SELECT r FROM RoleEntity r WHERE r.name = :roleName")
            .setParameter("roleName", roleName);
    List<Role> resultList = query.getResultList();

    if (resultList.size() == 0) {
        return null;
    } else if (resultList.size() == 1) {
        return resultList.get(0);
    }/*from  w  ww.j a  va 2 s .com*/

    throw new IllegalStateException("Multiple roles found for rolename: '" + roleName + "'");
}

From source file:br.org.indt.ndg.server.language.LanguageManagerBean.java

@Override
public HashMap<String, String> getLanguageList() {
    Query q = manager.createNamedQuery("languages.getLanguageList");

    HashMap<String, String> list = new HashMap<String, String>();

    List<Language> listOfLanguages = q.getResultList();

    for (Language language : listOfLanguages) {
        list.put(language.getName(), language.getLocaleString());
    }// w w  w  .  j a va 2  s .  c o m

    return list;
}