Package org.springframework.data.repository.query.parser

Examples of org.springframework.data.repository.query.parser.Part


  public void createsParameterExpressionWithMostConcreteType() throws Exception {

    Method method = SampleRepository.class.getMethod("findByIdGreaterThan", int.class);
    Parameters<?, ?> parameters = new DefaultParameters(method);
    ParametersParameterAccessor accessor = new ParametersParameterAccessor(parameters, new Object[] { 1 });
    Part part = new Part("IdGreaterThan", User.class);

    ParameterMetadataProvider provider = new ParameterMetadataProvider(em.getCriteriaBuilder(), accessor);
    ParameterExpression<? extends Comparable> expression = provider.next(part, Comparable.class).getExpression();
    assertThat(expression.getParameterType(), is(typeCompatibleWith(int.class)));
  }
View Full Code Here


     
      final OrPart orPart = orIt.next();
     
      final Iterator<Part> partIt = orPart.iterator();
      while(partIt.hasNext()) {
        final Part part = partIt.next();
       
        result.append(" " + part.getProperty().getSegment() + " ");
        result.append(convertOperator(part.getType()));
       
        if(partIt.hasNext()) {
          result.append(" AND ");
        }
      }
View Full Code Here

public class PredicatesUnitTests {

  @Test
  public void atomicPredicateDefaultsAlias() {

    Part part = new Part("firstname", Person.class);

    Iterable<Integer> indexes = Arrays.asList(1);

    Predicate predicate = new AtomicPredicate(part, indexes.iterator());
    assertThat(predicate.toString(null), is("x.firstname = $1"));
View Full Code Here

  }

  @Test
  public void concatenatesAndPredicateCorrectly() {

    Part left = new Part("firstname", Person.class);
    Part right = new Part("lastname", Person.class);
    Iterator<Integer> indexes = Arrays.asList(1, 2).iterator();

    Predicates predicate = Predicates.create(left, indexes);
    predicate = predicate.and(new AtomicPredicate(right, indexes));
View Full Code Here

  }

  @Test
  public void concatenatesOrPredicateCorrectly() {

    Part left = new Part("firstname", Person.class);
    Part right = new Part("lastname", Person.class);
    Iterator<Integer> indexes = Arrays.asList(1, 2).iterator();

    Predicates predicate = Predicates.create(left, indexes);
    predicate = predicate.or(new AtomicPredicate(right, indexes));
View Full Code Here

    assertThat(predicate.toString(null), is("x.firstname = $1 OR x.lastname = $2"));
  }

  @Test
  public void testBooleanBasedPredicate() {
    Part part = new Part("activeTrue", User.class);
    Iterator<Integer> indexes = Collections.<Integer>emptyList().iterator();
    Predicates predicate = Predicates.create(part, indexes);

    assertNotNull(predicate);
    assertThat(predicate.toString("user"), is("user.active = true"));
View Full Code Here

    }


    @Test
    public void createsQueryForSimplePropertyReference() {
        Part part = new Part("name", Person.class);
        query.addRestriction(part);
        assertThat(query.toString(),
                is(getExpectedQuery("MATCH (`person`:`Person`) WHERE `person`.`name` = {0} RETURN `person`")));
    }
View Full Code Here

        assertThat(query.toString(),
                is(getExpectedQuery("MATCH (`person`:`Person`) WHERE `person`.`name` = {0} RETURN `person`")));
    }
    @Test
    public void createsQueryForSimpleIndexedPropertyReference() {
        Part part = new Part("name2", Person.class);
        query.addRestriction(part);
        assertThat(query.toString(),
                is(getExpectedQuery("START `person`=node:`Person`(`name2`={0}) RETURN `person`")));
    }
View Full Code Here

                is(getExpectedQuery("START `person`=node:`Person`(`name2`={0}) RETURN `person`")));
    }

    @Test
    public void createsQueryForLikePropertyIndex() {
        Part part = new Part("titleLike", Person.class);
        query.addRestriction(part);
        assertThat(query.toString(),
                is(getExpectedQuery("START `person`=node:`title`({0}) RETURN `person`")));
    }
View Full Code Here

                is(getExpectedQuery("START `person`=node:`title`({0}) RETURN `person`")));
    }

    @Test
    public void createsQueryForLikeProperty() {
        Part part = new Part("infoLike", Person.class);
        query.addRestriction(part);
        assertThat(query.toString(), is( getExpectedQuery("trs-specific-test-subclass-expected-to-set-value")));
    }
View Full Code Here

TOP

Related Classes of org.springframework.data.repository.query.parser.Part

Copyright © 2018 www.massapicom. 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.