Example usage for javax.persistence TypedQuery getResultList

List of usage examples for javax.persistence TypedQuery getResultList

Introduction

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

Prototype

List<X> getResultList();

Source Link

Document

Execute a SELECT query and return the query results as a typed List.

Usage

From source file:io.github.todolist.core.repository.impl.UserRepositoryImpl.java

/**
 * {@inheritDoc}//  w  ww. j  a v  a  2 s .  co m
 */
public User getUserByEmail(final String email) {
    TypedQuery<User> query = entityManager.createNamedQuery("findUserByEmail", User.class);
    query.setParameter("p_email", email);
    List<User> users = query.getResultList();
    return (users != null && !users.isEmpty()) ? users.get(0) : null;
}

From source file:org.mitre.uma.service.impl.JpaRegisteredClientService.java

/**
 * @return/*from  ww  w  . j  a  v a 2 s .  com*/
 */
public Collection<SavedRegisteredClient> getAll() {
    TypedQuery<SavedRegisteredClient> query = em.createQuery("SELECT c from SavedRegisteredClient c",
            SavedRegisteredClient.class);
    return query.getResultList();
}

From source file:org.openmeetings.app.data.basic.dao.OmTimeZoneDaoImpl.java

public List<OmTimeZone> getOmTimeZones() {
    try {// w  w w  . j ava 2s . c  o  m
        String hql = "select sl from OmTimeZone as sl " + "ORDER BY sl.orderId";

        TypedQuery<OmTimeZone> query = em.createQuery(hql, OmTimeZone.class);
        List<OmTimeZone> sList = query.getResultList();

        for (OmTimeZone omTimeZone : sList) {
            omTimeZone.setFrontEndLabel(omTimeZone.getJname() + " (" + omTimeZone.getLabel() + ")");
        }

        return sList;

    } catch (Exception ex2) {
        log.error("[getOmTimeZones]: ", ex2);
    }
    return null;
}

From source file:com.pingdu.dao.licenseDao.LicenseDao.java

public List<License> getAllLicenseList() {
    String jpql = "select lic from License lic where 1=1";
    TypedQuery<License> query = em().createQuery(jpql, License.class);

    return query.getResultList();
}

From source file:com.tpg.tmjug.springdata.demo.jpa.repository.JpaCustomerDAOImpl.java

@Override
public List<Customer> findByAddress(Address address) {

    TypedQuery<Customer> query = em.createQuery("select c from Customer c where c.address = :address",
            Customer.class);
    query.setParameter("address", address);

    return query.getResultList();
}

From source file:org.mitre.oauth2.repository.impl.JpaAuthenticationHolderRepository.java

@Override
public List<AuthenticationHolderEntity> getAll() {
    TypedQuery<AuthenticationHolderEntity> query = manager
            .createNamedQuery(AuthenticationHolderEntity.QUERY_ALL, AuthenticationHolderEntity.class);
    return query.getResultList();
}

From source file:org.mitre.oauth2.repository.impl.JpaOAuth2ClientRepository.java

@Override
public Collection<ClientDetailsEntity> getAllClients() {
    TypedQuery<ClientDetailsEntity> query = manager.createNamedQuery(ClientDetailsEntity.QUERY_ALL,
            ClientDetailsEntity.class);
    return query.getResultList();
}

From source file:com.ewcms.content.particular.dao.FrontEnterpriseBasicDAO.java

public List<EnterpriseBasic> findEnterpriseBasicBySector(Long organId) {
    String hql = "From EnterpriseBasic As p where p.organ.id=:organId and p.release=true Order By p.published desc ";
    TypedQuery<EnterpriseBasic> query = this.getEntityManager().createQuery(hql, EnterpriseBasic.class);
    query.setParameter("organId", Integer.valueOf(organId.toString()));
    return query.getResultList();
}

From source file:fr.univrouen.poste.web.ForgotPasswordController.java

@RequestMapping(value = "/forgotpassword/formChange", method = RequestMethod.GET)
public String modifyPasswordFormWithActivationKey(@RequestParam String activationKey, Model model) {
    TypedQuery<User> userQuery = User.findUsersByActivationKey(activationKey);
    if (null != userQuery && !userQuery.getResultList().isEmpty()) {
        ForgotChangePasswordForm changePasswordForm = new ForgotChangePasswordForm();
        changePasswordForm.setActivationKey(activationKey);
        model.addAttribute("changePasswordForm", changePasswordForm);
        return "forgotpassword/formChange";
    }//from  w  w w  . j a  v a  2s.c o m
    return "redirect:/";
}

From source file:com.ewcms.content.particular.dao.FrontProjectBasicDAO.java

public List<ProjectBasic> findProjectBasicBySector(Long organId) {
    String hql = "From ProjectBasic As p where p.organ.id=:organId and p.release=true Order By p.published desc ";
    TypedQuery<ProjectBasic> query = this.getEntityManager().createQuery(hql, ProjectBasic.class);
    query.setParameter("organId", Integer.valueOf(organId.toString()));
    return query.getResultList();
}