Merge pull request #1127 from querydsl/i1123

Remove type(?) expression customizations
This commit is contained in:
Ruben Dijkstra 2015-01-23 20:55:35 +01:00
commit afd5de95fa
3 changed files with 0 additions and 34 deletions

View File

@ -75,10 +75,6 @@ public class HQLTemplates extends JPQLTemplates {
builder.put(BigDecimal.class, "big_decimal");
typeNames = builder.build();
// TODO : remove this when Hibernate supports type(alias)
add(Ops.INSTANCE_OF, "{0}.class = {1}");
// TODO : remove this when Hibernate supports type(alias)
add(JPQLOps.TYPE, "{0}.class");
// TODO : remove this when Hibernate supports member of properly
add(JPQLOps.MEMBER_OF, "{0} in elements({1})");
add(JPQLOps.NOT_MEMBER_OF, "{0} not in elements({1})");
@ -110,11 +106,6 @@ public class HQLTemplates extends JPQLTemplates {
return wrapElements.contains(operator);
}
@Override
public boolean isTypeAsString() {
return true;
}
@Override
public String getTypeForCast(Class<?> cl) {
return typeNames.get(cl);

View File

@ -417,9 +417,6 @@ public class JPQLSerializer extends SerializerBase<JPQLSerializer> {
super.visitOperation(type, operator, args);
}
} else if (operator == Ops.INSTANCE_OF) {
visitInstanceOf(type, operator, args);
} else if (operator == Ops.NUMCAST) {
visitNumCast(args);
@ -456,23 +453,6 @@ public class JPQLSerializer extends SerializerBase<JPQLSerializer> {
visitOperation(targetType, JPQLOps.CAST, ImmutableList.of(args.get(0), ConstantImpl.create(typeName)));
}
private void visitInstanceOf(Class<?> type, Operator<?> operator,
List<? extends Expression<?>> args) {
if (templates.isTypeAsString()) {
final List<Expression<?>> newArgs = new ArrayList<Expression<?>>(args);
final Class<?> cl = ((Class<?>) ((Constant<?>) newArgs.get(1)).getConstant());
// use discriminator value instead of fqnm
if (cl.isAnnotationPresent(DiscriminatorValue.class)) {
newArgs.set(1, ConstantImpl.create(cl.getAnnotation(DiscriminatorValue.class).value()));
} else {
newArgs.set(1, ConstantImpl.create(cl.getSimpleName()));
}
super.visitOperation(type, operator, newArgs);
} else {
super.visitOperation(type, operator, args);
}
}
private void visitPathInCollection(Class<?> type, Operator<?> operator,
List<? extends Expression<?>> args) {
Path<?> lhs = (Path<?>) args.get(0);

View File

@ -146,11 +146,6 @@ public class JPQLTemplates extends Templates {
return false;
}
public boolean isTypeAsString() {
// TODO : get rid of this when Hibernate supports type(alias)
return false;
}
public String getTypeForCast(Class<?> cl) {
return cl.getSimpleName().toLowerCase();
}