mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-19 23:02:24 +00:00
EQL - Add / expose via EbeanServer.createQuery(type, eql) method
This commit is contained in:
1 parent
e58cec8bdd
commit
474c2d5595
10 files changed
+215
-34
No files matched your search
@@ -29,6 +29,7 @@ import com.avaje.ebeaninternal.server.query.CancelableQuery;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -1395,6 +1396,16 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
this.generatedSql = generatedSql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkNamedParameters() {
|
||||
if (namedParams != null) {
|
||||
Collection<ONamedParam> values = namedParams.values();
|
||||
for (ONamedParam value : values) {
|
||||
value.checkValueSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiNamedParam createNamedParameter(String name) {
|
||||
if (namedParams == null) {
|
||||
|
||||
@@ -2,21 +2,44 @@ package com.avaje.ebeaninternal.server.querydefn;
|
||||
|
||||
import com.avaje.ebeaninternal.api.SpiNamedParam;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
/**
|
||||
* Named parameter used as placeholder in expressions created by EQL language parsing.
|
||||
*/
|
||||
public class ONamedParam implements SpiNamedParam {
|
||||
|
||||
private final String name;
|
||||
|
||||
private Object value;
|
||||
|
||||
/**
|
||||
* Create with the given name.
|
||||
*/
|
||||
public ONamedParam(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bind value for this named parameter.
|
||||
*/
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the bind value for this named parameter.
|
||||
*/
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the bind value has been set (so does not support null value).
|
||||
*/
|
||||
public void checkValueSet() {
|
||||
if (value == null) {
|
||||
throw new PersistenceException("Named parameter ["+name+"] has not had it's value set.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user