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:org.openmeetings.app.data.user.Emailmanagement.java

/**
 * Checks if a mail is already taken by someone else
 * //w  w w  . j  a  v  a  2s. co  m
 * @param email
 * @return
 */
public boolean checkUserEMail(String email) {
    try {
        if (email.length() == 0)
            return true;
        log.debug("checkUserMail: " + email);
        TypedQuery<Adresses> query = em.createQuery(
                "select c from Adresses as c where c.email LIKE :email AND c.deleted <> :deleted",
                Adresses.class);
        query.setParameter("email", email);
        query.setParameter("deleted", "true");
        int count = query.getResultList().size();
        log.debug("size: " + count);

        if (count > 0) {
            return false;
        }
    } catch (Exception ex2) {
        log.error("checkUserEMail: ", ex2);
    }
    return true;
}

From source file:com.music.dao.UserDao.java

public List<SocialAuthentication> getSocialAuthentications(String providerId, String providerUserId) {
    TypedQuery<SocialAuthentication> query = getEntityManager().createQuery(
            "SELECT sa FROM SocialAuthentication sa WHERE sa.providerId=:providerId AND sa.providerUserId=:providerUserId",
            SocialAuthentication.class);
    query.setParameter("providerId", providerId);
    query.setParameter("providerUserId", providerUserId);

    List<SocialAuthentication> auths = query.getResultList();
    return auths;
}

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

public List<FlvRecordingMetaData> getFlvRecordingMetaDataByRecording(Long flvRecordingId) {
    try {/*from  w w w.j  a  v a 2 s.c o m*/

        String hql = "SELECT c FROM FlvRecordingMetaData c "
                + "WHERE c.flvRecording.flvRecordingId = :flvRecordingId " + "AND c.deleted <> :deleted ";

        TypedQuery<FlvRecordingMetaData> query = em.createQuery(hql, FlvRecordingMetaData.class);
        query.setParameter("flvRecordingId", flvRecordingId);
        query.setParameter("deleted", "true");

        List<FlvRecordingMetaData> flvRecordingMetaDatas = query.getResultList();

        return flvRecordingMetaDatas;

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

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

public List<FlvRecordingMetaData> getFlvRecordingMetaDataAudioFlvsByRecording(Long flvRecordingId) {
    try {/*from   ww  w  .  j ava  2 s  . c  o m*/

        String hql = "SELECT c FROM FlvRecordingMetaData c "
                + "WHERE c.flvRecording.flvRecordingId = :flvRecordingId " + "AND ("
                + "(c.isScreenData = false) " + " AND "
                + "(c.isAudioOnly = true OR (c.isAudioOnly = false AND c.isVideoOnly = false))" + ")";

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

        List<FlvRecordingMetaData> flvRecordingMetaDatas = query.getResultList();

        return flvRecordingMetaDatas;

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

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

public FlvRecordingMetaData getFlvRecordingMetaDataScreenFlvByRecording(Long flvRecordingId) {
    try {/* w w w . j  a v a 2s  . c  o m*/

        String hql = "SELECT c FROM FlvRecordingMetaData c "
                + "WHERE c.flvRecording.flvRecordingId = :flvRecordingId " + "AND c.isScreenData = true";

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

        List<FlvRecordingMetaData> flvRecordingMetaDatas = query.getResultList();

        if (flvRecordingMetaDatas.size() > 0) {
            return flvRecordingMetaDatas.get(0);
        }

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

From source file:eu.domibus.common.dao.MessageLogDao.java

public MessageStatus getMessageStatus(final String messageId) {

    final TypedQuery<MessageStatus> query = this.em.createNamedQuery("MessageLogEntry.getMessageStatus",
            MessageStatus.class);
    query.setParameter("MESSAGE_ID", messageId);
    try {//from w  w w  . ja v a 2 s.  c om
        return query.getSingleResult();
    } catch (NoResultException e) {
        return MessageStatus.MESSAGE_NOT_FOUND;
    }
}

From source file:eu.domibus.common.dao.MessageLogDao.java

public List<String> getDownloadedUserMessagesOlderThan(Date date, String mpc) {
    final TypedQuery<String> query = em.createNamedQuery("MessageLogEntry.findDownloadedUserMessagesOlderThan",
            String.class);
    query.setParameter("DATE", date);
    query.setParameter("MPC", mpc);
    try {/*from   w  ww.  jav  a2  s  .  c  o  m*/
        return query.getResultList();
    } catch (NoResultException e) {
        return Collections.EMPTY_LIST;
    }
}

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

public FlvRecordingMetaData getFlvRecordingMetaDataById(Long flvRecordingMetaDataId) {
    try {/*from w w  w. j a v a2s  .c  om*/

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

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

        FlvRecordingMetaData flvRecordingMetaData = null;
        try {
            flvRecordingMetaData = query.getSingleResult();
        } catch (NoResultException ex) {
        }

        return flvRecordingMetaData;

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

From source file:ro.allevo.fintpws.model.UserEntity.java

@Override
public Collection<? extends GrantedAuthority> getAuthorities() {

    EntityManagerFactory configEntityManagerFactory = Persistence.createEntityManagerFactory("fintpCFG");
    EntityManager emc = configEntityManagerFactory.createEntityManager();

    TypedQuery<RoleEntity> query = emc.createNamedQuery("RoleEntity.findUserAuthorities", RoleEntity.class);
    List<RoleEntity> authorities = query.setParameter("userid", userid).getResultList();
    return authorities;
}

From source file:eu.europa.ec.fisheries.uvms.exchange.dao.bean.ExchangeLogDaoBean.java

@Override
public List<ExchangeLog> getExchangeLogByRangeOfRefGuids(List<String> logGuids) {
    if (CollectionUtils.isEmpty(logGuids)) {
        return new ArrayList<>();
    }/*from  www.  j  a v a 2s . c o  m*/
    TypedQuery<ExchangeLog> query = em.createNamedQuery(ExchangeConstants.LOG_BY_TYPE_RANGE_OF_REF_GUIDS,
            ExchangeLog.class);
    query.setParameter("refGuids", logGuids);
    return query.getResultList();
}