Package javax.persistence.criteria

Examples of javax.persistence.criteria.CriteriaBuilder.lower()


    em.getTransaction().begin();
    CriteriaBuilder cb = em.getCriteriaBuilder();
    // lower
    CriteriaQuery<Client> cq = cb.createQuery( Client.class );
    Root<Client> root = cq.from( Client.class );
    cq.where( cb.equal( cb.lower( root.get( Client_.name ).get( Name_.lastName ) ),"test" ) );
    em.createQuery( cq ).getResultList();
    // upper
    cq = cb.createQuery( Client.class );
    root = cq.from( Client.class );
    cq.where( cb.equal( cb.upper( root.get( Client_.name ).get( Name_.lastName ) ),"test" ) );
View Full Code Here


  @WebMethod
  public void insertEventTask(@WebParam(name = "eventUri") String eventUri) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<IntEvent> cq = cb.createQuery(IntEvent.class);
    Root<IntEvent> evta = cq.from(IntEvent.class);
    cq.where(cb.equal(cb.lower(evta.get(IntEvent_.eventUri)), eventUri.toLowerCase()));
    List<IntEvent> list = em.createQuery(cq).getResultList();
    if (list.size() == 0) {
      IntEvent intEvent = new IntEvent();
      intEvent.setEventUri(eventUri);
      intEvent.getFingerprint().setInsertDate(new Date());
View Full Code Here

    @Override
    public MetadataCategory findOneByNameIgnoreCase(@Nonnull String name) {
        final CriteriaBuilder cb = _entityManager.getCriteriaBuilder();
        final CriteriaQuery<MetadataCategory> cbQuery = cb.createQuery(MetadataCategory.class);
        final Root<MetadataCategory> root = cbQuery.from(MetadataCategory.class);
        final Expression<String> lowerName = cb.lower(root.get(MetadataCategory_.name));
        final Expression<String> lowerRequiredName = cb.lower(cb.literal(name));
        cbQuery.where(cb.equal(lowerName, lowerRequiredName));
        return _entityManager.createQuery(cbQuery).getSingleResult();
    }
View Full Code Here

    public MetadataCategory findOneByNameIgnoreCase(@Nonnull String name) {
        final CriteriaBuilder cb = _entityManager.getCriteriaBuilder();
        final CriteriaQuery<MetadataCategory> cbQuery = cb.createQuery(MetadataCategory.class);
        final Root<MetadataCategory> root = cbQuery.from(MetadataCategory.class);
        final Expression<String> lowerName = cb.lower(root.get(MetadataCategory_.name));
        final Expression<String> lowerRequiredName = cb.lower(cb.literal(name));
        cbQuery.where(cb.equal(lowerName, lowerRequiredName));
        return _entityManager.createQuery(cbQuery).getSingleResult();
    }

    @Override
View Full Code Here

        // We only want results that match the search query
        List<Predicate> restrictions = new ArrayList<Predicate>();
        String lq = query.toLowerCase();
        restrictions.add(
            builder.or(
                builder.like(builder.lower(sku.get("name").as(String.class)), '%' + lq + '%'),
                builder.like(builder.lower(sku.get("longDescription").as(String.class)), '%' + lq + '%')
            )
        );
               
        attachProductSearchCriteria(searchCriteria, product, sku, restrictions);
View Full Code Here

        List<Predicate> restrictions = new ArrayList<Predicate>();
        String lq = query.toLowerCase();
        restrictions.add(
            builder.or(
                builder.like(builder.lower(sku.get("name").as(String.class)), '%' + lq + '%'),
                builder.like(builder.lower(sku.get("longDescription").as(String.class)), '%' + lq + '%')
            )
        );
               
        attachProductSearchCriteria(searchCriteria, product, sku, restrictions);
       
View Full Code Here

        } else if (fieldName.contains("productAttributes.")) {
            pathToUse = product.join("productAttributes");
           
            fieldName = fieldName.substring("productAttributes.".length());
            criteria.where(builder.equal(
                builder.lower(pathToUse.get("name").as(String.class)), fieldName.toLowerCase()));
           
            fieldName = "value";
        } else if (fieldName.contains("product.")) {
            pathToUse = product;
            fieldName = fieldName.substring("product.".length());
View Full Code Here

        CriteriaBuilder builder = em.getCriteriaBuilder();
        CriteriaQuery<Hotel> cquery = builder.createQuery(Hotel.class);
        Root<Hotel> hotel = cquery.from(Hotel.class);
        // QUESTION can like create the pattern for us?
        cquery.select(hotel).where(
                builder.or(builder.like(builder.lower(hotel.get(Hotel_.name)), criteria.getSearchPattern()),
                        builder.like(builder.lower(hotel.get(Hotel_.city)), criteria.getSearchPattern()),
                        builder.like(builder.lower(hotel.get(Hotel_.zip)), criteria.getSearchPattern()),
                        builder.like(builder.lower(hotel.get(Hotel_.address)), criteria.getSearchPattern())));

        List<Hotel> results = em.createQuery(cquery).setMaxResults(criteria.getFetchSize())
View Full Code Here

        CriteriaQuery<Hotel> cquery = builder.createQuery(Hotel.class);
        Root<Hotel> hotel = cquery.from(Hotel.class);
        // QUESTION can like create the pattern for us?
        cquery.select(hotel).where(
                builder.or(builder.like(builder.lower(hotel.get(Hotel_.name)), criteria.getSearchPattern()),
                        builder.like(builder.lower(hotel.get(Hotel_.city)), criteria.getSearchPattern()),
                        builder.like(builder.lower(hotel.get(Hotel_.zip)), criteria.getSearchPattern()),
                        builder.like(builder.lower(hotel.get(Hotel_.address)), criteria.getSearchPattern())));

        List<Hotel> results = em.createQuery(cquery).setMaxResults(criteria.getFetchSize())
                .setFirstResult(criteria.getFetchOffset()).getResultList();
View Full Code Here

        Root<Hotel> hotel = cquery.from(Hotel.class);
        // QUESTION can like create the pattern for us?
        cquery.select(hotel).where(
                builder.or(builder.like(builder.lower(hotel.get(Hotel_.name)), criteria.getSearchPattern()),
                        builder.like(builder.lower(hotel.get(Hotel_.city)), criteria.getSearchPattern()),
                        builder.like(builder.lower(hotel.get(Hotel_.zip)), criteria.getSearchPattern()),
                        builder.like(builder.lower(hotel.get(Hotel_.address)), criteria.getSearchPattern())));

        List<Hotel> results = em.createQuery(cquery).setMaxResults(criteria.getFetchSize())
                .setFirstResult(criteria.getFetchOffset()).getResultList();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.