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:io.hops.hopsworks.common.dao.jupyter.JupyterSettingsFacade.java

public List<JupyterSettings> findJupyterSettingsByProject(Integer projectId) {
    TypedQuery<JupyterSettings> query = em.createNamedQuery("JupyterSettings.findByProjectId",
            JupyterSettings.class);
    query.setParameter("projectId", projectId);
    return query.getResultList();
}

From source file:io.hops.hopsworks.common.dao.rstudio.RStudioSettingsFacade.java

public List<RStudioSettings> findJupyterSettingsByProject(Integer projectId) {
    TypedQuery<RStudioSettings> query = em.createNamedQuery("JupyterSettings.findByProjectId",
            RStudioSettings.class);
    query.setParameter("projectId", projectId);
    return query.getResultList();
}

From source file:com.siriusit.spezg.multilib.storage.jpa.JpaUnitRepository.java

@Override
public List<? extends Unit> findUnitsByOwner(Person owner) {
    TypedQuery<UnitDomainObject> query = entityManager.createNamedQuery("findUnitsByOwner",
            UnitDomainObject.class);
    query.setParameter("owner", owner);
    return query.getResultList();
}

From source file:com.siriusit.spezg.multilib.storage.jpa.JpaUnitRepository.java

@Override
public List<? extends Unit> findUnitsByTitle(String title) {
    TypedQuery<UnitDomainObject> query = entityManager.createNamedQuery("findUnitsByTitle",
            UnitDomainObject.class);
    query.setParameter("title", title);
    return query.getResultList();
}

From source file:org.cleverbus.core.common.dao.ExternalCallDaoJpaImpl.java

@Override
@Nullable/*  w w w .j a v a 2s.co  m*/
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public ExternalCall getExternalCall(String operationName, String entityId) {
    Assert.notNull(operationName, "operationName (uri) must not be null");
    Assert.notNull(entityId, "entityId (operation key) must not be null");

    String jSql = "SELECT c FROM " + ExternalCall.class.getName() + " c "
            + "WHERE c.operationName = ?1 AND c.entityId = ?2";
    TypedQuery<ExternalCall> q = em.createQuery(jSql, ExternalCall.class);
    q.setParameter(1, operationName);
    q.setParameter(2, entityId);

    List<ExternalCall> results = q.getResultList();
    if (results.isEmpty()) {
        return null;
    }

    if (results.size() > 1) {
        throw new MultipleDataFoundException(
                String.format("Multiple ExternalCall instances found for operationName/entityId: %s/%s",
                        operationName, entityId));
    }

    return results.get(0);
}

From source file:cz.muni.fi.dndtroops.dao.TroopDaoImpl.java

@Override
public Troop findTroopByName(String name) throws IllegalArgumentException {
    log.debug("findTroopByName({})", name);
    if (name == null) {
        throw new IllegalArgumentException("name is null");
    }/*from  w w w .j  a  va2 s  .  c  o m*/
    if (name.length() == 0) {
        throw new IllegalArgumentException("name is empty string");
    }
    try {
        TypedQuery<Troop> query = em.createQuery("SELECT t FROM Troop t WHERE t.name = :name", Troop.class);
        return query.setParameter("name", name).getSingleResult();
    } catch (NoResultException nre) {
        return null;
    }
}

From source file:org.openmeetings.app.data.basic.Navimanagement.java

public List<Naviglobal> getMainMenu(long user_level, long USER_ID) {
    try {/*from w ww  . j ava  2s  .  c om*/
        TypedQuery<Naviglobal> query = em.createNamedQuery("getNavigation", Naviglobal.class);
        query.setParameter("level_id", user_level);
        List<Naviglobal> navi = query.getResultList();
        return navi;
    } catch (Exception ex2) {
        log.error("getMainMenu", ex2);
    }
    return null;
}

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

@Override
public Collection<ApprovedSite> getByClientIdAndUserId(String clientId, String userId) {

    TypedQuery<ApprovedSite> query = manager.createNamedQuery(ApprovedSite.QUERY_BY_CLIENT_ID_AND_USER_ID,
            ApprovedSite.class);
    query.setParameter(ApprovedSite.PARAM_USER_ID, userId);
    query.setParameter(ApprovedSite.PARAM_CLIENT_ID, clientId);

    return query.getResultList();
}

From source file:org.mitre.uma.repository.impl.JpaPermissionRepository.java

@Override
public Collection<PermissionTicket> getPermissionTicketsForResourceSet(ResourceSet rs) {
    TypedQuery<PermissionTicket> query = em.createNamedQuery(PermissionTicket.QUERY_BY_RESOURCE_SET,
            PermissionTicket.class);
    query.setParameter(PermissionTicket.PARAM_RESOURCE_SET_ID, rs.getId());
    return query.getResultList();
}

From source file:org.openmeetings.app.data.basic.Navimanagement.java

public Naviglobal getGlobalMenuEntry(long globalId) {
    try {/*  ww w .  j  av  a2 s  .  c om*/
        TypedQuery<Naviglobal> query = em.createNamedQuery("getNavigationById", Naviglobal.class);
        query.setParameter("global_id", globalId);
        return query.getSingleResult();
    } catch (Exception ex2) {
        log.error("getGlobalMenuEntry", ex2);
    }
    return null;

}