當前位置: 首頁>>代碼示例>>Java>>正文


Java TypedQuery.getResultList方法代碼示例

本文整理匯總了Java中javax.persistence.TypedQuery.getResultList方法的典型用法代碼示例。如果您正苦於以下問題:Java TypedQuery.getResultList方法的具體用法?Java TypedQuery.getResultList怎麽用?Java TypedQuery.getResultList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.persistence.TypedQuery的用法示例。


在下文中一共展示了TypedQuery.getResultList方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: searchForUser

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
@Override
public List<UserModel> searchForUser(String search, RealmModel realm, int firstResult, int maxResults) {
	TypedQuery<UserEntity> query = em.createNamedQuery("searchForUser", UserEntity.class);
	query.setParameter("search", "%" + search.toLowerCase() + "%");
	if (firstResult != -1) {
		query.setFirstResult(firstResult);
	}
	if (maxResults != -1) {
		query.setMaxResults(maxResults);
	}
	List<UserEntity> results = query.getResultList();
	List<UserModel> users = new LinkedList<>();
	for (UserEntity entity : results)
		users.add(new UserAdapter(session, realm, model, entity));
	return users;
}
 
開發者ID:allianzit,項目名稱:ait-platform,代碼行數:17,代碼來源:AitEjbUserStorageProvider.java

示例2: loadAuditLogs

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
/**
 * load auditLogs by operationIds and date range, if operationIds is null or
 * empty, load auditLogs only by date range
 * 
 * @param operationIds
 * @param startTime
 * @param endTime
 * @return
 */
