OPENJPA-1013: MEMBER OF support for criteria query

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@775009 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Fay Wang 2009-05-15 05:27:38 +00:00
parent 9d30d4819e
commit 2203aedf46
4 changed files with 16 additions and 10 deletions

View File

@ -403,7 +403,6 @@ public class TestTypesafeCriteria extends SQLListenerTestCase {
assertEquivalence(q, jpql);
}
@AllowFailure
public void testLiterals() {
String jpql = "SELECT p FROM Person p where 'Joe' MEMBER OF p.nickNames";
CriteriaQuery q = cb.create();

View File

@ -177,11 +177,11 @@ public class CriteriaQueryImpl implements CriteriaQuery {
exps.accessPath[i++] = ((Types.Managed<?>)r.getModel()).meta;
}
// exps.alias = null; // String
exps.ascending = new boolean[]{false};
exps.distinct = _distinct == null ? QueryExpressions.DISTINCT_AUTO :
_distinct ? QueryExpressions.DISTINCT_TRUE
: QueryExpressions.DISTINCT_FALSE;
// exps.fetchInnerPaths = null; // String[]
exps.distinct = _distinct == null ? QueryExpressions.DISTINCT_FALSE :
_distinct ?
QueryExpressions.DISTINCT_TRUE | QueryExpressions.DISTINCT_AUTO :
QueryExpressions.DISTINCT_FALSE;
// exps.fetchInnerPaths = null; // String[]
// exps.fetchPaths = null; // String[]
exps.filter = _where == null ? factory.emptyExpression()
: _where.toKernelExpression(factory, _model);

View File

@ -39,8 +39,6 @@ public class Expressions {
static Value toValue(ExpressionImpl<?> e, ExpressionFactory factory,
MetamodelImpl model) {
Value v = e.toValue(factory, model);
v.setImplicitType(e.getJavaType());
v.setAlias(e.getAlias());
return v;
}
@ -618,8 +616,9 @@ public class Expressions {
@Override
public org.apache.openjpa.kernel.exps.Expression toKernelExpression(
ExpressionFactory factory, MetamodelImpl model) {
return factory.contains(factory.getThis(),
Expressions.toValue(collection, factory, model));
return factory.contains(
Expressions.toValue(collection, factory, model),
Expressions.toValue(element, factory, model));
}
}

View File

@ -28,6 +28,7 @@ import javax.persistence.metamodel.Map;
import org.apache.openjpa.kernel.exps.ExpressionFactory;
import org.apache.openjpa.kernel.exps.Value;
import org.apache.openjpa.meta.JavaTypes;
import org.apache.openjpa.persistence.meta.Members;
import org.apache.openjpa.persistence.meta.MetamodelImpl;
@ -75,6 +76,13 @@ public class PathImpl<X> extends ExpressionImpl<X> implements Path<X> {
var = factory.newPath();//getJavaType());
var.setMetaData(model.repos.getMetaData(getJavaType(), null, true));
}
if (member != null) {
int typeCode = member.fmd.getDeclaredTypeCode();
if (typeCode != JavaTypes.COLLECTION && typeCode != JavaTypes.MAP)
var.setImplicitType(getJavaType());
}
var.setAlias(getAlias());
return var;
}