mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
#616 - ElasticSearch expression - IllegalArgumentException: unhandled type class org.example.domain.Customer
This commit is contained in:
1 parent
a9d7ea0299
commit
a227f8c469
4 files changed
+36
-15
No files matched your search
@@ -2,6 +2,7 @@ package com.avaje.ebeaninternal.server.expression;
|
||||
|
||||
import com.avaje.ebean.Junction;
|
||||
import com.avaje.ebean.LikeType;
|
||||
import com.avaje.ebean.plugin.ExpressionPath;
|
||||
import com.avaje.ebean.search.Match;
|
||||
import com.avaje.ebean.search.MultiMatch;
|
||||
import com.avaje.ebean.search.TextCommonTerms;
|
||||
@@ -142,4 +143,8 @@ public interface DocQueryContext {
|
||||
*/
|
||||
void endBoolGroup() throws IOException;
|
||||
|
||||
/**
|
||||
* Return the expression path for the given property path.
|
||||
*/
|
||||
ExpressionPath getExpressionPath(String propName);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.avaje.ebeaninternal.server.expression;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebean.plugin.ExpressionPath;
|
||||
import com.avaje.ebeaninternal.api.HashQueryPlanBuilder;
|
||||
import com.avaje.ebeaninternal.api.SpiExpression;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionRequest;
|
||||
@@ -25,7 +26,17 @@ public class SimpleExpression extends AbstractExpression {
|
||||
if (type == Op.BETWEEN) {
|
||||
throw new IllegalStateException("BETWEEN Not expected in SimpleExpression?");
|
||||
}
|
||||
context.writeSimple(type, propName, value);
|
||||
ExpressionPath prop = context.getExpressionPath(propName);
|
||||
if (prop != null && prop.isAssocId()) {
|
||||
String idName = prop.getAssocOneIdExpr(propName, "");
|
||||
Object[] ids = prop.getAssocOneIdValues((EntityBean) value);
|
||||
if (ids == null || ids.length != 1) {
|
||||
throw new IllegalArgumentException("Expecting 1 Id value for " + idName + " but got " + ids);
|
||||
}
|
||||
context.writeSimple(type, idName, ids[0]);
|
||||
} else {
|
||||
context.writeSimple(type, propName, value);
|
||||
}
|
||||
}
|
||||
|
||||
public final String getPropName() {
|
||||
|
||||
Reference in new issue
Block a user