public List<AuditLog> loadAuditLogs(List<String> operationIds,
        long startTime, long endTime) {
    TypedQuery<AuditLog> query;
    if (operationIds == null || operationIds.isEmpty()) {
        query = em.createNamedQuery("AuditLog.findByDateRange",
                AuditLog.class);
    } else {
        query = em.createNamedQuery("AuditLog.findByOperationAndDateRange",
                AuditLog.class);
        query.setParameter("operationIds", operationIds);
    }
    query.setParameter("startTime", Long.valueOf(startTime));
    query.setParameter("endTime", Long.valueOf(endTime));
    return query.getResultList();
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:25,代碼來源:AuditLogDao.java

示例3: getPlayersByPositionAndName

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
public List<PlayerDetails> getPlayersByPositionAndName(String position, String name) {
    logger.info("getPlayersByPositionAndName");
    List<Player> players = null;

    try {
        CriteriaQuery<Player> cq = cb.createQuery(Player.class);
        if (cq != null) {
            Root<Player> player = cq.from(Player.class);

            // Get MetaModel from Root
            //EntityType<Player> Player_ = player.getModel();

            // set the where clause
            cq.where(cb.equal(player.get(Player_.position), position),
                    cb.equal(player.get(Player_.name), name));
            cq.select(player).distinct(true);
            TypedQuery<Player> q = em.createQuery(cq);
            players = q.getResultList();
        }
        return copyPlayersToDetails(players);
    } catch (Exception ex) {
        throw new EJBException(ex);
    }
}
 
開發者ID:wwu-pi,項目名稱:tap17-muggl-javaee,代碼行數:25,代碼來源:RequestBean.java

示例4: getStatusByGuardianId

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
@GET
@Path("id/{guardianId}")
@Produces({"application/xml", "application/json"})
public List<Student> getStatusByGuardianId(@PathParam("guardianId") Long id) {
    logger.log(Level.INFO, "Principal is: {0}", ctx.getCallerPrincipal().getName());
    CriteriaQuery<Student> cq = cb.createQuery(Student.class);
    Root<Student> student = cq.from(Student.class);
    Join<Student, Guardian> guardian = student.join(Student_.guardians);

    cq.select(student);
    cq.where(cb.equal(guardian.get(Guardian_.id), id));
    cq.distinct(true);

    TypedQuery<Student> q = em.createQuery(cq);
    return q.getResultList();
}
 
開發者ID:wwu-pi,項目名稱:tap17-muggl-javaee,代碼行數:17,代碼來源:RequestBean.java

示例5: findAllInternal

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
private List<ConfigurationSubscriptionDto> findAllInternal(String mtaId, String appName, String spaceId, String resourceName,
    EntityManager manager) {
    TypedQuery<ConfigurationSubscriptionDto> query = createQuery(mtaId, appName, spaceId, resourceName, manager);

    setQueryParameter(query, ConfigurationSubscriptionDto.FieldNames.SPACE_ID, spaceId);
    setQueryParameter(query, ConfigurationSubscriptionDto.FieldNames.APP_NAME, appName);
    setQueryParameter(query, ConfigurationSubscriptionDto.FieldNames.RESOURCE_NAME, resourceName);
    setQueryParameter(query, ConfigurationSubscriptionDto.FieldNames.MTA_ID, mtaId);

    return query.getResultList();
}
 
開發者ID:SAP,項目名稱:cf-mta-deploy-service,代碼行數:12,代碼來源:ConfigurationSubscriptionDtoDao.java

示例6: findForEndRace

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
public List<ProductEntity> findForEndRace(String categoryName, String productType, int level) {
	TypedQuery<ProductEntity> query = entityManager.createNamedQuery("ProductEntity.findForEndRace", ProductEntity.class);
	query.setParameter("categoryName", categoryName);
	query.setParameter("productType", productType);
	query.setParameter("level", level);
	return query.getResultList();
}
 
開發者ID:SoapboxRaceWorld,項目名稱:soapbox-race-core,代碼行數:8,代碼來源:ProductDAO.java

示例7: findByPersonaId

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
public List<CarSlotEntity> findByPersonaId(Long personaId) {
	PersonaEntity personaEntity = new PersonaEntity();
	personaEntity.setPersonaId(personaId);
	
	TypedQuery<CarSlotEntity> query = entityManager.createNamedQuery("CarSlotEntity.findByPersonaId", CarSlotEntity.class);
	query.setParameter("persona", personaEntity);
	return query.getResultList();
}
 
開發者ID:SoapboxRaceWorld,項目名稱:soapbox-race-core,代碼行數:9,代碼來源:CarSlotDAO.java

示例8: findCode

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
@Override
public ConceptEntity findCode(Coding coding) {


    ConceptEntity conceptEntity = null;
    CriteriaBuilder builder = em.getCriteriaBuilder();

    CriteriaQuery<ConceptEntity> criteria = builder.createQuery(ConceptEntity.class);
    Root<ConceptEntity> root = criteria.from(ConceptEntity.class);


    List<Predicate> predList = new LinkedList<Predicate>();
    List<ConceptEntity> results = new ArrayList<ConceptEntity>();
    Join<ConceptEntity,CodeSystemRepository> join = root.join("codeSystemEntity");

    log.debug("Looking for code ="+coding.getCode()+" in "+coding.getSystem());
    Predicate pcode = builder.equal(root.get("code"), coding.getCode());
    predList.add(pcode);

    Predicate psystem = builder.equal(join.get("codeSystemUri"), coding.getSystem());
    predList.add(psystem);

    Predicate[] predArray = new Predicate[predList.size()];
    predList.toArray(predArray);

    criteria.select(root).where(predArray);

    TypedQuery<ConceptEntity> qry = em.createQuery(criteria);
    qry.setHint("javax.persistence.cache.storeMode", "REFRESH");
    List<ConceptEntity> qryResults = qry.getResultList();

    for (ConceptEntity concept : qryResults) {
        conceptEntity = concept;
        log.debug("Found for code="+coding.getCode()+" ConceptEntity.Id="+conceptEntity.getId());
        break;
    }

    return conceptEntity;
}
 
開發者ID:nhsconnect,項目名稱:careconnect-reference-implementation,代碼行數:40,代碼來源:ConceptDao.java

示例9: haalPersoonCachesOp

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
/**
 * Haalt een lijst van persoon caches op voor een lijst van persoon id's.
 * @param ids De id's van de personen.
 * @return De lijst van persoon caches.
 */
@Override
public List<PersoonCache> haalPersoonCachesOp(final Set<Long> ids) {
    if (ids.isEmpty()) {
        return Lists.newArrayList();
    }
    final String query = "SELECT pc FROM PersoonCache pc WHERE pc.persoon.id IN :ids";
    final TypedQuery<PersoonCache> typedQuery = entityManager.createQuery(query, PersoonCache.class);
    typedQuery.setParameter("ids", ids);
    return typedQuery.getResultList();
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:16,代碼來源:PersoonCacheJpaRepositoryImpl.java

示例10: getSportsOfPlayer

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
public List<String> getSportsOfPlayer(String playerId) {
        logger.info("getSportsOfPlayer");
        List<String> sports = new ArrayList<>();

        try {
            CriteriaQuery<String> cq = cb.createQuery(String.class);
            if (cq != null) {
                Root<Player> player = cq.from(Player.class);
                Join<Player, Team> team = player.join(Player_.teams);
                Join<Team, League> league = team.join(Team_.league);

                // Get MetaModel from Root
                //EntityType<Player> Player_ = player.getModel();

                // set the where clause
                cq.where(cb.equal(player.get(Player_.id), playerId));
                cq.select(league.get(League_.sport)).distinct(true);
                TypedQuery<String> q = em.createQuery(cq);
                sports = q.getResultList();
            }

//        Player player = em.find(Player.class, playerId);
//        Iterator<Team> i = player.getTeams().iterator();
//        while (i.hasNext()) {
//            Team team = i.next();
//            League league = team.getLeague();
//            sports.add(league.getSport());
//        }
        } catch (Exception ex) {
            throw new EJBException(ex);
        }
        return sports;
    }
 
開發者ID:wwu-pi,項目名稱:tap17-muggl-javaee,代碼行數:34,代碼來源:RequestBean.java

示例11: findAll

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
protected  <T> List<T> findAll(Class clazz) throws DatabaseException {
    try {
        CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
        CriteriaQuery<T> c = cb.createQuery(clazz);
        Root<T> root = c.from(clazz);
        CriteriaQuery<T> all = c.select(root);
        TypedQuery<T> allQuery = getEntityManager().createQuery(all);

        return allQuery.getResultList();
    } catch (EJBTransactionRolledbackException | PersistenceException e) {
        throw new DatabaseException("Could not find entity of class " + clazz.toString() + ", " + e.getMessage());
    }
}
 
開發者ID:RWTH-i5-IDSG,項目名稱:xsharing-services-router,代碼行數:14,代碼來源:AbstractRepository.java

示例12: findByEmailAndPassword

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public List<User> findByEmailAndPassword(String email, String password) {
	Session session = this.sessionFactory.getCurrentSession();
	TypedQuery<User> query = session.getNamedQuery("findByEmailAndPassword");  
       query.setParameter("email", email); 
       query.setParameter("password", password);
       return query.getResultList();
}
 
開發者ID:PacktPublishing,項目名稱:Building-Web-Apps-with-Spring-5-and-Angular,代碼行數:10,代碼來源:UserDAOImpl.java

示例13: findByUserId

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
@Override
public List<Session> findByUserId(Long userId) {
  TypedQuery<Session> sessionQuery =
      entityManager.createNamedQuery(FIND_BY_USER_ID_QUERY, Session.class);

  Stream.of(entry("userId", userId), entry("now", nowUtc()))
      .collect(Collectors.toMap(Entry::getKey, Entry::getValue))
      .forEach(sessionQuery::setParameter);

  return sessionQuery.getResultList();
}
 
開發者ID:springuni,項目名稱:springuni-particles,代碼行數:12,代碼來源:SessionJpaRepositoryImpl.java

示例14: getEventsForCategory

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
public List<Event> getEventsForCategory(String category, Optional<Interval> withIn) {
    StringBuilder qs = new StringBuilder("select e from Event e where e.category=:category");
    if (withIn.isPresent()) {
        qs.append(" and t.lastModifiedTime>:startsAt and t.lastModifiedTime<:endsAt");
    }
    TypedQuery<Event> q = em.createQuery(qs.toString(), Event.class);
    q.setParameter("category", category);
    if (withIn.isPresent()) {
        Interval intv = withIn.get();
        q.setParameter("startsAt", Timestamp.from(intv.getStart().toInstant()));
        q.setParameter("endsAt", Timestamp.from(intv.getEnd().toInstant()));
    }
    return q.getResultList();
}
 
開發者ID:psd2-in-a-box,項目名稱:mid-tier,代碼行數:15,代碼來源:LocationArchivist.java

示例15: findAll

import javax.persistence.TypedQuery; //導入方法依賴的package包/類
@Override
@Transactional
public List<MODEL> findAll() throws BusinessException {
   String sql = "from " + persistentClass.getSimpleName() + " order by id";
   TypedQuery<MODEL> q = em.createQuery(sql, persistentClass);
   return q.getResultList();
}
 
開發者ID:alexander-perucci,項目名稱:spring-grow,代碼行數:8,代碼來源:JPACRUDService.java


注:本文中的javax.persistence.TypedQuery.getResultList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。