DATACMNS-84 - Adapt refactorings.

This commit is contained in:
Oliver Gierke
2011-10-07 12:18:48 +02:00
parent 63e564aee3
commit 7a3b20992d
3 changed files with 11 additions and 11 deletions

View File

@@ -53,7 +53,7 @@
<properties>
<spring.version>3.0.6.RELEASE</spring.version>
<spring.data.commons.version>1.2.0.M1</spring.data.commons.version>
<spring.data.commons.version>1.2.0.BUILD-SNAPSHOT</spring.data.commons.version>
<hibernate.version>3.6.5.Final</hibernate.version>
<openjpa.version>2.1.0</openjpa.version>
<eclipselink.version>2.2.0</eclipselink.version>

View File

@@ -32,13 +32,13 @@ import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.springframework.data.domain.Sort;
import org.springframework.data.mapping.PropertyPath;
import org.springframework.data.repository.query.Parameter;
import org.springframework.data.repository.query.Parameters;
import org.springframework.data.repository.query.parser.AbstractQueryCreator;
import org.springframework.data.repository.query.parser.Part;
import org.springframework.data.repository.query.parser.Part.Type;
import org.springframework.data.repository.query.parser.PartTree;
import org.springframework.data.repository.query.parser.Property;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -296,7 +296,7 @@ public class JpaQueryCreator extends AbstractQueryCreator<CriteriaQuery<Object>,
*/
public Predicate build() {
Property property = part.getProperty();
PropertyPath property = part.getProperty();
Expression<Object> path = toExpressionRecursively(root, property);
switch (part.getType()) {
@@ -343,7 +343,7 @@ public class JpaQueryCreator extends AbstractQueryCreator<CriteriaQuery<Object>,
switch (part.shouldIgnoreCase()) {
case ALWAYS:
Assert.state(canUpperCase(expression), "Unable to ignore case of " + expression.getJavaType().getName()
+ " types, the property '" + part.getProperty().getName() + "' must reference a String");
+ " types, the property '" + part.getProperty().getSegment() + "' must reference a String");
return (Expression<T>) builder.upper((Expression<String>) expression);
case WHEN_POSSIBLE:
if (canUpperCase(expression)) {

View File

@@ -36,7 +36,7 @@ import javax.persistence.criteria.Root;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Order;
import org.springframework.data.repository.query.parser.Property;
import org.springframework.data.mapping.PropertyPath;
import org.springframework.util.Assert;
/**
@@ -280,25 +280,25 @@ public abstract class QueryUtils {
*/
private static javax.persistence.criteria.Order toJpaOrder(Order order, Root<?> root, CriteriaBuilder cb) {
Expression<?> expression = toExpressionRecursively(root, Property.from(order.getProperty(), root.getJavaType()));
Expression<?> expression = toExpressionRecursively(root, PropertyPath.from(order.getProperty(), root.getJavaType()));
return order.isAscending() ? cb.asc(expression) : cb.desc(expression);
}
@SuppressWarnings("unchecked")
static <T> Expression<T> toExpressionRecursively(From<?, ?> from, Property property) {
static <T> Expression<T> toExpressionRecursively(From<?, ?> from, PropertyPath property) {
if (property.isCollection()) {
Join<Object, Object> join = from.join(property.getName());
Join<Object, Object> join = from.join(property.getSegment());
return (Expression<T>) (property.hasNext() ? toExpressionRecursively((From<?, ?>) join, property.next()) : join);
} else {
Path<Object> path = from.get(property.getName());
Path<Object> path = from.get(property.getSegment());
return (Expression<T>) (property.hasNext() ? toExpressionRecursively(path, property.next()) : path);
}
}
static Expression<Object> toExpressionRecursively(Path<Object> path, Property property) {
static Expression<Object> toExpressionRecursively(Path<Object> path, PropertyPath property) {
Path<Object> result = path.get(property.getName());
Path<Object> result = path.get(property.getSegment());
return property.hasNext() ? toExpressionRecursively(result, property.next()) : result;
}
}