Example usage for javax.persistence TypedQuery setParameter

List of usage examples for javax.persistence TypedQuery setParameter

Introduction

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

Prototype

TypedQuery<X> setParameter(int position, Object value);

Source Link

Document

Bind an argument value to a positional parameter.

Usage

From source file:com.plan.proyecto.repositorios.DaoCuentaImpl.java

@Override
public List<Cuenta> findByNombre(String nombre) {
    TypedQuery<Cuenta> query = em.createNamedQuery("Cuenta.findByNombre", Cuenta.class);
    query.setParameter("valor", nombre);
    List<Cuenta> results = query.getResultList();
    return results;
}

From source file:com.plan.proyecto.repositorios.DaoCuentaImpl.java

@Override
public Boolean sonAmigos(Cuenta origen, Cuenta amigo) {
    TypedQuery<Cuenta> query = em.createNamedQuery("Cuenta.findAmigos", Cuenta.class);
    query.setParameter("idorigen", origen.getId());
    query.setParameter("idamigo", amigo);

    List<Cuenta> temp = query.getResultList();
    return !query.getResultList().isEmpty();
}

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

@Override
@Transactional(value = "defaultTransactionManager")
public SystemScope getByValue(String value) {
    TypedQuery<SystemScope> query = em.createNamedQuery(SystemScope.QUERY_BY_VALUE, SystemScope.class);
    query.setParameter(SystemScope.PARAM_VALUE, value);
    return getSingleResult(query.getResultList());
}

From source file:org.openmeetings.app.data.flvrecord.FlvRecordingMetaDeltaDaoImpl.java

public List<FlvRecordingMetaDelta> getFlvRecordingMetaDeltaByMetaId(Long flvRecordingMetaDataId) {
    try {//from   www . ja  v  a  2  s.  c o  m

        String hql = "SELECT c FROM FlvRecordingMetaDelta c "
                + "WHERE c.flvRecordingMetaDataId = :flvRecordingMetaDataId";

        TypedQuery<FlvRecordingMetaDelta> query = em.createQuery(hql, FlvRecordingMetaDelta.class);
        query.setParameter("flvRecordingMetaDataId", flvRecordingMetaDataId);

        List<FlvRecordingMetaDelta> flvRecordingMetaDeltas = query.getResultList();

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

From source file:org.openmeetings.app.data.user.dao.UserSipDataDaoImpl.java

public UserSipData getUserSipDataById(Long userSipDataId) {
    try {//from   ww  w .  java 2s.  c om

        if (userSipDataId == null) {
            return null;
        }

        String hql = "select c from UserSipData as c where c.userSipDataId = :userSipDataId";

        TypedQuery<UserSipData> query = em.createQuery(hql, UserSipData.class);
        query.setParameter("userSipDataId", userSipDataId);
        UserSipData userSipData = null;
        try {
            userSipData = query.getSingleResult();
        } catch (NoResultException ex) {
        }

        return userSipData;
    } catch (Exception ex2) {
        log.error("getUserSipDataById", ex2);
    }
    return null;
}

From source file:aka.pirana.springsecurity.dao.JpaUserDaoImpl.java

@Override
public User login(String email, String password) {
    System.out.println("aka.pirana.springsecurity.dao.JpaUserDaoImpl.login(" + email + "," + password + ")");
    TypedQuery<User> query = em.createQuery("select u from users u where u.email=?1 and u.password=?2",
            User.class);
    query.setParameter(1, email);
    query.setParameter(2, password);/*from ww w.ja  v  a  2s.c  om*/
    try {
        return query.getSingleResult();
    } catch (NonUniqueResultException | NoResultException e) {
        return null;
    }

}

From source file:com.plan.proyecto.repositorios.DaoCuentaImpl.java

@Override
public Cuenta findByEmail(String email) {
    TypedQuery<Cuenta> query = em.createNamedQuery("Cuenta.findByEmail", Cuenta.class);
    query.setParameter("valor", email);
    List<Cuenta> lista = query.getResultList();
    if (lista.isEmpty()) {
        return null;
    }/* w w  w. j av  a 2s .  c  o m*/
    return lista.get(0);
}

From source file:org.mitre.openid.connect.repository.impl.JpaUserInfoRepository.java

/**
 * Get a single UserInfo object by its email address
 */// www.  j  a v a 2s  . co m
@Override
public UserInfo getByEmailAddress(String email) {
    TypedQuery<DefaultUserInfo> query = manager.createNamedQuery(DefaultUserInfo.QUERY_BY_EMAIL,
            DefaultUserInfo.class);
    query.setParameter(DefaultUserInfo.PARAM_EMAIL, email);

    return getSingleResult(query.getResultList());
}

From source file:com.deltastar.task7.core.repository.api.impl.PositionRepositoryImpl.java

@Override
public List<Position> getPositionListByCustomerId(int customerId) {
    TypedQuery<Position> query = entityManager.createNamedQuery("findPositionByCustomerId", Position.class);
    query.setParameter("p_customerId", customerId);

    return query.getResultList();
}

From source file:com.home.ln_spring.ch10.service.jpa.ContactServiceImplOld.java

@Override
@Transactional(readOnly = true)/*from  w  w w  . j a v  a 2 s.c o m*/
public Contact findById(Long id) {
    TypedQuery<Contact> query = em.createNamedQuery("Contact.findById", Contact.class);
    query.setParameter("id", id);
    return query.getSingleResult();
}