mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Compare commits
29
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7902276296 | ||
|
|
95f7a85aa1 | ||
|
|
b5cb04a6ed | ||
|
|
5a9193f732 | ||
|
|
55584f09d5 | ||
|
|
05eb0bfc55 | ||
|
|
cf13119b49 | ||
|
|
e0eff149b5 | ||
|
|
474c2d5595 | ||
|
|
e58cec8bdd | ||
|
|
9dd82c0dd7 | ||
|
|
49d3cc91e4 | ||
|
|
a8c2fc2ed5 | ||
|
|
45d7e3cafd | ||
|
|
be6754bd06 | ||
|
|
83c16ad1c6 | ||
|
|
3f8b389999 | ||
|
|
b4b6a13e75 | ||
|
|
3fad4aae2f | ||
|
|
ceab95e6c2 | ||
|
|
84b37fb014 | ||
|
|
1a1c432c2a | ||
|
|
86faa947af | ||
|
|
6b54b6ef46 | ||
|
|
d8dfd66af3 | ||
|
|
675c51b8c1 | ||
|
|
3cd7ecaa4a | ||
|
|
1b322955ee | ||
|
|
a954f8e9e1 |
@@ -9,7 +9,7 @@
|
||||
|
||||
<groupId>org.avaje.ebeanorm</groupId>
|
||||
<artifactId>avaje-ebeanorm</artifactId>
|
||||
<version>7.18.1</version>
|
||||
<version>7.19.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>avaje-ebeanorm</name>
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
<scm>
|
||||
<developerConnection>scm:git:https://github.com/ebean-orm/avaje-ebeanorm.git</developerConnection>
|
||||
<tag>avaje-ebeanorm-7.18.1</tag>
|
||||
<tag>avaje-ebeanorm-7.19.1</tag>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
@@ -90,6 +90,12 @@
|
||||
<version>[1.7.1,1.7.99)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4-runtime</artifactId>
|
||||
<version>4.5.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Jackson core used internally by Ebean -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
|
||||
@@ -975,39 +975,7 @@ public final class Ebean {
|
||||
* {@link Query#findSet()} etc will execute against the same EbeanServer from
|
||||
* which is was created.
|
||||
* </p>
|
||||
*
|
||||
* <pre>{@code
|
||||
* // Find order 2 additionally fetching the customer, details and details.product
|
||||
* // name.
|
||||
*
|
||||
* Order order = Ebean.find(Order.class)
|
||||
* .fetch("customer")
|
||||
* .fetch("details")
|
||||
* .fetch("detail.product", "name")
|
||||
* .setId(2)
|
||||
* .findUnique();
|
||||
*
|
||||
* // Find order 2 additionally fetching the customer, details and details.product
|
||||
* // name.
|
||||
* // Note: same query as above but using the query language
|
||||
* // Note: using a named query would be preferred practice
|
||||
*
|
||||
* String oql = "find order fetch customer fetch details fetch details.product (name) where id = :orderId ";
|
||||
*
|
||||
* Query<Order> query = Ebean.find(Order.class);
|
||||
* query.setQuery(oql);
|
||||
* query.setParameter("orderId", 2);
|
||||
*
|
||||
* Order order = query.findUnique();
|
||||
*
|
||||
* // Using a named query
|
||||
* Query<Order> query = Ebean.find(Order.class, "with.details");
|
||||
* query.setParameter("orderId", 2);
|
||||
*
|
||||
* Order order = query.findUnique();
|
||||
*
|
||||
* }</pre>
|
||||
*
|
||||
*
|
||||
* @param beanType
|
||||
* the class of entity to be fetched
|
||||
* @return A ORM Query object for this beanType
|
||||
@@ -1017,6 +985,47 @@ public final class Ebean {
|
||||
return serverMgr.getDefaultServer().createQuery(beanType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the Ebean query language statement returning the query which can then
|
||||
* be modified (add expressions, change order by clause, change maxRows, change
|
||||
* fetch and select paths etc).
|
||||
*
|
||||
* <h3>Example</h3>
|
||||
*
|
||||
* <pre>{@code
|
||||
*
|
||||
*
|
||||
* // Find order additionally fetching the customer, details and details.product name.
|
||||
*
|
||||
* String eql = "fetch customer fetch details fetch details.product (name) where id = :orderId ";
|
||||
*
|
||||
* Query<Order> query = Ebean.createQuery(Order.class, eql);
|
||||
* query.setParameter("orderId", 2);
|
||||
*
|
||||
* Order order = query.findUnique();
|
||||
*
|
||||
* // This is the same as:
|
||||
*
|
||||
* Order order = Ebean.find(Order.class)
|
||||
* .fetch("customer")
|
||||
* .fetch("details")
|
||||
* .fetch("detail.product", "name")
|
||||
* .setId(2)
|
||||
* .findUnique();
|
||||
*
|
||||
* }</pre>
|
||||
*
|
||||
* @param beanType The type of bean to fetch
|
||||
* @param eql The Ebean query
|
||||
* @param <T> The type of the entity bean
|
||||
*
|
||||
* @return The query with expressions defined as per the parsed query statement
|
||||
*/
|
||||
public static <T> Query<T> createQuery(Class<T> beanType, String eql) {
|
||||
|
||||
return serverMgr.getDefaultServer().createQuery(beanType, eql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a query for a type of entity bean.
|
||||
* <p>
|
||||
|
||||
@@ -219,6 +219,43 @@ public interface EbeanServer {
|
||||
*/
|
||||
<T> Query<T> createQuery(Class<T> beanType);
|
||||
|
||||
/**
|
||||
* Parse the Ebean query language statement returning the query which can then
|
||||
* be modified (add expressions, change order by clause, change maxRows, change
|
||||
* fetch and select paths etc).
|
||||
*
|
||||
* <h3>Example</h3>
|
||||
*
|
||||
* <pre>{@code
|
||||
*
|
||||
* // Find order additionally fetching the customer, details and details.product name.
|
||||
*
|
||||
* String eql = "fetch customer fetch details fetch details.product (name) where id = :orderId ";
|
||||
*
|
||||
* Query<Order> query = Ebean.createQuery(Order.class, eql);
|
||||
* query.setParameter("orderId", 2);
|
||||
*
|
||||
* Order order = query.findUnique();
|
||||
*
|
||||
* // This is the same as:
|
||||
*
|
||||
* Order order = Ebean.find(Order.class)
|
||||
* .fetch("customer")
|
||||
* .fetch("details")
|
||||
* .fetch("detail.product", "name")
|
||||
* .setId(2)
|
||||
* .findUnique();
|
||||
*
|
||||
* }</pre>
|
||||
*
|
||||
* @param beanType The type of bean to fetch
|
||||
* @param eql The Ebean query
|
||||
* @param <T> The type of the entity bean
|
||||
*
|
||||
* @return The query with expressions defined as per the parsed query statement
|
||||
*/
|
||||
<T> Query<T> createQuery(Class<T> beanType, String eql);
|
||||
|
||||
/**
|
||||
* Create a query for a type of entity bean.
|
||||
* <p>
|
||||
|
||||
@@ -135,6 +135,11 @@ public interface ExpressionFactory {
|
||||
*/
|
||||
Expression ieq(String propertyName, String value);
|
||||
|
||||
/**
|
||||
* Case Insensitive Equal To that allows for named parameter use.
|
||||
*/
|
||||
Expression ieqObject(String propertyName, Object value);
|
||||
|
||||
/**
|
||||
* Between - property between the two given values.
|
||||
*/
|
||||
@@ -192,6 +197,11 @@ public interface ExpressionFactory {
|
||||
*/
|
||||
ExampleExpression exampleLike(Object example, boolean caseInsensitive, LikeType likeType);
|
||||
|
||||
/**
|
||||
* Like with support for named parameters.
|
||||
*/
|
||||
Expression like(String propertyName, Object value, boolean caseInsensitive, LikeType likeType);
|
||||
|
||||
/**
|
||||
* Like - property like value where the value contains the SQL wild card
|
||||
* characters % (percentage) and _ (underscore).
|
||||
|
||||
@@ -59,11 +59,11 @@ package com.avaje.ebean;
|
||||
* .and()
|
||||
* .startsWith("name", "r")
|
||||
* .eq("anniversary", onAfter)
|
||||
* .endJunction()
|
||||
* .endAnd()
|
||||
* .and()
|
||||
* .eq("status", Customer.Status.ACTIVE)
|
||||
* .gt("id", 0)
|
||||
* .endJunction()
|
||||
* .endAnd()
|
||||
* .order().asc("name");
|
||||
*
|
||||
* q.findList();
|
||||
@@ -84,39 +84,41 @@ public interface Junction<T> extends Expression, ExpressionList<T> {
|
||||
/**
|
||||
* AND group.
|
||||
*/
|
||||
AND(" and ", ""),
|
||||
AND(" and ", "", false),
|
||||
|
||||
/**
|
||||
* OR group.
|
||||
*/
|
||||
OR(" or ", ""),
|
||||
OR(" or ", "", false),
|
||||
|
||||
/**
|
||||
* NOT group.
|
||||
*/
|
||||
NOT(" and ", "not "),
|
||||
NOT(" and ", "not ", false),
|
||||
|
||||
/**
|
||||
* Text search AND group.
|
||||
*/
|
||||
MUST("must", ""),
|
||||
MUST("must", "", true),
|
||||
|
||||
/**
|
||||
* Text search NOT group.
|
||||
*/
|
||||
MUST_NOT("must_not", ""),
|
||||
MUST_NOT("must_not", "", true),
|
||||
|
||||
/**
|
||||
* Text search OR group.
|
||||
*/
|
||||
SHOULD("should", "");
|
||||
SHOULD("should", "", true);
|
||||
|
||||
String prefix;
|
||||
String literal;
|
||||
private String prefix;
|
||||
private String literal;
|
||||
private boolean text;
|
||||
|
||||
Type(String literal, String prefix) {
|
||||
Type(String literal, String prefix, boolean text) {
|
||||
this.literal = literal;
|
||||
this.prefix = prefix;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,6 +134,14 @@ public interface Junction<T> extends Expression, ExpressionList<T> {
|
||||
public String prefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this is a text type.
|
||||
*/
|
||||
public boolean isText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -148,6 +148,13 @@ public final class OrderBy<T> implements Serializable {
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to the order by by parsing a raw expression.
|
||||
*/
|
||||
public void add(String rawExpression) {
|
||||
parse(rawExpression);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a property to the order by.
|
||||
*/
|
||||
@@ -206,8 +213,9 @@ public final class OrderBy<T> implements Serializable {
|
||||
* order by clause and replace.
|
||||
* </p>
|
||||
*/
|
||||
public void clear() {
|
||||
public OrderBy<T> clear() {
|
||||
list.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -379,19 +379,13 @@ public class ServerConfig {
|
||||
|
||||
private boolean transactionRollbackOnChecked = true;
|
||||
|
||||
private boolean registerJmxMBeans = true;
|
||||
|
||||
// configuration for the background executor service (thread pool)
|
||||
|
||||
private int backgroundExecutorSchedulePoolSize = 1;
|
||||
private int backgroundExecutorCorePoolSize = 1;
|
||||
private int backgroundExecutorMaxPoolSize = 8;
|
||||
private int backgroundExecutorIdleSecs = 60;
|
||||
private int backgroundExecutorShutdownSecs = 30;
|
||||
|
||||
// defaults for the L2 bean caching
|
||||
|
||||
private int cacheWarmingDelay = 30;
|
||||
private int cacheMaxSize = 10000;
|
||||
private int cacheMaxIdleTime = 600;
|
||||
private int cacheMaxTimeToLive = 60 * 60 * 6;
|
||||
@@ -409,7 +403,7 @@ public class ServerConfig {
|
||||
private boolean expressionEqualsWithNullAsNoop;
|
||||
|
||||
/**
|
||||
* Set to true to use native ILIKE expression (if support by datasbase platform / like Postgres).
|
||||
* Set to true to use native ILIKE expression (if support by database platform / like Postgres).
|
||||
*/
|
||||
private boolean expressionNativeIlike;
|
||||
|
||||
@@ -1042,20 +1036,6 @@ public class ServerConfig {
|
||||
this.transactionRollbackOnChecked = transactionRollbackOnChecked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the server should register JMX MBeans.
|
||||
*/
|
||||
public boolean isRegisterJmxMBeans() {
|
||||
return registerJmxMBeans;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if the server should register JMX MBeans.
|
||||
*/
|
||||
public void setRegisterJmxMBeans(boolean registerJmxMBeans) {
|
||||
this.registerJmxMBeans = registerJmxMBeans;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Background executor schedule pool size. Defaults to 1.
|
||||
*/
|
||||
@@ -1070,48 +1050,6 @@ public class ServerConfig {
|
||||
this.backgroundExecutorSchedulePoolSize = backgroundExecutorSchedulePoolSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Background executor core pool size.
|
||||
*/
|
||||
public int getBackgroundExecutorCorePoolSize() {
|
||||
return backgroundExecutorCorePoolSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Background executor core pool size.
|
||||
*/
|
||||
public void setBackgroundExecutorCorePoolSize(int backgroundExecutorCorePoolSize) {
|
||||
this.backgroundExecutorCorePoolSize = backgroundExecutorCorePoolSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Background executor max pool size.
|
||||
*/
|
||||
public int getBackgroundExecutorMaxPoolSize() {
|
||||
return backgroundExecutorMaxPoolSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Background executor max pool size.
|
||||
*/
|
||||
public void setBackgroundExecutorMaxPoolSize(int backgroundExecutorMaxPoolSize) {
|
||||
this.backgroundExecutorMaxPoolSize = backgroundExecutorMaxPoolSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Background executor idle seconds.
|
||||
*/
|
||||
public int getBackgroundExecutorIdleSecs() {
|
||||
return backgroundExecutorIdleSecs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Background executor idle seconds.
|
||||
*/
|
||||
public void setBackgroundExecutorIdleSecs(int backgroundExecutorIdleSecs) {
|
||||
this.backgroundExecutorIdleSecs = backgroundExecutorIdleSecs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Background executor shutdown seconds. This is the time allowed for the pool to shutdown nicely
|
||||
* before it is forced shutdown.
|
||||
@@ -1128,20 +1066,6 @@ public class ServerConfig {
|
||||
this.backgroundExecutorShutdownSecs = backgroundExecutorShutdownSecs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cache warming delay in seconds.
|
||||
*/
|
||||
public int getCacheWarmingDelay() {
|
||||
return cacheWarmingDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cache warming delay in seconds.
|
||||
*/
|
||||
public void setCacheWarmingDelay(int cacheWarmingDelay) {
|
||||
this.cacheWarmingDelay = cacheWarmingDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the L2 cache default max size.
|
||||
*/
|
||||
@@ -2399,6 +2323,8 @@ public class ServerConfig {
|
||||
autoCommitMode = p.getBoolean("autoCommitMode", autoCommitMode);
|
||||
useJtaTransactionManager = p.getBoolean("useJtaTransactionManager", useJtaTransactionManager);
|
||||
|
||||
backgroundExecutorSchedulePoolSize = p.getInt("backgroundExecutorSchedulePoolSize", backgroundExecutorSchedulePoolSize);
|
||||
backgroundExecutorShutdownSecs = p.getInt("backgroundExecutorShutdownSecs", backgroundExecutorShutdownSecs);
|
||||
disableClasspathSearch = p.getBoolean("disableClasspathSearch", disableClasspathSearch);
|
||||
currentUserProvider = createInstance(p, CurrentUserProvider.class, "currentUserProvider", currentUserProvider);
|
||||
databasePlatform = createInstance(p, DatabasePlatform.class, "databasePlatform", databasePlatform);
|
||||
@@ -2408,7 +2334,6 @@ public class ServerConfig {
|
||||
dbEncrypt = createInstance(p, DbEncrypt.class, "dbEncrypt", dbEncrypt);
|
||||
serverCachePlugin = createInstance(p, ServerCachePlugin.class, "serverCachePlugin", serverCachePlugin);
|
||||
serverCacheManager = createInstance(p, ServerCacheManager.class, "serverCacheManager", serverCacheManager);
|
||||
cacheWarmingDelay = p.getInt("cacheWarmingDelay", cacheWarmingDelay);
|
||||
|
||||
if (packages != null) {
|
||||
String packagesProp = p.get("search.packages", p.get("packages", null));
|
||||
|
||||
@@ -13,7 +13,12 @@ import java.io.IOException;
|
||||
*/
|
||||
public interface SpiExpression extends Expression {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Simplify nested expressions if possible.
|
||||
*/
|
||||
void simplify();
|
||||
|
||||
/**
|
||||
* Write the expression as an elastic search expression.
|
||||
*/
|
||||
void writeDocQuery(DocQueryContext context) throws IOException;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.avaje.ebeaninternal.api;
|
||||
|
||||
public interface SpiNamedParam {
|
||||
|
||||
Object getValue();
|
||||
}
|
||||
@@ -296,6 +296,16 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
*/
|
||||
void setLoadDescription(String loadMode, String loadDescription);
|
||||
|
||||
/**
|
||||
* Check that the named parameters have had their values set.
|
||||
*/
|
||||
void checkNamedParameters();
|
||||
|
||||
/**
|
||||
* Create a named parameter placeholder.
|
||||
*/
|
||||
SpiNamedParam createNamedParameter(String parameterName);
|
||||
|
||||
/**
|
||||
* Return the joins required to support predicates on the many properties.
|
||||
*/
|
||||
@@ -542,12 +552,6 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
*/
|
||||
BindParams getBindParams();
|
||||
|
||||
/**
|
||||
* Get the orm query as a String. Only available if the query was built from
|
||||
* a string.
|
||||
*/
|
||||
String getQuery();
|
||||
|
||||
/**
|
||||
* Replace the query detail. This is used by the AutoTune feature to as a
|
||||
* fast way to set the query properties and joins.
|
||||
@@ -691,4 +695,8 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
*/
|
||||
OrmUpdateProperties getUpdateProperties();
|
||||
|
||||
/**
|
||||
* Simplify nested expression lists where possible.
|
||||
*/
|
||||
void simplifyExpressions();
|
||||
}
|
||||
|
||||
@@ -1,35 +1,25 @@
|
||||
package com.avaje.ebeaninternal.server.core;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.avaje.ebeaninternal.api.SpiBackgroundExecutor;
|
||||
import com.avaje.ebeaninternal.server.lib.DaemonExecutorService;
|
||||
import com.avaje.ebeaninternal.server.lib.DaemonScheduleThreadPool;
|
||||
import com.avaje.ebeaninternal.server.lib.DaemonThreadPool;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* The default implementation of the BackgroundExecutor.
|
||||
*/
|
||||
public class DefaultBackgroundExecutor implements SpiBackgroundExecutor {
|
||||
|
||||
private final DaemonThreadPool pool;
|
||||
|
||||
private final DaemonScheduleThreadPool schedulePool;
|
||||
|
||||
private final DaemonExecutorService pool;
|
||||
|
||||
/**
|
||||
* Construct the default implementation of BackgroundExecutor.
|
||||
*
|
||||
* @param corePoolSize
|
||||
* the core size of the thread pool.
|
||||
* @param maximumPoolSize
|
||||
* the maximum pool size before jobs are queued
|
||||
* @param keepAliveSecs
|
||||
* the time in seconds idle threads are keep alive
|
||||
* @param shutdownWaitSeconds
|
||||
* the time in seconds allowed for the pool to shutdown nicely.
|
||||
* After this the pool is forced to shutdown.
|
||||
*/
|
||||
public DefaultBackgroundExecutor(int schedulePoolSize, int corePoolSize, int maximumPoolSize, long keepAliveSecs,int shutdownWaitSeconds, String namePrefix) {
|
||||
this.pool = new DaemonThreadPool(corePoolSize, maximumPoolSize, keepAliveSecs, shutdownWaitSeconds, namePrefix);
|
||||
public DefaultBackgroundExecutor(int schedulePoolSize, int shutdownWaitSeconds, String namePrefix) {
|
||||
this.pool = new DaemonExecutorService(shutdownWaitSeconds, namePrefix);
|
||||
this.schedulePool = new DaemonScheduleThreadPool(schedulePoolSize, shutdownWaitSeconds, namePrefix+"-periodic-");
|
||||
}
|
||||
|
||||
|
||||
@@ -78,14 +78,10 @@ public class DefaultContainer implements SpiContainer {
|
||||
private SpiBackgroundExecutor createBackgroundExecutor(ServerConfig serverConfig) {
|
||||
|
||||
String namePrefix = "ebean-" + serverConfig.getName();
|
||||
|
||||
int schedulePoolSize = serverConfig.getBackgroundExecutorSchedulePoolSize();
|
||||
int corePoolSize = serverConfig.getBackgroundExecutorCorePoolSize();
|
||||
int maxPoolSize = serverConfig.getBackgroundExecutorMaxPoolSize();
|
||||
int idleSecs = serverConfig.getBackgroundExecutorIdleSecs();
|
||||
int shutdownSecs = serverConfig.getBackgroundExecutorShutdownSecs();
|
||||
|
||||
return new DefaultBackgroundExecutor(schedulePoolSize, corePoolSize, maxPoolSize, idleSecs, shutdownSecs, namePrefix);
|
||||
return new DefaultBackgroundExecutor(schedulePoolSize, shutdownSecs, namePrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
import com.avaje.ebeaninternal.server.deploy.InheritInfo;
|
||||
import com.avaje.ebeaninternal.server.el.ElFilter;
|
||||
import com.avaje.ebeaninternal.server.grammer.EqlParser;
|
||||
import com.avaje.ebeaninternal.server.lib.ShutdownManager;
|
||||
import com.avaje.ebeaninternal.server.query.CQuery;
|
||||
import com.avaje.ebeaninternal.server.query.CQueryEngine;
|
||||
@@ -893,6 +894,10 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
if (desc == null) {
|
||||
throw new PersistenceException(beanType.getName() + " is NOT an Entity Bean registered with this server?");
|
||||
}
|
||||
String named = desc.getNamedQuery(namedQuery);
|
||||
if (named != null) {
|
||||
return createQuery(beanType, named);
|
||||
}
|
||||
RawSql rawSql = desc.getNamedRawSql(namedQuery);
|
||||
if (rawSql != null) {
|
||||
DefaultOrmQuery<T> query = createQuery(beanType);
|
||||
@@ -902,6 +907,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
throw new PersistenceException("No named query called " + namedQuery + " for bean:" + beanType.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Query<T> createQuery(Class<T> beanType, String eql) {
|
||||
DefaultOrmQuery<T> query = createQuery(beanType);
|
||||
EqlParser.parse(eql, query);
|
||||
return query;
|
||||
}
|
||||
|
||||
public <T> DefaultOrmQuery<T> createQuery(Class<T> beanType) {
|
||||
BeanDescriptor<T> desc = getBeanDescriptor(beanType);
|
||||
if (desc == null) {
|
||||
@@ -954,6 +966,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
SpiQuery<T> spiQuery = (SpiQuery<T>) query;
|
||||
spiQuery.setType(type);
|
||||
spiQuery.checkNamedParameters();
|
||||
|
||||
return createQueryRequest(spiQuery, t);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.avaje.ebean.RawSql;
|
||||
import com.avaje.ebean.SqlUpdate;
|
||||
import com.avaje.ebean.Transaction;
|
||||
import com.avaje.ebean.ValuePair;
|
||||
import com.avaje.ebeaninternal.api.ConcurrencyMode;
|
||||
import com.avaje.ebean.annotation.DocStoreMode;
|
||||
import com.avaje.ebean.bean.BeanCollection;
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
@@ -16,8 +15,8 @@ import com.avaje.ebean.bean.PersistenceContext;
|
||||
import com.avaje.ebean.bean.PersistenceContextUtil;
|
||||
import com.avaje.ebean.config.EncryptKey;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.dbplatform.PlatformIdGenerator;
|
||||
import com.avaje.ebean.config.dbplatform.IdType;
|
||||
import com.avaje.ebean.config.dbplatform.PlatformIdGenerator;
|
||||
import com.avaje.ebean.event.BeanFindController;
|
||||
import com.avaje.ebean.event.BeanPersistController;
|
||||
import com.avaje.ebean.event.BeanPersistListener;
|
||||
@@ -36,6 +35,7 @@ import com.avaje.ebean.plugin.BeanType;
|
||||
import com.avaje.ebean.plugin.ExpressionPath;
|
||||
import com.avaje.ebean.plugin.Property;
|
||||
import com.avaje.ebeaninternal.api.CQueryPlanKey;
|
||||
import com.avaje.ebeaninternal.api.ConcurrencyMode;
|
||||
import com.avaje.ebeaninternal.api.LoadContext;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
@@ -111,6 +111,8 @@ public class BeanDescriptor<T> implements MetaBeanInfo, BeanType<T> {
|
||||
|
||||
private final Map<String, RawSql> namedRawSql;
|
||||
|
||||
private final Map<String, String> namedQuery;
|
||||
|
||||
public void merge(EntityBean bean, EntityBean existing) {
|
||||
|
||||
EntityBeanIntercept fromEbi = bean._ebean_getIntercept();
|
||||
@@ -414,6 +416,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo, BeanType<T> {
|
||||
this.rootBeanType = PersistenceContextUtil.root(beanType);
|
||||
this.prototypeEntityBean = createPrototypeEntityBean(beanType);
|
||||
|
||||
this.namedQuery = deploy.getNamedQuery();
|
||||
this.namedRawSql = deploy.getNamedRawSql();
|
||||
this.inheritInfo = deploy.getInheritInfo();
|
||||
|
||||
@@ -988,6 +991,13 @@ public class BeanDescriptor<T> implements MetaBeanInfo, BeanType<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the named ORM query.
|
||||
*/
|
||||
public String getNamedQuery(String name) {
|
||||
return namedQuery.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the named RawSql query.
|
||||
*/
|
||||
|
||||
@@ -53,6 +53,7 @@ import com.avaje.ebeaninternal.xmlmapping.model.XmAliasMapping;
|
||||
import com.avaje.ebeaninternal.xmlmapping.model.XmColumnMapping;
|
||||
import com.avaje.ebeaninternal.xmlmapping.model.XmEbean;
|
||||
import com.avaje.ebeaninternal.xmlmapping.model.XmEntity;
|
||||
import com.avaje.ebeaninternal.xmlmapping.model.XmNamedQuery;
|
||||
import com.avaje.ebeaninternal.xmlmapping.model.XmRawSql;
|
||||
import com.avaje.ebeanservice.docstore.api.DocStoreBeanAdapter;
|
||||
import com.avaje.ebeanservice.docstore.api.DocStoreFactory;
|
||||
@@ -395,6 +396,10 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
}
|
||||
info.addRawSql(sql.getName(), builder.create());
|
||||
}
|
||||
|
||||
for (XmNamedQuery namedQuery : entityDeploy.getNamedQuery()) {
|
||||
info.addNamedQuery(namedQuery.getName(), namedQuery.getQuery().getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Abstract base for properties mapped to an associated bean, list, set or map.
|
||||
@@ -41,6 +42,11 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty {
|
||||
|
||||
String targetIdProperty;
|
||||
|
||||
/**
|
||||
* Derived list of exported property and matching foreignKey
|
||||
*/
|
||||
protected ExportedProperty[] exportedProperties;
|
||||
|
||||
/**
|
||||
* Persist settings.
|
||||
*/
|
||||
@@ -385,4 +391,18 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty {
|
||||
+ " Perhaps an error in a @JoinColumn";
|
||||
throw new PersistenceException(msg);
|
||||
}
|
||||
|
||||
protected void bindWhereParentId(List<Object> bindValues, Object parentId) {
|
||||
|
||||
if (exportedProperties.length == 1) {
|
||||
bindValues.add(parentId);
|
||||
|
||||
} else {
|
||||
EntityBean parent = (EntityBean) parentId;
|
||||
for (int i = 0; i < exportedProperties.length; i++) {
|
||||
Object embVal = exportedProperties[i].getValue(parent);
|
||||
bindValues.add(embVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,11 +85,6 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
|
||||
|
||||
private BeanProperty mapKeyProperty;
|
||||
|
||||
/**
|
||||
* Derived list of exported property and matching foreignKey
|
||||
*/
|
||||
private ExportedProperty[] exportedProperties;
|
||||
|
||||
private String exportedPropertyBindProto = "?";
|
||||
|
||||
/**
|
||||
@@ -299,23 +294,25 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
|
||||
/**
|
||||
* Find the Id's of detail beans given a parent Id or list of parent Id's.
|
||||
*/
|
||||
public List<Object> findIdsByParentId(Object parentId, List<Object> parentIdist, Transaction t, ArrayList<Object> excludeDetailIds) {
|
||||
public List<Object> findIdsByParentId(Object parentId, List<Object> parentIdList, Transaction t, ArrayList<Object> excludeDetailIds) {
|
||||
if (parentId != null) {
|
||||
return findIdsByParentId(parentId, t, excludeDetailIds);
|
||||
} else {
|
||||
return findIdsByParentIdList(parentIdist, t, excludeDetailIds);
|
||||
return findIdsByParentIdList(parentIdList, t, excludeDetailIds);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Object> findIdsByParentId(Object parentId, Transaction t, ArrayList<Object> excludeDetailIds) {
|
||||
|
||||
String rawWhere = deriveWhereParentIdSql(false, "");
|
||||
List<Object> bindValues = new ArrayList<Object>();
|
||||
bindWhereParentId(bindValues, parentId);
|
||||
|
||||
EbeanServer server = getBeanDescriptor().getEbeanServer();
|
||||
Query<?> q = server.find(getPropertyType())
|
||||
.where().raw(rawWhere).query();
|
||||
|
||||
bindWhereParendId(1, q, parentId);
|
||||
.where()
|
||||
.raw(rawWhere, bindValues.toArray())
|
||||
.query();
|
||||
|
||||
if (excludeDetailIds != null && !excludeDetailIds.isEmpty()) {
|
||||
Expression idIn = q.getExpressionFactory().idIn(excludeDetailIds);
|
||||
@@ -371,21 +368,24 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
|
||||
query.where().raw(expr, bindValues.toArray());
|
||||
}
|
||||
|
||||
private List<Object> findIdsByParentIdList(List<Object> parentIdist, Transaction t, ArrayList<Object> excludeDetailIds) {
|
||||
private List<Object> findIdsByParentIdList(List<Object> parentIdList, Transaction t, ArrayList<Object> excludeDetailIds) {
|
||||
|
||||
String rawWhere = deriveWhereParentIdSql(true, "");
|
||||
String inClause = buildInClauseBinding(parentIdist.size(), exportedPropertyBindProto);
|
||||
String inClause = buildInClauseBinding(parentIdList.size(), exportedPropertyBindProto);
|
||||
|
||||
String expr = rawWhere + inClause;
|
||||
|
||||
EbeanServer server = getBeanDescriptor().getEbeanServer();
|
||||
Query<?> q = server.find(getPropertyType()).where().raw(expr).query();
|
||||
|
||||
int pos = 1;
|
||||
for (int i = 0; i < parentIdist.size(); i++) {
|
||||
pos = bindWhereParendId(pos, q, parentIdist.get(i));
|
||||
List<Object> bindValues = new ArrayList<Object>();
|
||||
for (int i = 0; i < parentIdList.size(); i++) {
|
||||
bindWhereParentId(bindValues, parentIdList.get(i));
|
||||
}
|
||||
|
||||
EbeanServer server = getBeanDescriptor().getEbeanServer();
|
||||
Query<?> q = server.find(getPropertyType())
|
||||
.where()
|
||||
.raw(expr, bindValues.toArray())
|
||||
.query();
|
||||
|
||||
if (excludeDetailIds != null && !excludeDetailIds.isEmpty()) {
|
||||
Expression idIn = q.getExpressionFactory().idIn(excludeDetailIds);
|
||||
q.where().not(idIn);
|
||||
@@ -690,22 +690,6 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
|
||||
}
|
||||
}
|
||||
|
||||
private int bindWhereParendId(int pos, Query<?> q, Object parentId) {
|
||||
|
||||
if (exportedProperties.length == 1) {
|
||||
q.setParameter(pos++, parentId);
|
||||
|
||||
} else {
|
||||
|
||||
EntityBean parent = (EntityBean) parentId;
|
||||
for (int i = 0; i < exportedProperties.length; i++) {
|
||||
Object embVal = exportedProperties[i].getValue(parent);
|
||||
q.setParameter(pos++, embVal);
|
||||
}
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
public void addSelectExported(DbSqlContext ctx, String tableAlias) {
|
||||
|
||||
String alias = manyToMany ? "int_" : tableAlias;
|
||||
|
||||
@@ -50,8 +50,6 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> {
|
||||
*/
|
||||
protected ImportedId importedId;
|
||||
|
||||
private ExportedProperty[] exportedProperties;
|
||||
|
||||
private String deleteByParentIdSql;
|
||||
private String deleteByParentIdInSql;
|
||||
|
||||
@@ -240,47 +238,37 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> {
|
||||
|
||||
String rawWhere = deriveWhereParentIdSql(false);
|
||||
|
||||
List<Object> bindValues = new ArrayList<Object>();
|
||||
bindWhereParentId(bindValues, parentId);
|
||||
|
||||
EbeanServer server = getBeanDescriptor().getEbeanServer();
|
||||
Query<?> q = server.find(getPropertyType())
|
||||
.where().raw(rawWhere).query();
|
||||
.where()
|
||||
.raw(rawWhere, bindValues.toArray())
|
||||
.query();
|
||||
|
||||
bindWhereParendId(q, parentId);
|
||||
return server.findIds(q, t);
|
||||
}
|
||||
|
||||
private List<Object> findIdsByParentIdList(List<Object> parentIdist, Transaction t) {
|
||||
private List<Object> findIdsByParentIdList(List<Object> parentIdList, Transaction t) {
|
||||
|
||||
String rawWhere = deriveWhereParentIdSql(true);
|
||||
String inClause = targetIdBinder.getIdInValueExpr(parentIdist.size());
|
||||
String inClause = targetIdBinder.getIdInValueExpr(parentIdList.size());
|
||||
|
||||
String expr = rawWhere + inClause;
|
||||
|
||||
List<Object> bindValues = new ArrayList<Object>();
|
||||
for (int i = 0; i < parentIdList.size(); i++) {
|
||||
bindWhereParentId(bindValues, parentIdList.get(i));
|
||||
}
|
||||
|
||||
EbeanServer server = getBeanDescriptor().getEbeanServer();
|
||||
Query<?> q = (Query<?>) server.find(getPropertyType())
|
||||
.where().raw(expr);
|
||||
|
||||
for (int i = 0; i < parentIdist.size(); i++) {
|
||||
bindWhereParendId(q, parentIdist.get(i));
|
||||
}
|
||||
.where().raw(expr, bindValues.toArray());
|
||||
|
||||
return server.findIds(q, t);
|
||||
}
|
||||
|
||||
private void bindWhereParendId(Query<?> q, Object parentId) {
|
||||
|
||||
if (exportedProperties.length == 1) {
|
||||
q.setParameter(1, parentId);
|
||||
|
||||
} else {
|
||||
int pos = 1;
|
||||
EntityBean parent = (EntityBean) parentId;
|
||||
for (int i = 0; i < exportedProperties.length; i++) {
|
||||
Object embVal = exportedProperties[i].getValue(parent);
|
||||
q.setParameter(pos++, embVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void addFkey() {
|
||||
if (importedId != null) {
|
||||
importedId.addFkeys(name);
|
||||
|
||||
@@ -46,6 +46,8 @@ import java.util.Map;
|
||||
*/
|
||||
public class DeployBeanDescriptor<T> {
|
||||
|
||||
private static final Map<String, String> EMPTY_NAMED_QUERY = new HashMap<String, String>();
|
||||
|
||||
private static final Map<String, RawSql> EMPTY_RAW_MAP = new HashMap<String, RawSql>();
|
||||
|
||||
private static class PropOrder implements Comparator<DeployBeanProperty> {
|
||||
@@ -73,6 +75,8 @@ public class DeployBeanDescriptor<T> {
|
||||
|
||||
private Map<String, RawSql> namedRawSql;
|
||||
|
||||
private Map<String, String> namedQuery;
|
||||
|
||||
private EntityType entityType;
|
||||
|
||||
private DeployBeanPropertyAssocOne<?> unidirectional;
|
||||
@@ -1055,6 +1059,23 @@ public class DeployBeanDescriptor<T> {
|
||||
return serverConfig.getDocStoreConfig().getPersist();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the named ORM queries.
|
||||
*/
|
||||
public Map<String, String> getNamedQuery() {
|
||||
return (namedQuery != null) ? namedQuery : EMPTY_NAMED_QUERY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a named query.
|
||||
*/
|
||||
public void addNamedQuery(String name, String query) {
|
||||
if (namedQuery == null) {
|
||||
namedQuery = new LinkedHashMap<String, String>();
|
||||
}
|
||||
namedQuery.put(name, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the named RawSql queries.
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,8 @@ import javax.persistence.AttributeOverride;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
@@ -177,6 +179,18 @@ public class AnnotationClass extends AnnotationParser {
|
||||
if (cache != null && !disableL2Cache) {
|
||||
descriptor.setCache(cache);
|
||||
}
|
||||
|
||||
NamedQueries namedQueries = cls.getAnnotation(NamedQueries.class);
|
||||
if (namedQueries != null) {
|
||||
for (NamedQuery namedQuery : namedQueries.value()) {
|
||||
descriptor.addNamedQuery(namedQuery.name(), namedQuery.query());
|
||||
}
|
||||
}
|
||||
|
||||
NamedQuery namedQuery = cls.getAnnotation(NamedQuery.class);
|
||||
if (namedQuery != null) {
|
||||
descriptor.addNamedQuery(namedQuery.name(), namedQuery.query());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -82,4 +82,11 @@ public class DeployBeanInfo<T> {
|
||||
public void addRawSql(String name, RawSql rawSql) {
|
||||
descriptor.addRawSql(name, rawSql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the named query.
|
||||
*/
|
||||
public void addNamedQuery(String name, String query) {
|
||||
descriptor.addNamedQuery(name, query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,11 @@ public abstract class AbstractExpression implements SpiExpression {
|
||||
this.propName = propName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simplify() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getIdEqualTo(String idName) {
|
||||
// override on SimpleExpression
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.avaje.ebeaninternal.server.expression;
|
||||
|
||||
/**
|
||||
* Abstract expression that helps with named parameter use.
|
||||
*/
|
||||
public abstract class AbstractValueExpression extends AbstractExpression {
|
||||
|
||||
protected final Object bindValue;
|
||||
|
||||
/**
|
||||
* Construct with property name and potential named parameter.
|
||||
*/
|
||||
protected AbstractValueExpression(String propName, Object bindValue) {
|
||||
super(propName);
|
||||
this.bindValue = bindValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the bind value taking into account named parameters.
|
||||
*/
|
||||
protected Object value() {
|
||||
return NamedParamHelp.value(bindValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the String bind value taking into account named parameters.
|
||||
*/
|
||||
protected String strValue() {
|
||||
return NamedParamHelp.valueAsString(bindValue);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,21 +14,29 @@ class BetweenExpression extends AbstractExpression {
|
||||
|
||||
private final Object valueLow;
|
||||
|
||||
BetweenExpression(String propertyName, Object valLo, Object valHigh) {
|
||||
BetweenExpression(String propertyName, Object valueLow, Object valueHigh) {
|
||||
super(propertyName);
|
||||
this.valueLow = valLo;
|
||||
this.valueHigh = valHigh;
|
||||
this.valueLow = valueLow;
|
||||
this.valueHigh = valueHigh;
|
||||
}
|
||||
|
||||
private Object low() {
|
||||
return NamedParamHelp.value(valueLow);
|
||||
}
|
||||
|
||||
private Object high() {
|
||||
return NamedParamHelp.value(valueHigh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
context.writeRange(propName, Op.GT_EQ, valueLow, Op.LT_EQ, valueHigh);
|
||||
context.writeRange(propName, Op.GT_EQ, low(), Op.LT_EQ, high());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
request.addBindValue(valueLow);
|
||||
request.addBindValue(valueHigh);
|
||||
request.addBindValue(low());
|
||||
request.addBindValue(high());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,8 +53,8 @@ class BetweenExpression extends AbstractExpression {
|
||||
|
||||
@Override
|
||||
public int queryBindHash() {
|
||||
int hc = valueLow.hashCode();
|
||||
hc = hc * 31 + valueHigh.hashCode();
|
||||
int hc = low().hashCode();
|
||||
hc = hc * 31 + high().hashCode();
|
||||
return hc;
|
||||
}
|
||||
|
||||
@@ -63,7 +71,7 @@ class BetweenExpression extends AbstractExpression {
|
||||
@Override
|
||||
public boolean isSameByBind(SpiExpression other) {
|
||||
BetweenExpression that = (BetweenExpression) other;
|
||||
return valueLow.equals(that.valueLow)
|
||||
&& valueHigh.equals(that.valueHigh);
|
||||
return low().equals(that.low())
|
||||
&& high().equals(that.high());
|
||||
}
|
||||
}
|
||||
|
||||
+9
-5
@@ -32,11 +32,15 @@ class BetweenPropertyExpression extends NonPrepareExpression {
|
||||
return propName;
|
||||
}
|
||||
|
||||
private Object val() {
|
||||
return NamedParamHelp.value(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
context.startBoolMust();
|
||||
context.writeSimple(Op.LT_EQ, lowProperty, value);
|
||||
context.writeSimple(Op.GT_EQ, highProperty, value);
|
||||
context.writeSimple(Op.LT_EQ, lowProperty, val());
|
||||
context.writeSimple(Op.GT_EQ, highProperty, val());
|
||||
context.endBool();
|
||||
}
|
||||
|
||||
@@ -72,7 +76,7 @@ class BetweenPropertyExpression extends NonPrepareExpression {
|
||||
|
||||
@Override
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
request.addBindValue(value);
|
||||
request.addBindValue(val());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +93,7 @@ class BetweenPropertyExpression extends NonPrepareExpression {
|
||||
|
||||
@Override
|
||||
public int queryBindHash() {
|
||||
return value.hashCode();
|
||||
return val().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,6 +110,6 @@ class BetweenPropertyExpression extends NonPrepareExpression {
|
||||
@Override
|
||||
public boolean isSameByBind(SpiExpression other) {
|
||||
BetweenPropertyExpression that = (BetweenPropertyExpression) other;
|
||||
return value.equals(that.value);
|
||||
return val().equals(that.val());
|
||||
}
|
||||
}
|
||||
|
||||
+13
-9
@@ -7,18 +7,22 @@ import com.avaje.ebeaninternal.server.el.ElPropertyValue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
class CaseInsensitiveEqualExpression extends AbstractExpression {
|
||||
class CaseInsensitiveEqualExpression extends AbstractValueExpression {
|
||||
|
||||
private final String value;
|
||||
CaseInsensitiveEqualExpression(String propertyName, Object value) {
|
||||
super(propertyName, value);
|
||||
}
|
||||
|
||||
CaseInsensitiveEqualExpression(String propertyName, String value) {
|
||||
super(propertyName);
|
||||
this.value = value.toLowerCase();
|
||||
/**
|
||||
* Return the bind value taking into account named parameters.
|
||||
*/
|
||||
private String val() {
|
||||
return strValue().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
context.writeIEqualTo(propName, value);
|
||||
context.writeIEqualTo(propName, val());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,7 +35,7 @@ class CaseInsensitiveEqualExpression extends AbstractExpression {
|
||||
request.addBindEncryptKey(encryptKey);
|
||||
}
|
||||
|
||||
request.addBindValue(value);
|
||||
request.addBindValue(val());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +58,7 @@ class CaseInsensitiveEqualExpression extends AbstractExpression {
|
||||
|
||||
@Override
|
||||
public int queryBindHash() {
|
||||
return value.hashCode();
|
||||
return val().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,6 +74,6 @@ class CaseInsensitiveEqualExpression extends AbstractExpression {
|
||||
@Override
|
||||
public boolean isSameByBind(SpiExpression other) {
|
||||
CaseInsensitiveEqualExpression that = (CaseInsensitiveEqualExpression) other;
|
||||
return value.equals(that.value);
|
||||
return val().equals(that.val());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,11 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simplify() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
if (!list.isEmpty()) {
|
||||
|
||||
@@ -157,6 +157,13 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
return new CaseInsensitiveEqualExpression(propertyName, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create for named parameter use (and without support for equalsWithNullAsNoop).
|
||||
*/
|
||||
public Expression ieqObject(String propertyName, Object value) {
|
||||
return new CaseInsensitiveEqualExpression(propertyName, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Between - property between the two given values.
|
||||
*/
|
||||
@@ -251,6 +258,11 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
return new DefaultExampleExpression(checkEntityBean(example), caseInsensitive, likeType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression like(String propertyName, Object value, boolean caseInsensitive, LikeType likeType) {
|
||||
return new LikeExpression(propertyName, value, caseInsensitive, likeType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like - property like value where the value contains the SQL wild card
|
||||
* characters % (percentage) and _ (underscore).
|
||||
|
||||
@@ -97,6 +97,16 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
}
|
||||
}
|
||||
|
||||
void simplifyEntries() {
|
||||
for (SpiExpression element : list) {
|
||||
element.simplify();
|
||||
}
|
||||
}
|
||||
|
||||
public void simplify() {
|
||||
simplifyEntries();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write being aware if it is the Top level "text" expressions.
|
||||
* <p>
|
||||
|
||||
@@ -36,6 +36,11 @@ class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpress
|
||||
this.subQuery = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simplify() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
throw new IllegalStateException("Not supported");
|
||||
|
||||
@@ -1,35 +1,54 @@
|
||||
package com.avaje.ebeaninternal.server.expression;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebean.event.BeanQueryRequest;
|
||||
import com.avaje.ebeaninternal.api.HashQueryPlanBuilder;
|
||||
import com.avaje.ebeaninternal.api.SpiExpression;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionRequest;
|
||||
import com.avaje.ebeaninternal.server.el.ElPropertyValue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
class InExpression extends AbstractExpression {
|
||||
|
||||
private final boolean not;
|
||||
|
||||
private final Object[] values;
|
||||
private final Collection<?> sourceValues;
|
||||
|
||||
InExpression(String propertyName, Collection<?> coll, boolean not) {
|
||||
private Object[] bindValues;
|
||||
|
||||
InExpression(String propertyName, Collection<?> sourceValues, boolean not) {
|
||||
super(propertyName);
|
||||
this.values = coll.toArray(new Object[coll.size()]);
|
||||
this.sourceValues = sourceValues;
|
||||
this.not = not;
|
||||
}
|
||||
|
||||
InExpression(String propertyName, Object[] array, boolean not) {
|
||||
super(propertyName);
|
||||
this.values = array;
|
||||
this.sourceValues = Arrays.asList(array);
|
||||
this.not = not;
|
||||
}
|
||||
|
||||
private Object[] values() {
|
||||
List<Object> vals = new ArrayList<Object>();
|
||||
for (Object sourceValue : sourceValues) {
|
||||
NamedParamHelp.valueAdd(vals, sourceValue);
|
||||
}
|
||||
return vals.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareExpression(BeanQueryRequest<?> request) {
|
||||
bindValues = values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
context.writeIn(propName, values, not);
|
||||
context.writeIn(propName, values(), not);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,13 +59,13 @@ class InExpression extends AbstractExpression {
|
||||
prop = null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
for (int i = 0; i < bindValues.length; i++) {
|
||||
if (prop == null) {
|
||||
request.addBindValue(values[i]);
|
||||
request.addBindValue(bindValues[i]);
|
||||
|
||||
} else {
|
||||
// extract the id values from the bean
|
||||
Object[] ids = prop.getAssocIdValues((EntityBean) values[i]);
|
||||
Object[] ids = prop.getAssocIdValues((EntityBean) bindValues[i]);
|
||||
if (ids != null) {
|
||||
for (int j = 0; j < ids.length; j++) {
|
||||
request.addBindValue(ids[j]);
|
||||
@@ -59,7 +78,7 @@ class InExpression extends AbstractExpression {
|
||||
@Override
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
|
||||
if (values.length == 0) {
|
||||
if (bindValues.length == 0) {
|
||||
String expr = not ? "1=1" : "1=0";
|
||||
request.append(expr);
|
||||
return;
|
||||
@@ -72,7 +91,7 @@ class InExpression extends AbstractExpression {
|
||||
|
||||
if (prop != null) {
|
||||
request.append(prop.getAssocIdInExpr(propName));
|
||||
String inClause = prop.getAssocIdInValueExpr(values.length);
|
||||
String inClause = prop.getAssocIdInValueExpr(bindValues.length);
|
||||
request.append(inClause);
|
||||
|
||||
} else {
|
||||
@@ -81,7 +100,7 @@ class InExpression extends AbstractExpression {
|
||||
request.append(" not");
|
||||
}
|
||||
request.append(" in (?");
|
||||
for (int i = 1; i < values.length; i++) {
|
||||
for (int i = 1; i < bindValues.length; i++) {
|
||||
request.append(", ").append("?");
|
||||
}
|
||||
|
||||
@@ -94,15 +113,15 @@ class InExpression extends AbstractExpression {
|
||||
*/
|
||||
@Override
|
||||
public void queryPlanHash(HashQueryPlanBuilder builder) {
|
||||
builder.add(InExpression.class).add(propName).add(values.length).add(not);
|
||||
builder.bind(values.length);
|
||||
builder.add(InExpression.class).add(propName).add(bindValues.length).add(not);
|
||||
builder.bind(bindValues.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int queryBindHash() {
|
||||
int hc = 31;
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
hc = 31 * hc + values[i].hashCode();
|
||||
for (int i = 0; i < bindValues.length; i++) {
|
||||
hc = 31 * hc + bindValues[i].hashCode();
|
||||
}
|
||||
return hc;
|
||||
}
|
||||
@@ -116,17 +135,17 @@ class InExpression extends AbstractExpression {
|
||||
InExpression that = (InExpression) other;
|
||||
return propName.equals(that.propName)
|
||||
&& not == that.not
|
||||
&& values.length == that.values.length;
|
||||
&& bindValues.length == that.bindValues.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameByBind(SpiExpression other) {
|
||||
InExpression that = (InExpression) other;
|
||||
if (this.values.length != that.values.length) {
|
||||
if (this.bindValues.length != that.bindValues.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (!values[i].equals(that.values[i])) {
|
||||
for (int i = 0; i < bindValues.length; i++) {
|
||||
if (!bindValues[i].equals(that.bindValues[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,11 @@ class InQueryExpression extends AbstractExpression implements UnsupportedDocStor
|
||||
this.bindParams = bindParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simplify() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
throw new IllegalStateException("Not supported");
|
||||
|
||||
@@ -39,9 +39,9 @@ import java.util.Set;
|
||||
*/
|
||||
class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, ExpressionList<T> {
|
||||
|
||||
protected final DefaultExpressionList<T> exprList;
|
||||
protected DefaultExpressionList<T> exprList;
|
||||
|
||||
protected final Junction.Type type;
|
||||
protected Junction.Type type;
|
||||
|
||||
JunctionExpression(Junction.Type type, Query<T> query, ExpressionList<T> parent) {
|
||||
this.type = type;
|
||||
@@ -56,6 +56,31 @@ class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, Expression
|
||||
this.exprList = exprList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simplify nested expressions where possible.
|
||||
* <p>
|
||||
* This is expected to only used after expressions are built via query language parsing.
|
||||
* </p>
|
||||
*/
|
||||
public void simplify() {
|
||||
exprList.simplifyEntries();
|
||||
|
||||
List<SpiExpression> list = exprList.list;
|
||||
if (list.size() == 1 && list.get(0) instanceof JunctionExpression) {
|
||||
JunctionExpression nested = (JunctionExpression)list.get(0);
|
||||
if (type == Type.AND && !nested.type.isText()) {
|
||||
// and (and (a, b, c)) -> and (a, b, c)
|
||||
// and (not (a, b, c)) -> not (a, b, c)
|
||||
// and (or (a, b, c)) -> or (a, b, c)
|
||||
this.exprList = nested.exprList;
|
||||
this.type = nested.type;
|
||||
} else if (type == Type.NOT && nested.type == Type.AND) {
|
||||
// not (and (a, b, c)) -> not (a, b, c)
|
||||
this.exprList = nested.exprList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SpiExpression copyForPlanKey() {
|
||||
return new JunctionExpression<T>(type, exprList.copyForPlanKey());
|
||||
}
|
||||
|
||||
@@ -8,24 +8,21 @@ import com.avaje.ebeaninternal.server.el.ElPropertyValue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
class LikeExpression extends AbstractExpression {
|
||||
|
||||
private final String val;
|
||||
class LikeExpression extends AbstractValueExpression {
|
||||
|
||||
private final boolean caseInsensitive;
|
||||
|
||||
private final LikeType type;
|
||||
|
||||
LikeExpression(String propertyName, String value, boolean caseInsensitive, LikeType type) {
|
||||
super(propertyName);
|
||||
LikeExpression(String propertyName, Object value, boolean caseInsensitive, LikeType type) {
|
||||
super(propertyName, value);
|
||||
this.caseInsensitive = caseInsensitive;
|
||||
this.type = type;
|
||||
this.val = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
context.writeLike(propName, val, type, caseInsensitive);
|
||||
context.writeLike(propName, strValue(), type, caseInsensitive);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,7 +35,7 @@ class LikeExpression extends AbstractExpression {
|
||||
request.addBindEncryptKey(encryptKey);
|
||||
}
|
||||
|
||||
String bindValue = getValue(val, caseInsensitive, type);
|
||||
String bindValue = getValue(strValue(), caseInsensitive, type);
|
||||
request.addBindValue(bindValue);
|
||||
}
|
||||
|
||||
@@ -74,7 +71,7 @@ class LikeExpression extends AbstractExpression {
|
||||
|
||||
@Override
|
||||
public int queryBindHash() {
|
||||
return val.hashCode();
|
||||
return strValue().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,7 +89,7 @@ class LikeExpression extends AbstractExpression {
|
||||
@Override
|
||||
public boolean isSameByBind(SpiExpression other) {
|
||||
LikeExpression that = (LikeExpression) other;
|
||||
return val.equals(that.val);
|
||||
return strValue().equals(that.strValue());
|
||||
}
|
||||
|
||||
private static String getValue(String value, boolean caseInsensitive, LikeType type) {
|
||||
|
||||
@@ -57,6 +57,11 @@ abstract class LogicExpression implements SpiExpression {
|
||||
this.expTwo = (SpiExpression) expTwo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simplify() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.avaje.ebeaninternal.server.expression;
|
||||
|
||||
import com.avaje.ebeaninternal.api.SpiNamedParam;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Helper for evaluating named parameters.
|
||||
*/
|
||||
class NamedParamHelp {
|
||||
|
||||
/**
|
||||
* Return the bind value taking into account named parameters.
|
||||
*/
|
||||
static Object value(Object val) {
|
||||
if (val instanceof SpiNamedParam) {
|
||||
return ((SpiNamedParam) val).getValue();
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value as a string.
|
||||
*/
|
||||
static String valueAsString(Object val) {
|
||||
Object value = value(val);
|
||||
return (value == null) ? null : value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the potentially named parameter(s) to the values.
|
||||
*/
|
||||
public static void valueAdd(List<Object> values, Object sourceValue) {
|
||||
|
||||
Object value = value(sourceValue);
|
||||
if (value instanceof Collection) {
|
||||
values.addAll((Collection)value);
|
||||
} else {
|
||||
values.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -24,6 +24,11 @@ class NestedPathWrapperExpression implements SpiExpression {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simplify() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
context.startNested(nestedPath);
|
||||
|
||||
@@ -8,6 +8,11 @@ import com.avaje.ebeaninternal.api.SpiExpression;
|
||||
*/
|
||||
abstract class NonPrepareExpression implements SpiExpression {
|
||||
|
||||
@Override
|
||||
public void simplify() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareExpression(BeanQueryRequest<?> request) {
|
||||
// do nothing
|
||||
|
||||
@@ -17,6 +17,11 @@ class NoopExpression implements SpiExpression {
|
||||
|
||||
protected static final NoopExpression INSTANCE = new NoopExpression();
|
||||
|
||||
@Override
|
||||
public void simplify() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiExpression copyForPlanKey() {
|
||||
return this;
|
||||
|
||||
@@ -22,6 +22,11 @@ final class NotExpression implements SpiExpression {
|
||||
this.exp = (SpiExpression) exp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simplify() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
context.startBoolMustNot();
|
||||
|
||||
@@ -9,22 +9,19 @@ import com.avaje.ebeaninternal.server.el.ElPropertyValue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class SimpleExpression extends AbstractExpression {
|
||||
public class SimpleExpression extends AbstractValueExpression {
|
||||
|
||||
private final Op type;
|
||||
|
||||
private final Object value;
|
||||
|
||||
public SimpleExpression(String propertyName, Op type, Object value) {
|
||||
super(propertyName);
|
||||
super(propertyName, value);
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getIdEqualTo(String idName) {
|
||||
if (type == Op.EQ && idName.equals(propName)) {
|
||||
return value;
|
||||
return value();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -37,13 +34,13 @@ public class SimpleExpression extends AbstractExpression {
|
||||
ExpressionPath prop = context.getExpressionPath(propName);
|
||||
if (prop != null && prop.isAssocId()) {
|
||||
String idName = prop.getAssocIdExpression(propName, "");
|
||||
Object[] ids = prop.getAssocIdValues((EntityBean) value);
|
||||
Object[] ids = prop.getAssocIdValues((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);
|
||||
context.writeSimple(type, propName, value());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +53,7 @@ public class SimpleExpression extends AbstractExpression {
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
return value();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,7 +62,7 @@ public class SimpleExpression extends AbstractExpression {
|
||||
ElPropertyValue prop = getElProp(request);
|
||||
if (prop != null) {
|
||||
if (prop.isAssocId()) {
|
||||
Object[] ids = prop.getAssocIdValues((EntityBean) value);
|
||||
Object[] ids = prop.getAssocIdValues((EntityBean) value());
|
||||
if (ids != null) {
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
request.addBindValue(ids[i]);
|
||||
@@ -83,7 +80,7 @@ public class SimpleExpression extends AbstractExpression {
|
||||
// prop.getBeanProperty().getScalarType();
|
||||
}
|
||||
|
||||
request.addBindValue(value);
|
||||
request.addBindValue(value());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,7 +112,7 @@ public class SimpleExpression extends AbstractExpression {
|
||||
|
||||
@Override
|
||||
public int queryBindHash() {
|
||||
return value.hashCode();
|
||||
return value().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,6 +129,6 @@ public class SimpleExpression extends AbstractExpression {
|
||||
@Override
|
||||
public boolean isSameByBind(SpiExpression other) {
|
||||
SimpleExpression that = (SimpleExpression) other;
|
||||
return value.equals(that.value);
|
||||
return value().equals(that.value());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,374 @@
|
||||
package com.avaje.ebeaninternal.server.grammer;
|
||||
|
||||
import com.avaje.ebean.Expression;
|
||||
import com.avaje.ebean.ExpressionList;
|
||||
import com.avaje.ebean.FetchConfig;
|
||||
import com.avaje.ebean.LikeType;
|
||||
import com.avaje.ebean.OrderBy;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.grammer.antlr.EQLBaseListener;
|
||||
import com.avaje.ebeaninternal.server.grammer.antlr.EQLLexer;
|
||||
import com.avaje.ebeaninternal.server.grammer.antlr.EQLParser;
|
||||
import com.avaje.ebeaninternal.server.util.ArrayStack;
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class EqlAdapter<T> extends EQLBaseListener {
|
||||
|
||||
private static final OperatorMapping operatorMapping = new OperatorMapping();
|
||||
|
||||
private static final String DISTINCT = "distinct";
|
||||
|
||||
private static final String NULLS = "nulls";
|
||||
|
||||
private static final String ASC = "asc";
|
||||
|
||||
private final SpiQuery<T> query;
|
||||
|
||||
private final EqlAdapterHelper helper;
|
||||
|
||||
private ArrayStack<ExpressionList<T>> textStack;
|
||||
|
||||
private ArrayStack<ExpressionList<T>> whereStack;
|
||||
|
||||
private boolean textMode;
|
||||
|
||||
private List<Object> inValues;
|
||||
|
||||
private String inPropertyName;
|
||||
|
||||
public EqlAdapter(SpiQuery<T> query) {
|
||||
this.query = query;
|
||||
this.helper = new EqlAdapterHelper(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current expression list that expressions should be added to.
|
||||
*/
|
||||
protected ExpressionList<T> peekExprList() {
|
||||
|
||||
if (textMode) {
|
||||
// return the current text expression list
|
||||
return _peekText();
|
||||
}
|
||||
|
||||
if (whereStack == null) {
|
||||
whereStack = new ArrayStack<ExpressionList<T>>();
|
||||
whereStack.push(query.where());
|
||||
}
|
||||
// return the current expression list
|
||||
return whereStack.peek();
|
||||
}
|
||||
|
||||
private ExpressionList<T> _peekText() {
|
||||
if (textStack == null) {
|
||||
textStack = new ArrayStack<ExpressionList<T>>();
|
||||
// empty so push on the queries base expression list
|
||||
textStack.push(query.text());
|
||||
}
|
||||
// return the current expression list
|
||||
return textStack.peek();
|
||||
}
|
||||
|
||||
/**
|
||||
* Push the expression list onto the appropriate stack.
|
||||
*/
|
||||
private void pushExprList(ExpressionList<T> list) {
|
||||
if (textMode) {
|
||||
textStack.push(list);
|
||||
} else {
|
||||
whereStack.push(list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End a list of expressions added by 'OR'.
|
||||
*/
|
||||
private void popJunction() {
|
||||
if (textMode) {
|
||||
textStack.pop();
|
||||
} else {
|
||||
whereStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterSelect_clause(EQLParser.Select_clauseContext ctx) {
|
||||
|
||||
checkChildren(ctx, 4);
|
||||
if (DISTINCT.equals(child(ctx, 1))) {
|
||||
query.setDistinct(true);
|
||||
query.select(child(ctx, 3));
|
||||
} else {
|
||||
query.select(child(ctx, 2));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterFetch_path(EQLParser.Fetch_pathContext ctx) {
|
||||
|
||||
int childCount = ctx.getChildCount();
|
||||
checkChildren(ctx, 2);
|
||||
String path = child(ctx, 1);
|
||||
|
||||
int noPropertiesLength = 2;
|
||||
|
||||
FetchConfig fetchConfig = ParseFetchConfig.parse(path);
|
||||
if (fetchConfig != null) {
|
||||
noPropertiesLength = 3;
|
||||
path = child(ctx, 2);
|
||||
}
|
||||
if (childCount == noPropertiesLength) {
|
||||
query.fetch(path, fetchConfig);
|
||||
|
||||
} else {
|
||||
String fetchProperties = trimParenthesis(ctx.getChild(noPropertiesLength).getText());
|
||||
query.fetch(path, fetchProperties, fetchConfig);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterOrderby_property(EQLParser.Orderby_propertyContext ctx) {
|
||||
|
||||
int childCount = ctx.getChildCount();
|
||||
|
||||
String path = child(ctx, 0);
|
||||
boolean asc = true;
|
||||
String nulls = null;
|
||||
String nullsFirstLast = null;
|
||||
|
||||
if (childCount == 3) {
|
||||
asc = child(ctx, 1).startsWith(ASC);
|
||||
nullsFirstLast = ctx.getChild(2).getChild(1).getText();
|
||||
nulls = NULLS;
|
||||
|
||||
} else if (childCount == 2) {
|
||||
String firstChild = child(ctx, 1);
|
||||
if (firstChild.startsWith(NULLS)) {
|
||||
nullsFirstLast = ctx.getChild(1).getChild(1).getText();
|
||||
nulls = NULLS;
|
||||
} else {
|
||||
asc = firstChild.startsWith(ASC);
|
||||
}
|
||||
}
|
||||
|
||||
query.orderBy().add(new OrderBy.Property(path, asc, nulls, nullsFirstLast));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterLimit_clause(EQLParser.Limit_clauseContext ctx) {
|
||||
|
||||
try {
|
||||
String limitValue = child(ctx, 1);
|
||||
query.setMaxRows(Integer.parseInt(limitValue));
|
||||
|
||||
int childCount = ctx.getChildCount();
|
||||
if (childCount == 3) {
|
||||
ParseTree offsetTree = ctx.getChild(2);
|
||||
String offsetValue = offsetTree.getChild(1).getText();
|
||||
query.setFirstRow(Integer.parseInt(offsetValue));
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IllegalArgumentException("Error parsing limit or offset parameter - not an integer", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim leading '(' and trailing ')'
|
||||
*/
|
||||
private String trimParenthesis(String text) {
|
||||
text = text.substring(1);
|
||||
text = text.substring(0, text.length()-1);
|
||||
return text;
|
||||
}
|
||||
|
||||
private String getLeftHandSidePath(ParserRuleContext ctx) {
|
||||
TerminalNode pathToken = ctx.getToken(EQLLexer.PATH_VARIABLE, 0);
|
||||
return pathToken.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterBetween_expression(EQLParser.Between_expressionContext ctx) {
|
||||
|
||||
checkChildren(ctx, 5);
|
||||
String path = getLeftHandSidePath(ctx);
|
||||
EqlOperator op = getOperator(ctx);
|
||||
if (op != EqlOperator.BETWEEN) {
|
||||
throw new IllegalStateException("Expecting BETWEEN operator but got "+op);
|
||||
}
|
||||
helper.addBetween(path, child(ctx,2), child(ctx,4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx) {
|
||||
checkChildren(ctx, 5);
|
||||
String rawValue = child(ctx,0);
|
||||
EqlOperator op = getOperator(ctx);
|
||||
if (op != EqlOperator.BETWEEN) {
|
||||
throw new IllegalStateException("Expecting BETWEEN operator but got "+op);
|
||||
}
|
||||
helper.addBetweenProperty(rawValue, child(ctx,2), child(ctx,4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterIn_expression(EQLParser.In_expressionContext ctx) {
|
||||
this.inValues = new ArrayList<Object>();
|
||||
this.inPropertyName = getLeftHandSidePath(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterIn_value(EQLParser.In_valueContext ctx) {
|
||||
int childCount = ctx.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
String text = child(ctx, i);
|
||||
if (isValue(text)) {
|
||||
inValues.add(helper.bind(text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String child(ParserRuleContext ctx, int position) {
|
||||
ParseTree child = ctx.getChild(position);
|
||||
return child.getText();
|
||||
}
|
||||
|
||||
private boolean isValue(String text) {
|
||||
if (text.length() == 1 && (text.equals("(") || text.equals(")") || text.equals(","))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitIn_expression(EQLParser.In_expressionContext ctx) {
|
||||
helper.addIn(inPropertyName, inValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterIsNull_expression(EQLParser.IsNull_expressionContext ctx) {
|
||||
String path = getLeftHandSidePath(ctx);
|
||||
peekExprList().isNull(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx) {
|
||||
String path = getLeftHandSidePath(ctx);
|
||||
peekExprList().isNotNull(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx) {
|
||||
String path = getLeftHandSidePath(ctx);
|
||||
peekExprList().isEmpty(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx) {
|
||||
String path = getLeftHandSidePath(ctx);
|
||||
peekExprList().isNotEmpty(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterLike_expression(EQLParser.Like_expressionContext ctx) {
|
||||
addExpression(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterComparison_expression(EQLParser.Comparison_expressionContext ctx) {
|
||||
addExpression(ctx);
|
||||
}
|
||||
|
||||
private void addExpression(ParserRuleContext ctx) {
|
||||
int childCount = ctx.getChildCount();
|
||||
if (childCount < 3) {
|
||||
throw new IllegalStateException("expecting 3 children for comparison? " + ctx);
|
||||
}
|
||||
String path = getLeftHandSidePath(ctx);
|
||||
String operator = child(ctx, 1);
|
||||
EqlOperator op = operatorMapping.get(operator);
|
||||
if (op == null) {
|
||||
throw new IllegalStateException("No operator found for " + operator);
|
||||
}
|
||||
|
||||
// RHS is Path, Literal or Named input parameter
|
||||
helper.addExpression(path, op, child(ctx, 2));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void enterConditional_term(EQLParser.Conditional_termContext ctx) {
|
||||
int childCount = ctx.getChildCount();
|
||||
if (childCount > 1) {
|
||||
pushExprList(peekExprList().and());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitConditional_term(EQLParser.Conditional_termContext ctx) {
|
||||
if (ctx.getChildCount() > 1) {
|
||||
popJunction();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterConditional_expression(EQLParser.Conditional_expressionContext ctx) {
|
||||
if (ctx.getChildCount() > 1) {
|
||||
pushExprList(peekExprList().or());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitConditional_expression(EQLParser.Conditional_expressionContext ctx) {
|
||||
if (ctx.getChildCount() > 1) {
|
||||
popJunction();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterConditional_factor(EQLParser.Conditional_factorContext ctx) {
|
||||
if (ctx.getChildCount() > 1) {
|
||||
pushExprList(peekExprList().not());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitConditional_factor(EQLParser.Conditional_factorContext ctx) {
|
||||
if (ctx.getChildCount() > 1) {
|
||||
popJunction();
|
||||
}
|
||||
}
|
||||
|
||||
private EqlOperator getOperator(ParserRuleContext ctx) {
|
||||
String operator = child(ctx,1);
|
||||
EqlOperator op = operatorMapping.get(operator);
|
||||
if (op == null) {
|
||||
throw new IllegalStateException("No operator found for " + operator);
|
||||
}
|
||||
return op;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for the minimum number of children.
|
||||
*/
|
||||
private void checkChildren(ParserRuleContext ctx, int min) {
|
||||
if (ctx.getChildCount() < min) {
|
||||
throw new IllegalStateException("expecting " + min + " children for comparison? " + ctx);
|
||||
}
|
||||
}
|
||||
|
||||
public Object namedParam(String parameterName) {
|
||||
return query.createNamedParameter(parameterName);
|
||||
}
|
||||
|
||||
public Expression like(boolean caseInsensitive, LikeType likeType, String property, Object bindValue) {
|
||||
return query.getExpressionFactory().like(property, bindValue, caseInsensitive, likeType);
|
||||
}
|
||||
|
||||
public Expression ieq(String property, Object bindValue) {
|
||||
return query.getExpressionFactory().ieqObject(property, bindValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.avaje.ebeaninternal.server.grammer;
|
||||
|
||||
import com.avaje.ebean.ExpressionList;
|
||||
import com.avaje.ebean.LikeType;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
class EqlAdapterHelper {
|
||||
|
||||
private final EqlAdapter owner;
|
||||
|
||||
public EqlAdapterHelper(EqlAdapter owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
enum ValueType {
|
||||
NAMED_PARAM,
|
||||
STRING,
|
||||
BOOL,
|
||||
NUMBER
|
||||
}
|
||||
|
||||
private ValueType getValueType(String valueAsText) {
|
||||
|
||||
char firstChar = Character.toLowerCase(valueAsText.charAt(0));
|
||||
switch (firstChar) {
|
||||
case ':':
|
||||
return ValueType.NAMED_PARAM;
|
||||
case 't':
|
||||
return ValueType.BOOL;
|
||||
case 'f':
|
||||
return ValueType.BOOL;
|
||||
case '\'':
|
||||
return ValueType.STRING;
|
||||
default:
|
||||
if (Character.isDigit(firstChar)) {
|
||||
return ValueType.NUMBER;
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected first character in value [" + valueAsText + "]");
|
||||
}
|
||||
}
|
||||
|
||||
protected void addBetweenProperty(String rawValue, String lowProperty, String highProperty) {
|
||||
peekExprList().betweenProperties(lowProperty, highProperty, bind(rawValue));
|
||||
}
|
||||
|
||||
protected void addBetween(String path, String value1, String value2) {
|
||||
peekExprList().between(path, bind(value1), bind(value2));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void addIn(String path, List<Object> inValues) {
|
||||
peekExprList().in(path, inValues);
|
||||
}
|
||||
|
||||
protected void addExpression(String path, EqlOperator op, String value) {
|
||||
|
||||
switch (op) {
|
||||
case EQ:
|
||||
peekExprList().eq(path, bind(value));
|
||||
break;
|
||||
case IEQ:
|
||||
peekExprList().add(owner.ieq(path, bind(value)));
|
||||
break;
|
||||
case NE:
|
||||
peekExprList().ne(path, bind(value));
|
||||
break;
|
||||
case GT:
|
||||
peekExprList().gt(path, bind(value));
|
||||
break;
|
||||
case LT:
|
||||
peekExprList().lt(path, bind(value));
|
||||
break;
|
||||
case GTE:
|
||||
peekExprList().ge(path, bind(value));
|
||||
break;
|
||||
case LTE:
|
||||
peekExprList().le(path, bind(value));
|
||||
break;
|
||||
case LIKE:
|
||||
addLike(false, LikeType.RAW, path, bind(value));
|
||||
break;
|
||||
case CONTAINS:
|
||||
addLike(false, LikeType.CONTAINS, path, bind(value));
|
||||
break;
|
||||
case STARTS_WITH:
|
||||
addLike(false, LikeType.STARTS_WITH, path, bind(value));
|
||||
break;
|
||||
case ENDS_WITH:
|
||||
addLike(false, LikeType.ENDS_WITH, path, bind(value));
|
||||
break;
|
||||
case ILIKE:
|
||||
addLike(true, LikeType.RAW, path, bind(value));
|
||||
break;
|
||||
case ICONTAINS:
|
||||
addLike(true, LikeType.CONTAINS, path, bind(value));
|
||||
break;
|
||||
case ISTARTS_WITH:
|
||||
addLike(true, LikeType.STARTS_WITH, path, bind(value));
|
||||
break;
|
||||
case IENDS_WITH:
|
||||
addLike(true, LikeType.ENDS_WITH, path, bind(value));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unhandled operator " + op);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addLike(boolean caseInsensitive, LikeType likeType, String path, Object bindValue) {
|
||||
peekExprList().add(owner.like(caseInsensitive, likeType, path, bindValue));
|
||||
}
|
||||
|
||||
protected Object bind(String value) {
|
||||
ValueType valueType = getValueType(value);
|
||||
return getBindValue(valueType, value);
|
||||
}
|
||||
|
||||
private ExpressionList peekExprList() {
|
||||
return owner.peekExprList();
|
||||
}
|
||||
|
||||
private Object getBindValue(ValueType valueType, String value) {
|
||||
switch (valueType) {
|
||||
case BOOL: return Boolean.parseBoolean(value);
|
||||
case NUMBER: return new BigDecimal(value);
|
||||
case STRING: return unquote(value);
|
||||
case NAMED_PARAM: return owner.namedParam(value.substring(1));
|
||||
default:
|
||||
throw new IllegalArgumentException("Unhandled valueType "+valueType);
|
||||
}
|
||||
}
|
||||
|
||||
private String unquote(String value) {
|
||||
String raw = value.substring(1, value.length() - 1);
|
||||
//raw.replaceAll();
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.avaje.ebeaninternal.server.grammer;
|
||||
|
||||
enum EqlOperator {
|
||||
|
||||
EQ,
|
||||
IEQ,
|
||||
NE,
|
||||
LT,
|
||||
LTE,
|
||||
GT,
|
||||
GTE,
|
||||
CONTAINS,
|
||||
STARTS_WITH,
|
||||
ENDS_WITH,
|
||||
LIKE,
|
||||
ICONTAINS,
|
||||
ISTARTS_WITH,
|
||||
IENDS_WITH,
|
||||
ILIKE,
|
||||
BETWEEN
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.avaje.ebeaninternal.server.grammer;
|
||||
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.grammer.antlr.EQLLexer;
|
||||
import com.avaje.ebeaninternal.server.grammer.antlr.EQLParser;
|
||||
import org.antlr.v4.runtime.ANTLRInputStream;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||
|
||||
/**
|
||||
* Parse EQL query language applying it to an ORM query object.
|
||||
*/
|
||||
public class EqlParser {
|
||||
|
||||
/**
|
||||
* Parse the raw EQL query and apply it to the supplied query.
|
||||
*/
|
||||
public static <T> void parse(String raw, SpiQuery<T> query) {
|
||||
|
||||
EQLLexer lexer = new EQLLexer(new ANTLRInputStream(raw));
|
||||
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||
EQLParser parser = new EQLParser(tokens);
|
||||
EQLParser.Select_statementContext context = parser.select_statement();
|
||||
|
||||
EqlAdapter<T> adapter = new EqlAdapter<T>(query);
|
||||
|
||||
ParseTreeWalker walker = new ParseTreeWalker();
|
||||
walker.walk(adapter, context);
|
||||
|
||||
query.simplifyExpressions();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.avaje.ebeaninternal.server.grammer;
|
||||
|
||||
public class NamedParameter {
|
||||
|
||||
public static final String PREFIX = "$namedParam$";
|
||||
|
||||
private final String name;
|
||||
|
||||
public NamedParameter(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.avaje.ebeaninternal.server.grammer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
class OperatorMapping {
|
||||
|
||||
Map<String,EqlOperator> map = new HashMap<String,EqlOperator>();
|
||||
|
||||
public OperatorMapping() {
|
||||
map.put("eq", EqlOperator.EQ);
|
||||
map.put("=", EqlOperator.EQ);
|
||||
map.put("ieq", EqlOperator.IEQ);
|
||||
|
||||
map.put("ne", EqlOperator.NE);
|
||||
map.put("<>", EqlOperator.NE);
|
||||
map.put("!=", EqlOperator.NE);
|
||||
|
||||
map.put(">", EqlOperator.GT);
|
||||
map.put("gt", EqlOperator.GT);
|
||||
|
||||
map.put(">=", EqlOperator.GTE);
|
||||
map.put("gte", EqlOperator.GTE);
|
||||
map.put("ge", EqlOperator.GTE);
|
||||
|
||||
map.put("<", EqlOperator.LT);
|
||||
map.put("lt", EqlOperator.LT);
|
||||
|
||||
map.put("<=", EqlOperator.LTE);
|
||||
map.put("lte", EqlOperator.LTE);
|
||||
map.put("le", EqlOperator.LTE);
|
||||
|
||||
map.put("contains", EqlOperator.CONTAINS);
|
||||
map.put("startsWith", EqlOperator.STARTS_WITH);
|
||||
map.put("endsWith", EqlOperator.ENDS_WITH);
|
||||
map.put("like", EqlOperator.LIKE);
|
||||
|
||||
map.put("icontains", EqlOperator.ICONTAINS);
|
||||
map.put("istartsWith", EqlOperator.ISTARTS_WITH);
|
||||
map.put("iendsWith", EqlOperator.IENDS_WITH);
|
||||
map.put("ilike", EqlOperator.ILIKE);
|
||||
|
||||
map.put("between", EqlOperator.BETWEEN);
|
||||
}
|
||||
|
||||
public EqlOperator get(String key) {
|
||||
return map.get(key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.avaje.ebeaninternal.server.grammer;
|
||||
|
||||
import com.avaje.ebean.FetchConfig;
|
||||
|
||||
/**
|
||||
* Parse the path that potentially is a FetchConfig definition.
|
||||
*/
|
||||
class ParseFetchConfig {
|
||||
|
||||
/**
|
||||
* Parse the path that potentially is a FetchConfig definition.
|
||||
* <p>
|
||||
* Return the FetchConfig if it is and otherwise null.
|
||||
* </p>
|
||||
*/
|
||||
static FetchConfig parse(String path) {
|
||||
|
||||
if (path.startsWith("lazy")) {
|
||||
if (path.length() == 4) {
|
||||
return new FetchConfig().lazy();
|
||||
} else if (path.charAt(4) == '(') {
|
||||
path = path.substring(5);
|
||||
int batchSize = parseBatchSize(path);
|
||||
return new FetchConfig().lazy(batchSize);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (path.startsWith("query")) {
|
||||
if (path.length() == 5) {
|
||||
return new FetchConfig().query();
|
||||
} else if (path.charAt(5) == '(') {
|
||||
path = path.substring(6);
|
||||
int batchSize = parseBatchSize(path);
|
||||
return new FetchConfig().query(batchSize);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int parseBatchSize(String path) {
|
||||
path = path.substring(0, path.length()-1);
|
||||
return Integer.parseInt(path);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
T__7=8
|
||||
T__8=9
|
||||
T__9=10
|
||||
T__10=11
|
||||
T__11=12
|
||||
T__12=13
|
||||
T__13=14
|
||||
T__14=15
|
||||
T__15=16
|
||||
T__16=17
|
||||
T__17=18
|
||||
T__18=19
|
||||
T__19=20
|
||||
T__20=21
|
||||
T__21=22
|
||||
T__22=23
|
||||
T__23=24
|
||||
T__24=25
|
||||
T__25=26
|
||||
T__26=27
|
||||
T__27=28
|
||||
T__28=29
|
||||
T__29=30
|
||||
T__30=31
|
||||
T__31=32
|
||||
T__32=33
|
||||
T__33=34
|
||||
T__34=35
|
||||
T__35=36
|
||||
T__36=37
|
||||
T__37=38
|
||||
T__38=39
|
||||
T__39=40
|
||||
T__40=41
|
||||
T__41=42
|
||||
T__42=43
|
||||
T__43=44
|
||||
T__44=45
|
||||
T__45=46
|
||||
T__46=47
|
||||
T__47=48
|
||||
T__48=49
|
||||
T__49=50
|
||||
T__50=51
|
||||
T__51=52
|
||||
T__52=53
|
||||
T__53=54
|
||||
T__54=55
|
||||
T__55=56
|
||||
T__56=57
|
||||
INPUT_VARIABLE=58
|
||||
PATH_VARIABLE=59
|
||||
BOOLEAN_LITERAL=60
|
||||
NUMBER_LITERAL=61
|
||||
DOUBLE=62
|
||||
INT=63
|
||||
ZERO=64
|
||||
STRING_LITERAL=65
|
||||
WS=66
|
||||
'select'=1
|
||||
'('=2
|
||||
')'=3
|
||||
'distinct'=4
|
||||
'where'=5
|
||||
'order'=6
|
||||
'by'=7
|
||||
','=8
|
||||
'nulls'=9
|
||||
'first'=10
|
||||
'last'=11
|
||||
'asc'=12
|
||||
'desc'=13
|
||||
'limit'=14
|
||||
'offset'=15
|
||||
'fetch'=16
|
||||
'+'=17
|
||||
'query'=18
|
||||
'lazy'=19
|
||||
'or'=20
|
||||
'and'=21
|
||||
'not'=22
|
||||
'in'=23
|
||||
'between'=24
|
||||
'is'=25
|
||||
'null'=26
|
||||
'isNull'=27
|
||||
'isNotNull'=28
|
||||
'notNull'=29
|
||||
'empty'=30
|
||||
'isEmpty'=31
|
||||
'isNotEmpty'=32
|
||||
'notEmpty'=33
|
||||
'like'=34
|
||||
'ilike'=35
|
||||
'contains'=36
|
||||
'icontains'=37
|
||||
'startsWith'=38
|
||||
'istartsWith'=39
|
||||
'endsWith'=40
|
||||
'iendsWith'=41
|
||||
'='=42
|
||||
'eq'=43
|
||||
'>'=44
|
||||
'gt'=45
|
||||
'>='=46
|
||||
'ge'=47
|
||||
'gte'=48
|
||||
'<'=49
|
||||
'lt'=50
|
||||
'<='=51
|
||||
'le'=52
|
||||
'lte'=53
|
||||
'<>'=54
|
||||
'!='=55
|
||||
'ne'=56
|
||||
'ieq'=57
|
||||
'0'=64
|
||||
@@ -0,0 +1,519 @@
|
||||
// Generated from /home/rob/github/avaje-ebeanorm/src/test/resources/EQL.g4 by ANTLR 4.5.3
|
||||
package com.avaje.ebeaninternal.server.grammer.antlr;
|
||||
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
import org.antlr.v4.runtime.tree.ErrorNode;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
|
||||
/**
|
||||
* This class provides an empty implementation of {@link EQLListener},
|
||||
* which can be extended to create a listener which only needs to handle a subset
|
||||
* of the available methods.
|
||||
*/
|
||||
public class EQLBaseListener implements EQLListener {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterSelect_statement(EQLParser.Select_statementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitSelect_statement(EQLParser.Select_statementContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterSelect_clause(EQLParser.Select_clauseContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitSelect_clause(EQLParser.Select_clauseContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterDistinct(EQLParser.DistinctContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitDistinct(EQLParser.DistinctContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterFetch_clause(EQLParser.Fetch_clauseContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFetch_clause(EQLParser.Fetch_clauseContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterWhere_clause(EQLParser.Where_clauseContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitWhere_clause(EQLParser.Where_clauseContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterOrderby_clause(EQLParser.Orderby_clauseContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitOrderby_clause(EQLParser.Orderby_clauseContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterOrderby_property(EQLParser.Orderby_propertyContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitOrderby_property(EQLParser.Orderby_propertyContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterNulls_firstlast(EQLParser.Nulls_firstlastContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitNulls_firstlast(EQLParser.Nulls_firstlastContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterAsc_desc(EQLParser.Asc_descContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitAsc_desc(EQLParser.Asc_descContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterLimit_clause(EQLParser.Limit_clauseContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitLimit_clause(EQLParser.Limit_clauseContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterOffset_clause(EQLParser.Offset_clauseContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitOffset_clause(EQLParser.Offset_clauseContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterFetch_path(EQLParser.Fetch_pathContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFetch_path(EQLParser.Fetch_pathContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterFetch_property_set(EQLParser.Fetch_property_setContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFetch_property_set(EQLParser.Fetch_property_setContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterFetch_property_group(EQLParser.Fetch_property_groupContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFetch_property_group(EQLParser.Fetch_property_groupContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterFetch_property(EQLParser.Fetch_propertyContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFetch_property(EQLParser.Fetch_propertyContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterFetch_query_hint(EQLParser.Fetch_query_hintContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFetch_query_hint(EQLParser.Fetch_query_hintContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterFetch_option(EQLParser.Fetch_optionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFetch_option(EQLParser.Fetch_optionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterFetch_query_option(EQLParser.Fetch_query_optionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFetch_query_option(EQLParser.Fetch_query_optionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterConditional_expression(EQLParser.Conditional_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitConditional_expression(EQLParser.Conditional_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterConditional_term(EQLParser.Conditional_termContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitConditional_term(EQLParser.Conditional_termContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterConditional_factor(EQLParser.Conditional_factorContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitConditional_factor(EQLParser.Conditional_factorContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterConditional_primary(EQLParser.Conditional_primaryContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitConditional_primary(EQLParser.Conditional_primaryContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterAny_expression(EQLParser.Any_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitAny_expression(EQLParser.Any_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterIn_expression(EQLParser.In_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitIn_expression(EQLParser.In_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterIn_value(EQLParser.In_valueContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitIn_value(EQLParser.In_valueContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterBetween_expression(EQLParser.Between_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitBetween_expression(EQLParser.Between_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterIsNull_expression(EQLParser.IsNull_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitIsNull_expression(EQLParser.IsNull_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterLike_expression(EQLParser.Like_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitLike_expression(EQLParser.Like_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterLike_op(EQLParser.Like_opContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitLike_op(EQLParser.Like_opContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterComparison_expression(EQLParser.Comparison_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitComparison_expression(EQLParser.Comparison_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterComparison_operator(EQLParser.Comparison_operatorContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitComparison_operator(EQLParser.Comparison_operatorContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterValue_expression(EQLParser.Value_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitValue_expression(EQLParser.Value_expressionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterLiteral(EQLParser.LiteralContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitLiteral(EQLParser.LiteralContext ctx) { }
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterEveryRule(ParserRuleContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitEveryRule(ParserRuleContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void visitTerminal(TerminalNode node) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void visitErrorNode(ErrorNode node) { }
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
// Generated from /home/rob/github/avaje-ebeanorm/src/test/resources/EQL.g4 by ANTLR 4.5.3
|
||||
package com.avaje.ebeaninternal.server.grammer.antlr;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.TokenStream;
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.atn.*;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.*;
|
||||
|
||||
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
|
||||
public class EQLLexer extends Lexer {
|
||||
static { RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); }
|
||||
|
||||
protected static final DFA[] _decisionToDFA;
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
new PredictionContextCache();
|
||||
public static final int
|
||||
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
|
||||
T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17,
|
||||
T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24,
|
||||
T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31,
|
||||
T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38,
|
||||
T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45,
|
||||
T__45=46, T__46=47, T__47=48, T__48=49, T__49=50, T__50=51, T__51=52,
|
||||
T__52=53, T__53=54, T__54=55, T__55=56, T__56=57, INPUT_VARIABLE=58, PATH_VARIABLE=59,
|
||||
BOOLEAN_LITERAL=60, NUMBER_LITERAL=61, DOUBLE=62, INT=63, ZERO=64, STRING_LITERAL=65,
|
||||
WS=66;
|
||||
public static String[] modeNames = {
|
||||
"DEFAULT_MODE"
|
||||
};
|
||||
|
||||
public static final String[] ruleNames = {
|
||||
"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
|
||||
"T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16",
|
||||
"T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24",
|
||||
"T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32",
|
||||
"T__33", "T__34", "T__35", "T__36", "T__37", "T__38", "T__39", "T__40",
|
||||
"T__41", "T__42", "T__43", "T__44", "T__45", "T__46", "T__47", "T__48",
|
||||
"T__49", "T__50", "T__51", "T__52", "T__53", "T__54", "T__55", "T__56",
|
||||
"INPUT_VARIABLE", "PATH_VARIABLE", "BOOLEAN_LITERAL", "NUMBER_LITERAL",
|
||||
"DOUBLE", "INT", "ZERO", "STRING_LITERAL", "WS"
|
||||
};
|
||||
|
||||
private static final String[] _LITERAL_NAMES = {
|
||||
null, "'select'", "'('", "')'", "'distinct'", "'where'", "'order'", "'by'",
|
||||
"','", "'nulls'", "'first'", "'last'", "'asc'", "'desc'", "'limit'", "'offset'",
|
||||
"'fetch'", "'+'", "'query'", "'lazy'", "'or'", "'and'", "'not'", "'in'",
|
||||
"'between'", "'is'", "'null'", "'isNull'", "'isNotNull'", "'notNull'",
|
||||
"'empty'", "'isEmpty'", "'isNotEmpty'", "'notEmpty'", "'like'", "'ilike'",
|
||||
"'contains'", "'icontains'", "'startsWith'", "'istartsWith'", "'endsWith'",
|
||||
"'iendsWith'", "'='", "'eq'", "'>'", "'gt'", "'>='", "'ge'", "'gte'",
|
||||
"'<'", "'lt'", "'<='", "'le'", "'lte'", "'<>'", "'!='", "'ne'", "'ieq'",
|
||||
null, null, null, null, null, null, "'0'"
|
||||
};
|
||||
private static final String[] _SYMBOLIC_NAMES = {
|
||||
null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null, null, null, null, null, null, null, "INPUT_VARIABLE",
|
||||
"PATH_VARIABLE", "BOOLEAN_LITERAL", "NUMBER_LITERAL", "DOUBLE", "INT",
|
||||
"ZERO", "STRING_LITERAL", "WS"
|
||||
};
|
||||
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #VOCABULARY} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String[] tokenNames;
|
||||
static {
|
||||
tokenNames = new String[_SYMBOLIC_NAMES.length];
|
||||
for (int i = 0; i < tokenNames.length; i++) {
|
||||
tokenNames[i] = VOCABULARY.getLiteralName(i);
|
||||
if (tokenNames[i] == null) {
|
||||
tokenNames[i] = VOCABULARY.getSymbolicName(i);
|
||||
}
|
||||
|
||||
if (tokenNames[i] == null) {
|
||||
tokenNames[i] = "<INVALID>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String[] getTokenNames() {
|
||||
return tokenNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public Vocabulary getVocabulary() {
|
||||
return VOCABULARY;
|
||||
}
|
||||
|
||||
|
||||
public EQLLexer(CharStream input) {
|
||||
super(input);
|
||||
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGrammarFileName() { return "EQL.g4"; }
|
||||
|
||||
@Override
|
||||
public String[] getRuleNames() { return ruleNames; }
|
||||
|
||||
@Override
|
||||
public String getSerializedATN() { return _serializedATN; }
|
||||
|
||||
@Override
|
||||
public String[] getModeNames() { return modeNames; }
|
||||
|
||||
@Override
|
||||
public ATN getATN() { return _ATN; }
|
||||
|
||||
public static final String _serializedATN =
|
||||
"\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2D\u0200\b\1\4\2\t"+
|
||||
"\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+
|
||||
"\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+
|
||||
"\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+
|
||||
"\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+
|
||||
"\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+
|
||||
",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t"+
|
||||
"\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+
|
||||
"\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3"+
|
||||
"\3\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\6"+
|
||||
"\3\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3"+
|
||||
"\13\3\13\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\16"+
|
||||
"\3\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3\20"+
|
||||
"\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21\3\22\3\22\3\23\3\23\3\23"+
|
||||
"\3\23\3\23\3\23\3\24\3\24\3\24\3\24\3\24\3\25\3\25\3\25\3\26\3\26\3\26"+
|
||||
"\3\26\3\27\3\27\3\27\3\27\3\30\3\30\3\30\3\31\3\31\3\31\3\31\3\31\3\31"+
|
||||
"\3\31\3\31\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\34\3\34"+
|
||||
"\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\36"+
|
||||
"\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\37\3\37\3\37\3\37\3\37\3\37\3 \3"+
|
||||
" \3 \3 \3 \3 \3 \3 \3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3\"\3\"\3\"\3\"\3"+
|
||||
"\"\3\"\3\"\3\"\3\"\3#\3#\3#\3#\3#\3$\3$\3$\3$\3$\3$\3%\3%\3%\3%\3%\3%"+
|
||||
"\3%\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&\3&\3&\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3"+
|
||||
"\'\3\'\3\'\3\'\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)\3)\3"+
|
||||
")\3)\3)\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3+\3+\3,\3,\3,\3-\3-\3.\3.\3.\3"+
|
||||
"/\3/\3/\3\60\3\60\3\60\3\61\3\61\3\61\3\61\3\62\3\62\3\63\3\63\3\63\3"+
|
||||
"\64\3\64\3\64\3\65\3\65\3\65\3\66\3\66\3\66\3\66\3\67\3\67\3\67\38\38"+
|
||||
"\38\39\39\39\3:\3:\3:\3:\3;\3;\3;\7;\u01bb\n;\f;\16;\u01be\13;\3<\3<\7"+
|
||||
"<\u01c2\n<\f<\16<\u01c5\13<\3=\3=\3=\3=\3=\3=\3=\3=\3=\5=\u01d0\n=\3>"+
|
||||
"\5>\u01d3\n>\3>\3>\5>\u01d7\n>\3>\3>\5>\u01db\n>\3?\6?\u01de\n?\r?\16"+
|
||||
"?\u01df\3?\3?\7?\u01e4\n?\f?\16?\u01e7\13?\3@\3@\7@\u01eb\n@\f@\16@\u01ee"+
|
||||
"\13@\3A\3A\3B\3B\3B\3B\7B\u01f6\nB\fB\16B\u01f9\13B\3B\3B\3C\3C\3C\3C"+
|
||||
"\2\2D\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35"+
|
||||
"\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36"+
|
||||
";\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63e\64g\65i\66k\67"+
|
||||
"m8o9q:s;u<w=y>{?}@\177A\u0081B\u0083C\u0085D\3\2\t\5\2C\\aac|\6\2\62;"+
|
||||
"C\\aac|\7\2\60\60\62;C\\aac|\3\2\62;\3\2\63;\3\2))\5\2\13\f\17\17\"\""+
|
||||
"\u020b\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2"+
|
||||
"\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3"+
|
||||
"\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2"+
|
||||
"\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2"+
|
||||
"/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2"+
|
||||
"\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2"+
|
||||
"G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3"+
|
||||
"\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2"+
|
||||
"\2\2a\3\2\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2"+
|
||||
"m\3\2\2\2\2o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3"+
|
||||
"\2\2\2\2{\3\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2\2\2\u0083\3\2"+
|
||||
"\2\2\2\u0085\3\2\2\2\3\u0087\3\2\2\2\5\u008e\3\2\2\2\7\u0090\3\2\2\2\t"+
|
||||
"\u0092\3\2\2\2\13\u009b\3\2\2\2\r\u00a1\3\2\2\2\17\u00a7\3\2\2\2\21\u00aa"+
|
||||
"\3\2\2\2\23\u00ac\3\2\2\2\25\u00b2\3\2\2\2\27\u00b8\3\2\2\2\31\u00bd\3"+
|
||||
"\2\2\2\33\u00c1\3\2\2\2\35\u00c6\3\2\2\2\37\u00cc\3\2\2\2!\u00d3\3\2\2"+
|
||||
"\2#\u00d9\3\2\2\2%\u00db\3\2\2\2\'\u00e1\3\2\2\2)\u00e6\3\2\2\2+\u00e9"+
|
||||
"\3\2\2\2-\u00ed\3\2\2\2/\u00f1\3\2\2\2\61\u00f4\3\2\2\2\63\u00fc\3\2\2"+
|
||||
"\2\65\u00ff\3\2\2\2\67\u0104\3\2\2\29\u010b\3\2\2\2;\u0115\3\2\2\2=\u011d"+
|
||||
"\3\2\2\2?\u0123\3\2\2\2A\u012b\3\2\2\2C\u0136\3\2\2\2E\u013f\3\2\2\2G"+
|
||||
"\u0144\3\2\2\2I\u014a\3\2\2\2K\u0153\3\2\2\2M\u015d\3\2\2\2O\u0168\3\2"+
|
||||
"\2\2Q\u0174\3\2\2\2S\u017d\3\2\2\2U\u0187\3\2\2\2W\u0189\3\2\2\2Y\u018c"+
|
||||
"\3\2\2\2[\u018e\3\2\2\2]\u0191\3\2\2\2_\u0194\3\2\2\2a\u0197\3\2\2\2c"+
|
||||
"\u019b\3\2\2\2e\u019d\3\2\2\2g\u01a0\3\2\2\2i\u01a3\3\2\2\2k\u01a6\3\2"+
|
||||
"\2\2m\u01aa\3\2\2\2o\u01ad\3\2\2\2q\u01b0\3\2\2\2s\u01b3\3\2\2\2u\u01b7"+
|
||||
"\3\2\2\2w\u01bf\3\2\2\2y\u01cf\3\2\2\2{\u01da\3\2\2\2}\u01dd\3\2\2\2\177"+
|
||||
"\u01e8\3\2\2\2\u0081\u01ef\3\2\2\2\u0083\u01f1\3\2\2\2\u0085\u01fc\3\2"+
|
||||
"\2\2\u0087\u0088\7u\2\2\u0088\u0089\7g\2\2\u0089\u008a\7n\2\2\u008a\u008b"+
|
||||
"\7g\2\2\u008b\u008c\7e\2\2\u008c\u008d\7v\2\2\u008d\4\3\2\2\2\u008e\u008f"+
|
||||
"\7*\2\2\u008f\6\3\2\2\2\u0090\u0091\7+\2\2\u0091\b\3\2\2\2\u0092\u0093"+
|
||||
"\7f\2\2\u0093\u0094\7k\2\2\u0094\u0095\7u\2\2\u0095\u0096\7v\2\2\u0096"+
|
||||
"\u0097\7k\2\2\u0097\u0098\7p\2\2\u0098\u0099\7e\2\2\u0099\u009a\7v\2\2"+
|
||||
"\u009a\n\3\2\2\2\u009b\u009c\7y\2\2\u009c\u009d\7j\2\2\u009d\u009e\7g"+
|
||||
"\2\2\u009e\u009f\7t\2\2\u009f\u00a0\7g\2\2\u00a0\f\3\2\2\2\u00a1\u00a2"+
|
||||
"\7q\2\2\u00a2\u00a3\7t\2\2\u00a3\u00a4\7f\2\2\u00a4\u00a5\7g\2\2\u00a5"+
|
||||
"\u00a6\7t\2\2\u00a6\16\3\2\2\2\u00a7\u00a8\7d\2\2\u00a8\u00a9\7{\2\2\u00a9"+
|
||||
"\20\3\2\2\2\u00aa\u00ab\7.\2\2\u00ab\22\3\2\2\2\u00ac\u00ad\7p\2\2\u00ad"+
|
||||
"\u00ae\7w\2\2\u00ae\u00af\7n\2\2\u00af\u00b0\7n\2\2\u00b0\u00b1\7u\2\2"+
|
||||
"\u00b1\24\3\2\2\2\u00b2\u00b3\7h\2\2\u00b3\u00b4\7k\2\2\u00b4\u00b5\7"+
|
||||
"t\2\2\u00b5\u00b6\7u\2\2\u00b6\u00b7\7v\2\2\u00b7\26\3\2\2\2\u00b8\u00b9"+
|
||||
"\7n\2\2\u00b9\u00ba\7c\2\2\u00ba\u00bb\7u\2\2\u00bb\u00bc\7v\2\2\u00bc"+
|
||||
"\30\3\2\2\2\u00bd\u00be\7c\2\2\u00be\u00bf\7u\2\2\u00bf\u00c0\7e\2\2\u00c0"+
|
||||
"\32\3\2\2\2\u00c1\u00c2\7f\2\2\u00c2\u00c3\7g\2\2\u00c3\u00c4\7u\2\2\u00c4"+
|
||||
"\u00c5\7e\2\2\u00c5\34\3\2\2\2\u00c6\u00c7\7n\2\2\u00c7\u00c8\7k\2\2\u00c8"+
|
||||
"\u00c9\7o\2\2\u00c9\u00ca\7k\2\2\u00ca\u00cb\7v\2\2\u00cb\36\3\2\2\2\u00cc"+
|
||||
"\u00cd\7q\2\2\u00cd\u00ce\7h\2\2\u00ce\u00cf\7h\2\2\u00cf\u00d0\7u\2\2"+
|
||||
"\u00d0\u00d1\7g\2\2\u00d1\u00d2\7v\2\2\u00d2 \3\2\2\2\u00d3\u00d4\7h\2"+
|
||||
"\2\u00d4\u00d5\7g\2\2\u00d5\u00d6\7v\2\2\u00d6\u00d7\7e\2\2\u00d7\u00d8"+
|
||||
"\7j\2\2\u00d8\"\3\2\2\2\u00d9\u00da\7-\2\2\u00da$\3\2\2\2\u00db\u00dc"+
|
||||
"\7s\2\2\u00dc\u00dd\7w\2\2\u00dd\u00de\7g\2\2\u00de\u00df\7t\2\2\u00df"+
|
||||
"\u00e0\7{\2\2\u00e0&\3\2\2\2\u00e1\u00e2\7n\2\2\u00e2\u00e3\7c\2\2\u00e3"+
|
||||
"\u00e4\7|\2\2\u00e4\u00e5\7{\2\2\u00e5(\3\2\2\2\u00e6\u00e7\7q\2\2\u00e7"+
|
||||
"\u00e8\7t\2\2\u00e8*\3\2\2\2\u00e9\u00ea\7c\2\2\u00ea\u00eb\7p\2\2\u00eb"+
|
||||
"\u00ec\7f\2\2\u00ec,\3\2\2\2\u00ed\u00ee\7p\2\2\u00ee\u00ef\7q\2\2\u00ef"+
|
||||
"\u00f0\7v\2\2\u00f0.\3\2\2\2\u00f1\u00f2\7k\2\2\u00f2\u00f3\7p\2\2\u00f3"+
|
||||
"\60\3\2\2\2\u00f4\u00f5\7d\2\2\u00f5\u00f6\7g\2\2\u00f6\u00f7\7v\2\2\u00f7"+
|
||||
"\u00f8\7y\2\2\u00f8\u00f9\7g\2\2\u00f9\u00fa\7g\2\2\u00fa\u00fb\7p\2\2"+
|
||||
"\u00fb\62\3\2\2\2\u00fc\u00fd\7k\2\2\u00fd\u00fe\7u\2\2\u00fe\64\3\2\2"+
|
||||
"\2\u00ff\u0100\7p\2\2\u0100\u0101\7w\2\2\u0101\u0102\7n\2\2\u0102\u0103"+
|
||||
"\7n\2\2\u0103\66\3\2\2\2\u0104\u0105\7k\2\2\u0105\u0106\7u\2\2\u0106\u0107"+
|
||||
"\7P\2\2\u0107\u0108\7w\2\2\u0108\u0109\7n\2\2\u0109\u010a\7n\2\2\u010a"+
|
||||
"8\3\2\2\2\u010b\u010c\7k\2\2\u010c\u010d\7u\2\2\u010d\u010e\7P\2\2\u010e"+
|
||||
"\u010f\7q\2\2\u010f\u0110\7v\2\2\u0110\u0111\7P\2\2\u0111\u0112\7w\2\2"+
|
||||
"\u0112\u0113\7n\2\2\u0113\u0114\7n\2\2\u0114:\3\2\2\2\u0115\u0116\7p\2"+
|
||||
"\2\u0116\u0117\7q\2\2\u0117\u0118\7v\2\2\u0118\u0119\7P\2\2\u0119\u011a"+
|
||||
"\7w\2\2\u011a\u011b\7n\2\2\u011b\u011c\7n\2\2\u011c<\3\2\2\2\u011d\u011e"+
|
||||
"\7g\2\2\u011e\u011f\7o\2\2\u011f\u0120\7r\2\2\u0120\u0121\7v\2\2\u0121"+
|
||||
"\u0122\7{\2\2\u0122>\3\2\2\2\u0123\u0124\7k\2\2\u0124\u0125\7u\2\2\u0125"+
|
||||
"\u0126\7G\2\2\u0126\u0127\7o\2\2\u0127\u0128\7r\2\2\u0128\u0129\7v\2\2"+
|
||||
"\u0129\u012a\7{\2\2\u012a@\3\2\2\2\u012b\u012c\7k\2\2\u012c\u012d\7u\2"+
|
||||
"\2\u012d\u012e\7P\2\2\u012e\u012f\7q\2\2\u012f\u0130\7v\2\2\u0130\u0131"+
|
||||
"\7G\2\2\u0131\u0132\7o\2\2\u0132\u0133\7r\2\2\u0133\u0134\7v\2\2\u0134"+
|
||||
"\u0135\7{\2\2\u0135B\3\2\2\2\u0136\u0137\7p\2\2\u0137\u0138\7q\2\2\u0138"+
|
||||
"\u0139\7v\2\2\u0139\u013a\7G\2\2\u013a\u013b\7o\2\2\u013b\u013c\7r\2\2"+
|
||||
"\u013c\u013d\7v\2\2\u013d\u013e\7{\2\2\u013eD\3\2\2\2\u013f\u0140\7n\2"+
|
||||
"\2\u0140\u0141\7k\2\2\u0141\u0142\7m\2\2\u0142\u0143\7g\2\2\u0143F\3\2"+
|
||||
"\2\2\u0144\u0145\7k\2\2\u0145\u0146\7n\2\2\u0146\u0147\7k\2\2\u0147\u0148"+
|
||||
"\7m\2\2\u0148\u0149\7g\2\2\u0149H\3\2\2\2\u014a\u014b\7e\2\2\u014b\u014c"+
|
||||
"\7q\2\2\u014c\u014d\7p\2\2\u014d\u014e\7v\2\2\u014e\u014f\7c\2\2\u014f"+
|
||||
"\u0150\7k\2\2\u0150\u0151\7p\2\2\u0151\u0152\7u\2\2\u0152J\3\2\2\2\u0153"+
|
||||
"\u0154\7k\2\2\u0154\u0155\7e\2\2\u0155\u0156\7q\2\2\u0156\u0157\7p\2\2"+
|
||||
"\u0157\u0158\7v\2\2\u0158\u0159\7c\2\2\u0159\u015a\7k\2\2\u015a\u015b"+
|
||||
"\7p\2\2\u015b\u015c\7u\2\2\u015cL\3\2\2\2\u015d\u015e\7u\2\2\u015e\u015f"+
|
||||
"\7v\2\2\u015f\u0160\7c\2\2\u0160\u0161\7t\2\2\u0161\u0162\7v\2\2\u0162"+
|
||||
"\u0163\7u\2\2\u0163\u0164\7Y\2\2\u0164\u0165\7k\2\2\u0165\u0166\7v\2\2"+
|
||||
"\u0166\u0167\7j\2\2\u0167N\3\2\2\2\u0168\u0169\7k\2\2\u0169\u016a\7u\2"+
|
||||
"\2\u016a\u016b\7v\2\2\u016b\u016c\7c\2\2\u016c\u016d\7t\2\2\u016d\u016e"+
|
||||
"\7v\2\2\u016e\u016f\7u\2\2\u016f\u0170\7Y\2\2\u0170\u0171\7k\2\2\u0171"+
|
||||
"\u0172\7v\2\2\u0172\u0173\7j\2\2\u0173P\3\2\2\2\u0174\u0175\7g\2\2\u0175"+
|
||||
"\u0176\7p\2\2\u0176\u0177\7f\2\2\u0177\u0178\7u\2\2\u0178\u0179\7Y\2\2"+
|
||||
"\u0179\u017a\7k\2\2\u017a\u017b\7v\2\2\u017b\u017c\7j\2\2\u017cR\3\2\2"+
|
||||
"\2\u017d\u017e\7k\2\2\u017e\u017f\7g\2\2\u017f\u0180\7p\2\2\u0180\u0181"+
|
||||
"\7f\2\2\u0181\u0182\7u\2\2\u0182\u0183\7Y\2\2\u0183\u0184\7k\2\2\u0184"+
|
||||
"\u0185\7v\2\2\u0185\u0186\7j\2\2\u0186T\3\2\2\2\u0187\u0188\7?\2\2\u0188"+
|
||||
"V\3\2\2\2\u0189\u018a\7g\2\2\u018a\u018b\7s\2\2\u018bX\3\2\2\2\u018c\u018d"+
|
||||
"\7@\2\2\u018dZ\3\2\2\2\u018e\u018f\7i\2\2\u018f\u0190\7v\2\2\u0190\\\3"+
|
||||
"\2\2\2\u0191\u0192\7@\2\2\u0192\u0193\7?\2\2\u0193^\3\2\2\2\u0194\u0195"+
|
||||
"\7i\2\2\u0195\u0196\7g\2\2\u0196`\3\2\2\2\u0197\u0198\7i\2\2\u0198\u0199"+
|
||||
"\7v\2\2\u0199\u019a\7g\2\2\u019ab\3\2\2\2\u019b\u019c\7>\2\2\u019cd\3"+
|
||||
"\2\2\2\u019d\u019e\7n\2\2\u019e\u019f\7v\2\2\u019ff\3\2\2\2\u01a0\u01a1"+
|
||||
"\7>\2\2\u01a1\u01a2\7?\2\2\u01a2h\3\2\2\2\u01a3\u01a4\7n\2\2\u01a4\u01a5"+
|
||||
"\7g\2\2\u01a5j\3\2\2\2\u01a6\u01a7\7n\2\2\u01a7\u01a8\7v\2\2\u01a8\u01a9"+
|
||||
"\7g\2\2\u01a9l\3\2\2\2\u01aa\u01ab\7>\2\2\u01ab\u01ac\7@\2\2\u01acn\3"+
|
||||
"\2\2\2\u01ad\u01ae\7#\2\2\u01ae\u01af\7?\2\2\u01afp\3\2\2\2\u01b0\u01b1"+
|
||||
"\7p\2\2\u01b1\u01b2\7g\2\2\u01b2r\3\2\2\2\u01b3\u01b4\7k\2\2\u01b4\u01b5"+
|
||||
"\7g\2\2\u01b5\u01b6\7s\2\2\u01b6t\3\2\2\2\u01b7\u01b8\7<\2\2\u01b8\u01bc"+
|
||||
"\t\2\2\2\u01b9\u01bb\t\3\2\2\u01ba\u01b9\3\2\2\2\u01bb\u01be\3\2\2\2\u01bc"+
|
||||
"\u01ba\3\2\2\2\u01bc\u01bd\3\2\2\2\u01bdv\3\2\2\2\u01be\u01bc\3\2\2\2"+
|
||||
"\u01bf\u01c3\t\2\2\2\u01c0\u01c2\t\4\2\2\u01c1\u01c0\3\2\2\2\u01c2\u01c5"+
|
||||
"\3\2\2\2\u01c3\u01c1\3\2\2\2\u01c3\u01c4\3\2\2\2\u01c4x\3\2\2\2\u01c5"+
|
||||
"\u01c3\3\2\2\2\u01c6\u01c7\7v\2\2\u01c7\u01c8\7t\2\2\u01c8\u01c9\7w\2"+
|
||||
"\2\u01c9\u01d0\7g\2\2\u01ca\u01cb\7h\2\2\u01cb\u01cc\7c\2\2\u01cc\u01cd"+
|
||||
"\7n\2\2\u01cd\u01ce\7u\2\2\u01ce\u01d0\7g\2\2\u01cf\u01c6\3\2\2\2\u01cf"+
|
||||
"\u01ca\3\2\2\2\u01d0z\3\2\2\2\u01d1\u01d3\7/\2\2\u01d2\u01d1\3\2\2\2\u01d2"+
|
||||
"\u01d3\3\2\2\2\u01d3\u01d4\3\2\2\2\u01d4\u01db\5}?\2\u01d5\u01d7\7/\2"+
|
||||
"\2\u01d6\u01d5\3\2\2\2\u01d6\u01d7\3\2\2\2\u01d7\u01d8\3\2\2\2\u01d8\u01db"+
|
||||
"\5\177@\2\u01d9\u01db\5\u0081A\2\u01da\u01d2\3\2\2\2\u01da\u01d6\3\2\2"+
|
||||
"\2\u01da\u01d9\3\2\2\2\u01db|\3\2\2\2\u01dc\u01de\t\5\2\2\u01dd\u01dc"+
|
||||
"\3\2\2\2\u01de\u01df\3\2\2\2\u01df\u01dd\3\2\2\2\u01df\u01e0\3\2\2\2\u01e0"+
|
||||
"\u01e1\3\2\2\2\u01e1\u01e5\7\60\2\2\u01e2\u01e4\t\5\2\2\u01e3\u01e2\3"+
|
||||
"\2\2\2\u01e4\u01e7\3\2\2\2\u01e5\u01e3\3\2\2\2\u01e5\u01e6\3\2\2\2\u01e6"+
|
||||
"~\3\2\2\2\u01e7\u01e5\3\2\2\2\u01e8\u01ec\t\6\2\2\u01e9\u01eb\t\5\2\2"+
|
||||
"\u01ea\u01e9\3\2\2\2\u01eb\u01ee\3\2\2\2\u01ec\u01ea\3\2\2\2\u01ec\u01ed"+
|
||||
"\3\2\2\2\u01ed\u0080\3\2\2\2\u01ee\u01ec\3\2\2\2\u01ef\u01f0\7\62\2\2"+
|
||||
"\u01f0\u0082\3\2\2\2\u01f1\u01f7\7)\2\2\u01f2\u01f6\n\7\2\2\u01f3\u01f4"+
|
||||
"\7)\2\2\u01f4\u01f6\7)\2\2\u01f5\u01f2\3\2\2\2\u01f5\u01f3\3\2\2\2\u01f6"+
|
||||
"\u01f9\3\2\2\2\u01f7\u01f5\3\2\2\2\u01f7\u01f8\3\2\2\2\u01f8\u01fa\3\2"+
|
||||
"\2\2\u01f9\u01f7\3\2\2\2\u01fa\u01fb\7)\2\2\u01fb\u0084\3\2\2\2\u01fc"+
|
||||
"\u01fd\t\b\2\2\u01fd\u01fe\3\2\2\2\u01fe\u01ff\bC\2\2\u01ff\u0086\3\2"+
|
||||
"\2\2\16\2\u01bc\u01c3\u01cf\u01d2\u01d6\u01da\u01df\u01e5\u01ec\u01f5"+
|
||||
"\u01f7\3\b\2\2";
|
||||
public static final ATN _ATN =
|
||||
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
|
||||
static {
|
||||
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
|
||||
for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
|
||||
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
T__7=8
|
||||
T__8=9
|
||||
T__9=10
|
||||
T__10=11
|
||||
T__11=12
|
||||
T__12=13
|
||||
T__13=14
|
||||
T__14=15
|
||||
T__15=16
|
||||
T__16=17
|
||||
T__17=18
|
||||
T__18=19
|
||||
T__19=20
|
||||
T__20=21
|
||||
T__21=22
|
||||
T__22=23
|
||||
T__23=24
|
||||
T__24=25
|
||||
T__25=26
|
||||
T__26=27
|
||||
T__27=28
|
||||
T__28=29
|
||||
T__29=30
|
||||
T__30=31
|
||||
T__31=32
|
||||
T__32=33
|
||||
T__33=34
|
||||
T__34=35
|
||||
T__35=36
|
||||
T__36=37
|
||||
T__37=38
|
||||
T__38=39
|
||||
T__39=40
|
||||
T__40=41
|
||||
T__41=42
|
||||
T__42=43
|
||||
T__43=44
|
||||
T__44=45
|
||||
T__45=46
|
||||
T__46=47
|
||||
T__47=48
|
||||
T__48=49
|
||||
T__49=50
|
||||
T__50=51
|
||||
T__51=52
|
||||
T__52=53
|
||||
T__53=54
|
||||
T__54=55
|
||||
T__55=56
|
||||
T__56=57
|
||||
INPUT_VARIABLE=58
|
||||
PATH_VARIABLE=59
|
||||
BOOLEAN_LITERAL=60
|
||||
NUMBER_LITERAL=61
|
||||
DOUBLE=62
|
||||
INT=63
|
||||
ZERO=64
|
||||
STRING_LITERAL=65
|
||||
WS=66
|
||||
'select'=1
|
||||
'('=2
|
||||
')'=3
|
||||
'distinct'=4
|
||||
'where'=5
|
||||
'order'=6
|
||||
'by'=7
|
||||
','=8
|
||||
'nulls'=9
|
||||
'first'=10
|
||||
'last'=11
|
||||
'asc'=12
|
||||
'desc'=13
|
||||
'limit'=14
|
||||
'offset'=15
|
||||
'fetch'=16
|
||||
'+'=17
|
||||
'query'=18
|
||||
'lazy'=19
|
||||
'or'=20
|
||||
'and'=21
|
||||
'not'=22
|
||||
'in'=23
|
||||
'between'=24
|
||||
'is'=25
|
||||
'null'=26
|
||||
'isNull'=27
|
||||
'isNotNull'=28
|
||||
'notNull'=29
|
||||
'empty'=30
|
||||
'isEmpty'=31
|
||||
'isNotEmpty'=32
|
||||
'notEmpty'=33
|
||||
'like'=34
|
||||
'ilike'=35
|
||||
'contains'=36
|
||||
'icontains'=37
|
||||
'startsWith'=38
|
||||
'istartsWith'=39
|
||||
'endsWith'=40
|
||||
'iendsWith'=41
|
||||
'='=42
|
||||
'eq'=43
|
||||
'>'=44
|
||||
'gt'=45
|
||||
'>='=46
|
||||
'ge'=47
|
||||
'gte'=48
|
||||
'<'=49
|
||||
'lt'=50
|
||||
'<='=51
|
||||
'le'=52
|
||||
'lte'=53
|
||||
'<>'=54
|
||||
'!='=55
|
||||
'ne'=56
|
||||
'ieq'=57
|
||||
'0'=64
|
||||
@@ -0,0 +1,410 @@
|
||||
// Generated from /home/rob/github/avaje-ebeanorm/src/test/resources/EQL.g4 by ANTLR 4.5.3
|
||||
package com.avaje.ebeaninternal.server.grammer.antlr;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
||||
|
||||
/**
|
||||
* This interface defines a complete listener for a parse tree produced by
|
||||
* {@link EQLParser}.
|
||||
*/
|
||||
public interface EQLListener extends ParseTreeListener {
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#select_statement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterSelect_statement(EQLParser.Select_statementContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#select_statement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitSelect_statement(EQLParser.Select_statementContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#select_clause}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterSelect_clause(EQLParser.Select_clauseContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#select_clause}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitSelect_clause(EQLParser.Select_clauseContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#distinct}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterDistinct(EQLParser.DistinctContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#distinct}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitDistinct(EQLParser.DistinctContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#fetch_clause}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterFetch_clause(EQLParser.Fetch_clauseContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#fetch_clause}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFetch_clause(EQLParser.Fetch_clauseContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#where_clause}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterWhere_clause(EQLParser.Where_clauseContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#where_clause}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitWhere_clause(EQLParser.Where_clauseContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#orderby_clause}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterOrderby_clause(EQLParser.Orderby_clauseContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#orderby_clause}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitOrderby_clause(EQLParser.Orderby_clauseContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#orderby_property}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterOrderby_property(EQLParser.Orderby_propertyContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#orderby_property}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitOrderby_property(EQLParser.Orderby_propertyContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#nulls_firstlast}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterNulls_firstlast(EQLParser.Nulls_firstlastContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#nulls_firstlast}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitNulls_firstlast(EQLParser.Nulls_firstlastContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#asc_desc}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterAsc_desc(EQLParser.Asc_descContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#asc_desc}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitAsc_desc(EQLParser.Asc_descContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#limit_clause}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterLimit_clause(EQLParser.Limit_clauseContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#limit_clause}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitLimit_clause(EQLParser.Limit_clauseContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#offset_clause}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterOffset_clause(EQLParser.Offset_clauseContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#offset_clause}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitOffset_clause(EQLParser.Offset_clauseContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#fetch_path}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterFetch_path(EQLParser.Fetch_pathContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#fetch_path}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFetch_path(EQLParser.Fetch_pathContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#fetch_property_set}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterFetch_property_set(EQLParser.Fetch_property_setContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#fetch_property_set}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFetch_property_set(EQLParser.Fetch_property_setContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#fetch_property_group}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterFetch_property_group(EQLParser.Fetch_property_groupContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#fetch_property_group}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFetch_property_group(EQLParser.Fetch_property_groupContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#fetch_property}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterFetch_property(EQLParser.Fetch_propertyContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#fetch_property}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFetch_property(EQLParser.Fetch_propertyContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#fetch_query_hint}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterFetch_query_hint(EQLParser.Fetch_query_hintContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#fetch_query_hint}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFetch_query_hint(EQLParser.Fetch_query_hintContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#fetch_lazy_hint}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#fetch_lazy_hint}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#fetch_option}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterFetch_option(EQLParser.Fetch_optionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#fetch_option}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFetch_option(EQLParser.Fetch_optionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#fetch_query_option}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterFetch_query_option(EQLParser.Fetch_query_optionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#fetch_query_option}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFetch_query_option(EQLParser.Fetch_query_optionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#fetch_lazy_option}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#fetch_lazy_option}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#fetch_batch_size}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#fetch_batch_size}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#conditional_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterConditional_expression(EQLParser.Conditional_expressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#conditional_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitConditional_expression(EQLParser.Conditional_expressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#conditional_term}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterConditional_term(EQLParser.Conditional_termContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#conditional_term}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitConditional_term(EQLParser.Conditional_termContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#conditional_factor}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterConditional_factor(EQLParser.Conditional_factorContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#conditional_factor}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitConditional_factor(EQLParser.Conditional_factorContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#conditional_primary}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterConditional_primary(EQLParser.Conditional_primaryContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#conditional_primary}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitConditional_primary(EQLParser.Conditional_primaryContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#any_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterAny_expression(EQLParser.Any_expressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#any_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitAny_expression(EQLParser.Any_expressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#in_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterIn_expression(EQLParser.In_expressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#in_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitIn_expression(EQLParser.In_expressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#in_value}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterIn_value(EQLParser.In_valueContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#in_value}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitIn_value(EQLParser.In_valueContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#between_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterBetween_expression(EQLParser.Between_expressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#between_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitBetween_expression(EQLParser.Between_expressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#propertyBetween_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#propertyBetween_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#isNull_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterIsNull_expression(EQLParser.IsNull_expressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#isNull_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitIsNull_expression(EQLParser.IsNull_expressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#isNotNull_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#isNotNull_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#isEmpty_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#isEmpty_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#isNotEmpty_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#isNotEmpty_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#like_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterLike_expression(EQLParser.Like_expressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#like_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitLike_expression(EQLParser.Like_expressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#like_op}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterLike_op(EQLParser.Like_opContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#like_op}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitLike_op(EQLParser.Like_opContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#comparison_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterComparison_expression(EQLParser.Comparison_expressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#comparison_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitComparison_expression(EQLParser.Comparison_expressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#comparison_operator}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterComparison_operator(EQLParser.Comparison_operatorContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#comparison_operator}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitComparison_operator(EQLParser.Comparison_operatorContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#value_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterValue_expression(EQLParser.Value_expressionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#value_expression}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitValue_expression(EQLParser.Value_expressionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#literal}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterLiteral(EQLParser.LiteralContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#literal}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitLiteral(EQLParser.LiteralContext ctx);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,72 @@
|
||||
package com.avaje.ebeaninternal.server.lib;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* A "CachedThreadPool" based on Daemon threads.
|
||||
* <p>
|
||||
* The Threads are created as needed and once idle live for 60 seconds.
|
||||
*/
|
||||
public final class DaemonExecutorService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DaemonExecutorService.class);
|
||||
|
||||
private final String namePrefix;
|
||||
|
||||
private final int shutdownWaitSeconds;
|
||||
|
||||
private final ExecutorService service;
|
||||
|
||||
/**
|
||||
* Construct the DaemonThreadPool.
|
||||
*
|
||||
* @param shutdownWaitSeconds the time in seconds allowed for the pool to shutdown nicely. After
|
||||
* this the pool is forced to shutdown.
|
||||
*/
|
||||
public DaemonExecutorService(int shutdownWaitSeconds, String namePrefix) {
|
||||
this.service = Executors.newCachedThreadPool(new DaemonThreadFactory(namePrefix));
|
||||
this.shutdownWaitSeconds = shutdownWaitSeconds;
|
||||
this.namePrefix = namePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the Runnable.
|
||||
*/
|
||||
public void execute(Runnable runnable) {
|
||||
service.execute(runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown this thread pool nicely if possible.
|
||||
* <p>
|
||||
* This will wait a maximum of 20 seconds before terminating any threads still
|
||||
* working.
|
||||
* </p>
|
||||
*/
|
||||
public void shutdown() {
|
||||
synchronized (this) {
|
||||
if (service.isShutdown()) {
|
||||
logger.debug("DaemonExecutorService[{}] already shut down", namePrefix);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
logger.debug("DaemonExecutorService[{}] shutting down...", namePrefix);
|
||||
service.shutdown();
|
||||
if (!service.awaitTermination(shutdownWaitSeconds, TimeUnit.SECONDS)) {
|
||||
logger.info("DaemonExecutorService[{}] shut down timeout exceeded. Terminating running threads.", namePrefix);
|
||||
service.shutdownNow();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during shutdown of DaemonThreadPool[" + namePrefix + "]", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,6 @@ import org.slf4j.LoggerFactory;
|
||||
* <p>
|
||||
* Uses Daemon threads and hooks into shutdown event.
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*/
|
||||
public final class DaemonScheduleThreadPool extends ScheduledThreadPoolExecutor {
|
||||
|
||||
@@ -26,19 +24,11 @@ public final class DaemonScheduleThreadPool extends ScheduledThreadPoolExecutor
|
||||
* Construct the DaemonScheduleThreadPool.
|
||||
*/
|
||||
public DaemonScheduleThreadPool(int coreSize, int shutdownWaitSeconds, String namePrefix) {
|
||||
|
||||
super(coreSize, new DaemonThreadFactory(namePrefix));
|
||||
this.namePrefix = namePrefix;
|
||||
this.shutdownWaitSeconds = shutdownWaitSeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a shutdown hook with the JVM Runtime.
|
||||
*/
|
||||
public void registerShutdownHook() {
|
||||
Runtime.getRuntime().addShutdownHook(new ShutdownHook());
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown this thread pool nicely if possible.
|
||||
* <p>
|
||||
@@ -66,14 +56,4 @@ public final class DaemonScheduleThreadPool extends ScheduledThreadPoolExecutor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired by the JVM Runtime shutdown.
|
||||
*/
|
||||
private class ShutdownHook extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.lib;
|
||||
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The Thread Pool based on Daemon threads.
|
||||
*
|
||||
* @author rbygrave
|
||||
*/
|
||||
public final class DaemonThreadPool extends ThreadPoolExecutor {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DaemonThreadPool.class);
|
||||
|
||||
private final String namePrefix;
|
||||
|
||||
private final int shutdownWaitSeconds;
|
||||
|
||||
/**
|
||||
* Construct the DaemonThreadPool.
|
||||
*
|
||||
* @param coreSize
|
||||
* the core size of the thread pool.
|
||||
* @param keepAliveSecs
|
||||
* the time in seconds idle threads are keep alive
|
||||
* @param shutdownWaitSeconds
|
||||
* the time in seconds allowed for the pool to shutdown nicely. After
|
||||
* this the pool is forced to shutdown.
|
||||
*/
|
||||
public DaemonThreadPool(int coreSize, int maximumPoolSize, long keepAliveSecs, int shutdownWaitSeconds, String namePrefix) {
|
||||
|
||||
super(coreSize, maximumPoolSize, keepAliveSecs, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new DaemonThreadFactory(namePrefix));
|
||||
allowCoreThreadTimeOut(true);
|
||||
this.shutdownWaitSeconds = shutdownWaitSeconds;
|
||||
this.namePrefix = namePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a shutdown hook with the JVM Runtime.
|
||||
*/
|
||||
public void registerShutdownHook() {
|
||||
Runtime.getRuntime().addShutdownHook(new ShutdownHook());
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown this thread pool nicely if possible.
|
||||
* <p>
|
||||
* This will wait a maximum of 20 seconds before terminating any threads still
|
||||
* working.
|
||||
* </p>
|
||||
*/
|
||||
public void shutdown() {
|
||||
synchronized (this) {
|
||||
if (super.isShutdown()) {
|
||||
logger.debug("DaemonThreadPool[" + namePrefix + "] already shut down");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
logger.debug("DaemonThreadPool[" + namePrefix + "] shutting down...");
|
||||
super.shutdown();
|
||||
if (!super.awaitTermination(shutdownWaitSeconds, TimeUnit.SECONDS)) {
|
||||
logger.info("DaemonThreadPool[" + namePrefix+ "] shut down timeout exceeded. Terminating running threads.");
|
||||
super.shutdownNow();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during shutdown of DaemonThreadPool[" + namePrefix + "]", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired by the JVM Runtime shutdown.
|
||||
*/
|
||||
private class ShutdownHook extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import com.avaje.ebeaninternal.api.ManyWhereJoins;
|
||||
import com.avaje.ebeaninternal.api.SpiExpression;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionList;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionValidation;
|
||||
import com.avaje.ebeaninternal.api.SpiNamedParam;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.api.SpiQuerySecondary;
|
||||
import com.avaje.ebeaninternal.server.autotune.ProfilingListener;
|
||||
@@ -28,6 +29,8 @@ 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;
|
||||
import java.util.Map;
|
||||
@@ -91,11 +94,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
|
||||
private String generatedSql;
|
||||
|
||||
/**
|
||||
* Query language version of the query.
|
||||
*/
|
||||
private String query;
|
||||
|
||||
private String lazyLoadProperty;
|
||||
|
||||
private String lazyLoadManyPath;
|
||||
@@ -135,6 +133,8 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
*/
|
||||
private Object id;
|
||||
|
||||
private Map<String,ONamedParam> namedParams;
|
||||
|
||||
/**
|
||||
* Bind parameters when using the query language.
|
||||
*/
|
||||
@@ -564,7 +564,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
copy.includeTableJoin = includeTableJoin;
|
||||
copy.profilingListener = profilingListener;
|
||||
|
||||
copy.query = query;
|
||||
// copy.query = query;
|
||||
copy.rootTableAlias = rootTableAlias;
|
||||
copy.distinct = distinct;
|
||||
copy.sqlDistinct = sqlDistinct;
|
||||
@@ -837,7 +837,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
CQueryPlanKey createQueryPlanKey() {
|
||||
|
||||
queryPlanKey = new OrmQueryPlanKey(includeTableJoin, type, detail, maxRows, firstRow,
|
||||
disableLazyLoading, orderBy, query,
|
||||
disableLazyLoading, orderBy,
|
||||
distinct, sqlDistinct, mapKey, id, bindParams, whereExpressions, havingExpressions,
|
||||
temporalMode, forUpdate, rootTableAlias, rawSql, updateProperties);
|
||||
|
||||
@@ -1138,6 +1138,15 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
*/
|
||||
@Override
|
||||
public DefaultOrmQuery<T> setParameter(String name, Object value) {
|
||||
|
||||
if (namedParams != null) {
|
||||
ONamedParam param = namedParams.get(name);
|
||||
if (param != null) {
|
||||
param.setValue(value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
if (bindParams == null) {
|
||||
bindParams = new BindParams();
|
||||
}
|
||||
@@ -1308,11 +1317,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
return bindParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultOrmQuery<T> where(Expression expression) {
|
||||
where().add(expression);
|
||||
@@ -1336,6 +1340,13 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
return whereExpressions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simplifyExpressions() {
|
||||
if (whereExpressions != null) {
|
||||
whereExpressions.simplify();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultOrmQuery<T> having(Expression expression) {
|
||||
having().add(expression);
|
||||
@@ -1375,6 +1386,30 @@ 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) {
|
||||
namedParams = new HashMap<String, ONamedParam>();
|
||||
}
|
||||
|
||||
ONamedParam param = namedParams.get(name);
|
||||
if (param == null) {
|
||||
param = new ONamedParam(name);
|
||||
namedParams.put(name, param);
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultFetchBuffer(int fetchSize) {
|
||||
if (bufferFetchSizeHint == 0) {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
|
||||
private final int maxRows;
|
||||
private final int firstRow;
|
||||
private final boolean disableLazyLoading;
|
||||
private final String query;
|
||||
private final boolean distinct;
|
||||
private final boolean sqlDistinct;
|
||||
private final String mapKey;
|
||||
@@ -37,7 +36,7 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
|
||||
private final int planHash;
|
||||
private final int bindCount;
|
||||
|
||||
public OrmQueryPlanKey(TableJoin includeTableJoin, SpiQuery.Type type, OrmQueryDetail detail, int maxRows, int firstRow, boolean disableLazyLoading, OrderBy<?> orderBy, String query, boolean distinct, boolean sqlDistinct, String mapKey, Object id, BindParams bindParams, SpiExpression whereExpressions, SpiExpression havingExpressions, SpiQuery.TemporalMode temporalMode, boolean forUpdate, String rootTableAlias, RawSql rawSql, OrmUpdateProperties updateProperties) {
|
||||
public OrmQueryPlanKey(TableJoin includeTableJoin, SpiQuery.Type type, OrmQueryDetail detail, int maxRows, int firstRow, boolean disableLazyLoading, OrderBy<?> orderBy, boolean distinct, boolean sqlDistinct, String mapKey, Object id, BindParams bindParams, SpiExpression whereExpressions, SpiExpression havingExpressions, SpiQuery.TemporalMode temporalMode, boolean forUpdate, String rootTableAlias, RawSql rawSql, OrmUpdateProperties updateProperties) {
|
||||
|
||||
this.includeTableJoin = includeTableJoin;
|
||||
this.type = type;
|
||||
@@ -46,7 +45,6 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
|
||||
this.firstRow = firstRow;
|
||||
this.disableLazyLoading = disableLazyLoading;
|
||||
this.orderByAsSting = (orderBy == null) ? null : orderBy.toStringFormat();
|
||||
this.query = query;
|
||||
this.distinct = distinct;
|
||||
this.sqlDistinct = sqlDistinct;
|
||||
this.mapKey = mapKey;
|
||||
@@ -63,7 +61,7 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
|
||||
HashQueryPlanBuilder builder = new HashQueryPlanBuilder();
|
||||
|
||||
builder.add((type == null ? 0 : type.ordinal() + 1));
|
||||
builder.add(distinct).add(sqlDistinct).add(query);
|
||||
builder.add(distinct).add(sqlDistinct);
|
||||
builder.add(firstRow).add(maxRows);
|
||||
builder.add(orderBy).add(forUpdate);
|
||||
builder.add(mapKey);
|
||||
@@ -131,7 +129,6 @@ public class OrmQueryPlanKey implements CQueryPlanKey {
|
||||
|
||||
// if (detail != null ? !detail.equals(that.detail) : that.detail != null) return false;
|
||||
|
||||
if (query != null ? !query.equals(that.query) : that.query != null) return false;
|
||||
if (mapKey != null ? !mapKey.equals(that.mapKey) : that.mapKey != null) return false;
|
||||
return rootTableAlias != null ? rootTableAlias.equals(that.rootTableAlias) : that.rootTableAlias == null;
|
||||
}
|
||||
|
||||
@@ -77,4 +77,12 @@ public class ObjectFactory {
|
||||
return new XmEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link XmNamedQuery }
|
||||
*
|
||||
*/
|
||||
public XmNamedQuery createNamedQuery() {
|
||||
return new XmNamedQuery();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlType;
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element ref="{http://ebean-orm.github.io/xml/ns/ebean}named-query" maxOccurs="unbounded"/>
|
||||
* <element ref="{http://ebean-orm.github.io/xml/ns/ebean}raw-sql" maxOccurs="unbounded"/>
|
||||
* </sequence>
|
||||
* <attribute name="class" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
|
||||
@@ -33,16 +34,48 @@ import javax.xml.bind.annotation.XmlType;
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "", propOrder = {
|
||||
"namedQuery",
|
||||
"rawSql"
|
||||
})
|
||||
@XmlRootElement(name = "entity")
|
||||
public class XmEntity {
|
||||
|
||||
@XmlElement(name = "named-query", required = true)
|
||||
protected List<XmNamedQuery> namedQuery;
|
||||
@XmlElement(name = "raw-sql", required = true)
|
||||
protected List<XmRawSql> rawSql;
|
||||
@XmlAttribute(name = "class", required = true)
|
||||
protected String clazz;
|
||||
|
||||
/**
|
||||
* Gets the value of the namedQuery property.
|
||||
*
|
||||
* <p>
|
||||
* This accessor method returns a reference to the live list,
|
||||
* not a snapshot. Therefore any modification you make to the
|
||||
* returned list will be present inside the JAXB object.
|
||||
* This is why there is not a <CODE>set</CODE> method for the namedQuery property.
|
||||
*
|
||||
* <p>
|
||||
* For example, to add a new item, do as follows:
|
||||
* <pre>
|
||||
* getNamedQuery().add(newItem);
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Objects of the following type(s) are allowed in the list
|
||||
* {@link XmNamedQuery }
|
||||
*
|
||||
*
|
||||
*/
|
||||
public List<XmNamedQuery> getNamedQuery() {
|
||||
if (namedQuery == null) {
|
||||
namedQuery = new ArrayList<XmNamedQuery>();
|
||||
}
|
||||
return this.namedQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the rawSql property.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
|
||||
package com.avaje.ebeaninternal.xmlmapping.model;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for anonymous complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType>
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element ref="{http://ebean-orm.github.io/xml/ns/ebean}query"/>
|
||||
* </sequence>
|
||||
* <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "", propOrder = {
|
||||
"query"
|
||||
})
|
||||
@XmlRootElement(name = "named-query")
|
||||
public class XmNamedQuery {
|
||||
|
||||
@XmlElement(required = true)
|
||||
protected XmQuery query;
|
||||
@XmlAttribute(name = "name", required = true)
|
||||
protected String name;
|
||||
|
||||
/**
|
||||
* Gets the value of the query property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link XmQuery }
|
||||
*
|
||||
*/
|
||||
public XmQuery getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the query property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link XmQuery }
|
||||
*
|
||||
*/
|
||||
public void setQuery(XmQuery value) {
|
||||
this.query = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the name property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the name property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,12 +15,22 @@
|
||||
<xsd:element name="entity">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element ref="raw-sql" minOccurs="1" maxOccurs="unbounded"/>
|
||||
<xsd:element ref="named-query" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xsd:element ref="raw-sql" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="class" type="xsd:string" use="required"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="named-query">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element ref="query" minOccurs="1" maxOccurs="1"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="raw-sql">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.avaje.ebean;
|
||||
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class EbeanServer_eqlTest extends BaseTestCase {
|
||||
|
||||
|
||||
@Test
|
||||
public void basic() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = server().createQuery(Customer.class, "order by id limit 10");
|
||||
query.setMaxRows(100);
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("order by t0.id ");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basic_via_Ebean_defaultServer() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = Ebean.createQuery(Customer.class, "order by id limit 10");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("order by t0.id ");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void orderBy_override() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = server().createQuery(Customer.class, "order by id");
|
||||
|
||||
// use clear() and then effectively override the orderBy clause
|
||||
query.orderBy().clear().asc("name");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("order by t0.name");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void namedParams() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = server().createQuery(Customer.class, "where name startsWith :name order by name");
|
||||
query.setParameter("name", "Ro");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where t0.name like ? ");
|
||||
}
|
||||
|
||||
@Test(expected = PersistenceException.class)
|
||||
public void unboundNamedParams_expect_PersistenceException() {
|
||||
|
||||
Query<Customer> query = server().createQuery(Customer.class, "where name = :name");
|
||||
query.findUnique();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void namedQuery() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> name = server().createNamedQuery(Customer.class, "name");
|
||||
name.findList();
|
||||
|
||||
assertThat(name.getGeneratedSql()).contains("select t0.id c0, t0.name c1 from o_customer t0 order by t0.name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void namedQuery_withStatus() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> name = server().createNamedQuery(Customer.class, "withStatus");
|
||||
name.order().clear().asc("status");
|
||||
name.findList();
|
||||
|
||||
assertThat(name.getGeneratedSql()).contains("select t0.id c0, t0.name c1, t0.status c2 from o_customer t0 order by t0.status");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void namedQuery_withContacts() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = server()
|
||||
.createNamedQuery(Customer.class, "withContacts")
|
||||
.setParameter("id", 1);
|
||||
|
||||
query.setUseCache(false);
|
||||
query.findUnique();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("from o_customer t0 left outer join contact t1 on t1.customer_id = t0.id ");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void namedQuery_fromXml() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = server()
|
||||
.createNamedQuery(Customer.class, "withContactsById")
|
||||
.setParameter("id", 1);
|
||||
|
||||
query.setUseCache(false);
|
||||
query.findUnique();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("from o_customer t0 left outer join contact t1 on t1.customer_id = t0.id ");
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,8 @@ public class ServerConfigTest {
|
||||
props.setProperty("dbuuid","binary");
|
||||
props.setProperty("jdbcFetchSizeFindEach", "42");
|
||||
props.setProperty("jdbcFetchSizeFindList", "43");
|
||||
props.setProperty("backgroundExecutorShutdownSecs", "98");
|
||||
props.setProperty("backgroundExecutorSchedulePoolSize", "4");
|
||||
|
||||
serverConfig.loadFromProperties(props);
|
||||
|
||||
@@ -40,6 +42,8 @@ public class ServerConfigTest {
|
||||
assertEquals(ServerConfig.DbUuid.BINARY, serverConfig.getDbUuid());
|
||||
assertEquals(42, serverConfig.getJdbcFetchSizeFindEach());
|
||||
assertEquals(43, serverConfig.getJdbcFetchSizeFindList());
|
||||
assertEquals(4, serverConfig.getBackgroundExecutorSchedulePoolSize());
|
||||
assertEquals(98, serverConfig.getBackgroundExecutorShutdownSecs());
|
||||
|
||||
serverConfig.setPersistBatch(PersistBatch.NONE);
|
||||
serverConfig.setPersistBatchOnCascade(PersistBatch.NONE);
|
||||
|
||||
@@ -290,6 +290,11 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Query<T> createQuery(Class<T> beanType, String eql) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Query<T> createQuery(Class<T> beanType) {
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.avaje.ebeaninternal.server.core;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DefaultBackgroundExecutorTest {
|
||||
|
||||
@Test @Ignore
|
||||
public void shutdown_when_running_expect_waitAndNiceShutdown() throws Exception {
|
||||
|
||||
DefaultBackgroundExecutor es = new DefaultBackgroundExecutor(1, 20, "test");
|
||||
|
||||
es.execute(new RunFor(3000,"a"));
|
||||
es.execute(new RunFor(3000,"b"));
|
||||
es.execute(new RunFor(3000,"c"));
|
||||
|
||||
es.shutdown();
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
public void shutdown_when_rougeRunnable_expect_InterruptedException() throws Exception {
|
||||
|
||||
DefaultBackgroundExecutor es = new DefaultBackgroundExecutor(1, 10, "test");
|
||||
|
||||
es.execute(new RunFor(300000,"a"));
|
||||
es.execute(new RunFor(3000,"b"));
|
||||
es.execute(new RunFor(3000,"c"));
|
||||
|
||||
es.shutdown();
|
||||
}
|
||||
|
||||
|
||||
class RunFor implements Runnable {
|
||||
|
||||
final long wait;
|
||||
final String id;
|
||||
|
||||
RunFor(long wait, String id) {
|
||||
this.wait = wait;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
System.out.println("start " + id);
|
||||
Thread.sleep(wait);
|
||||
System.out.println("done " + id);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,17 @@ import com.avaje.ebean.bean.BeanCollection;
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.tests.model.basic.Contact;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class BeanPropertyAssocManyTest extends BaseTestCase {
|
||||
|
||||
@@ -40,4 +46,21 @@ public class BeanPropertyAssocManyTest extends BaseTestCase {
|
||||
assertTrue(ref.isReference());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void findIdsByParentId() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
List<Object> customerIds = new ArrayList<Object>();
|
||||
customerIds.add(1L);
|
||||
customerIds.add(2L);
|
||||
|
||||
List<Object> contactIdsForOne = contacts().findIdsByParentId(1L, null, null, null);
|
||||
|
||||
List<Object> contactIdsForMultiple = contacts().findIdsByParentId(null, customerIds, null, null);
|
||||
|
||||
assertThat(contactIdsForOne).isNotEmpty();
|
||||
assertThat(contactIdsForMultiple).isNotEmpty();
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,9 @@ public class InExpressionTest {
|
||||
InExpression ex1 = new InExpression("foo", values, false);
|
||||
InExpression ex2 = new InExpression("bar", values, false);
|
||||
|
||||
ex1.prepareExpression(null);
|
||||
ex2.prepareExpression(null);
|
||||
|
||||
HashQueryPlanBuilder b1 = new HashQueryPlanBuilder();
|
||||
ex1.queryPlanHash(b1);
|
||||
|
||||
@@ -41,6 +44,9 @@ public class InExpressionTest {
|
||||
InExpression ex1 = new InExpression("foo", values1, false);
|
||||
InExpression ex2 = new InExpression("foo", values2, false);
|
||||
|
||||
ex1.prepareExpression(null);
|
||||
ex2.prepareExpression(null);
|
||||
|
||||
HashQueryPlanBuilder b1 = new HashQueryPlanBuilder();
|
||||
ex1.queryPlanHash(b1);
|
||||
|
||||
@@ -58,6 +64,9 @@ public class InExpressionTest {
|
||||
InExpression ex1 = new InExpression("foo", values, true);
|
||||
InExpression ex2 = new InExpression("foo", values, false);
|
||||
|
||||
ex1.prepareExpression(null);
|
||||
ex2.prepareExpression(null);
|
||||
|
||||
HashQueryPlanBuilder b1 = new HashQueryPlanBuilder();
|
||||
ex1.queryPlanHash(b1);
|
||||
|
||||
@@ -75,6 +84,9 @@ public class InExpressionTest {
|
||||
InExpression ex1 = new InExpression("foo", values, true);
|
||||
InExpression ex2 = new InExpression("foo", values, true);
|
||||
|
||||
ex1.prepareExpression(null);
|
||||
ex2.prepareExpression(null);
|
||||
|
||||
HashQueryPlanBuilder b1 = new HashQueryPlanBuilder();
|
||||
ex1.queryPlanHash(b1);
|
||||
|
||||
@@ -94,7 +106,9 @@ public class InExpressionTest {
|
||||
|
||||
@NotNull
|
||||
private InExpression exp(String propName, boolean not, Object... values) {
|
||||
return new InExpression(propName, Arrays.asList(values), not);
|
||||
InExpression ex = new InExpression(propName, Arrays.asList(values), not);
|
||||
ex.prepareExpression(null);
|
||||
return ex;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,400 @@
|
||||
package com.avaje.ebeaninternal.server.grammer;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.Query;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class EqlParserTest extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void where_eq() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name eq 'Rob'");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where t0.name = ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_ieq() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name ieq 'Rob'");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where lower(t0.name) =?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_eq2() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name = 'Rob'");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where t0.name = ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_namedParam() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name eq :name");
|
||||
query.setParameter("name", "Rob");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where t0.name = ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_namedParam_startsWith() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name startsWith :name");
|
||||
query.setParameter("name", "Rob");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where t0.name like ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_or1() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name = 'Rob' or (status = 'NEW' and smallnote is null)");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where (t0.name = ? or (t0.status = ? and t0.smallnote is null ) )");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_or2() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where (name = 'Rob' or status = 'NEW') and smallnote is null");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where ((t0.name = ? or t0.status = ? ) and t0.smallnote is null )");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_simplifyExpressions() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where not (name = 'Rob' and status = 'NEW')");
|
||||
query.findList();
|
||||
assertThat(query.getGeneratedSql()).contains("where not (t0.name = ? and t0.status = ? )");
|
||||
|
||||
query = parse("where not ((name = 'Rob' and status = 'NEW'))");
|
||||
query.findList();
|
||||
assertThat(query.getGeneratedSql()).contains("where not (t0.name = ? and t0.status = ? )");
|
||||
|
||||
query = parse("where not (((name = 'Rob') and (status = 'NEW')))");
|
||||
query.findList();
|
||||
assertThat(query.getGeneratedSql()).contains("where not (t0.name = ? and t0.status = ? )");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void where_in() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name in ('Rob','Jim')");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where t0.name in (?, ? )");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_in_when_namedParams() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name in (:one, :two)");
|
||||
query.setParameter("one", "Foo");
|
||||
query.setParameter("two", "Bar");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where t0.name in (?, ? )");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_in_when_namedParams_withWhitespace() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name in (:one, :two)");
|
||||
query.setParameter("one", "Foo");
|
||||
query.setParameter("two", "Bar");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where t0.name in (?, ? )");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_in_when_namedParams_withNoWhitespace() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name in (:one,:two)");
|
||||
query.setParameter("one", "Foo");
|
||||
query.setParameter("two", "Bar");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where t0.name in (?, ? )");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_in_when_namedParamAsList() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name in (:names)");
|
||||
query.setParameter("names", Arrays.asList("Baz","Maz","Jim"));
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where t0.name in (?, ?, ? )");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_between() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name between 'As' and 'B'");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where t0.name between ? and ? ");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_between_withNamedParams() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name between :one and :two");
|
||||
query.setParameter("one", "a");
|
||||
query.setParameter("two", "b");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where t0.name between ? and ? ");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_betweenProperty() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where 'x' between name and smallnote");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where ? between t0.name and t0.smallnote");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_betweenProperty_withNamed() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where :some between name and smallnote");
|
||||
query.setParameter("some", "A");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where ? between t0.name and t0.smallnote");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fetch_basic() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("fetch billingAddress");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains(", t1.id c9");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fetch_withProperty() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("fetch billingAddress (city)");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains(", t1.id c9, t1.city");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fetch_withProperty_noWhitespace() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("fetch billingAddress(city)");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains(", t1.id c9, t1.city");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fetch_basic_multiple() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("fetch billingAddress fetch shippingAddress");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains(", t1.city ");
|
||||
assertThat(query.getGeneratedSql()).contains(", t2.city ");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fetch_basic_multiple_withProperties() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("fetch billingAddress (city) fetch shippingAddress (city)");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains(", t1.id c8, t1.city c9, t2.id c10, t2.city c11");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fetch_lazy() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("fetch lazy billingAddress");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).doesNotContain(", t1.city ");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fetch_lazy50() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("fetch lazy(50) billingAddress");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).doesNotContain(", t1.city ");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fetch_query50() throws Exception {
|
||||
|
||||
ResetBasicData.reset();
|
||||
Query<Customer> query = parse("fetch query(50) billingAddress");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).doesNotContain(", t1.city ");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fetch_query50_asHint() throws Exception {
|
||||
|
||||
ResetBasicData.reset();
|
||||
Query<Customer> query = parse("fetch billingAddress (+query(50),city)");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).doesNotContain(", t1.city ");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fetch_lazy50_asHint() throws Exception {
|
||||
|
||||
ResetBasicData.reset();
|
||||
Query<Customer> query = parse("fetch billingAddress (+lazy(50),city)");
|
||||
List<Customer> list = query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).doesNotContain(", t1.city ");
|
||||
|
||||
Customer customer = list.get(0);
|
||||
customer.getBillingAddress().getCity();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void select() throws Exception {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = parse("select (name)");
|
||||
query.findList();
|
||||
assertThat(query.getGeneratedSql()).contains("select t0.id c0, t0.name c1 from o_customer t0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void selectDistinct() throws Exception {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = parse("select distinct (name)");
|
||||
query.findList();
|
||||
assertThat(query.getGeneratedSql()).contains("select distinct t0.name c0 from o_customer t0");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void limit() throws Exception {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = parse("limit 10");
|
||||
query.findList();
|
||||
if (isH2()) {
|
||||
assertThat(query.getGeneratedSql()).contains(" limit 10");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void limitOffset() throws Exception {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = parse("limit 10 offset 5");
|
||||
query.findList();
|
||||
if (isH2()) {
|
||||
assertThat(query.getGeneratedSql()).contains(" limit 10 offset 5");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void orderBy() throws Exception {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = parse("order by id");
|
||||
query.findList();
|
||||
if (isH2()) {
|
||||
assertThat(query.getGeneratedSql()).contains("from o_customer t0 order by t0.id");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void orderBy_desc() throws Exception {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = parse("order by id desc");
|
||||
query.findList();
|
||||
if (isH2()) {
|
||||
assertThat(query.getGeneratedSql()).contains("from o_customer t0 order by t0.id desc");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void orderBy_nullsLast() throws Exception {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = parse("order by id desc nulls last");
|
||||
query.findList();
|
||||
if (isH2()) {
|
||||
assertThat(query.getGeneratedSql()).contains(" from o_customer t0 order by t0.id desc nulls last");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void orderBy_nullsFirst() throws Exception {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = parse("order by id nulls first");
|
||||
query.findList();
|
||||
if (isH2()) {
|
||||
assertThat(query.getGeneratedSql()).contains(" from o_customer t0 order by t0.id nulls first");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void orderBy_multiple() throws Exception {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = parse("order by billingAddress.city desc nulls last, name, id desc nulls last");
|
||||
query.findList();
|
||||
if (isH2()) {
|
||||
assertThat(query.getGeneratedSql()).contains(" order by t1.city desc nulls last, t0.name, t0.id desc nulls last");
|
||||
}
|
||||
}
|
||||
|
||||
private Query<Customer> parse(String raw) {
|
||||
|
||||
Query<Customer> query = Ebean.find(Customer.class);
|
||||
EqlParser.parse(raw, (SpiQuery)query);
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.avaje.ebeaninternal.server.grammer;
|
||||
|
||||
import com.avaje.ebean.FetchConfig;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class ParseFetchConfigTest {
|
||||
|
||||
@Test
|
||||
public void parse() throws Exception {
|
||||
|
||||
assertNull(ParseFetchConfig.parse("junk"));
|
||||
assertNull(ParseFetchConfig.parse("lazyFoo"));
|
||||
assertNull(ParseFetchConfig.parse("queryFoo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseLazy() throws Exception {
|
||||
|
||||
FetchConfig lazy = ParseFetchConfig.parse("lazy");
|
||||
assertThat(lazy.getLazyBatchSize()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseLazy100() throws Exception {
|
||||
|
||||
FetchConfig lazy = ParseFetchConfig.parse("lazy(100)");
|
||||
assertThat(lazy.getLazyBatchSize()).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseQuery() throws Exception {
|
||||
|
||||
FetchConfig lazy = ParseFetchConfig.parse("query");
|
||||
assertThat(lazy.getQueryBatchSize()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseQuery100() throws Exception {
|
||||
|
||||
FetchConfig lazy = ParseFetchConfig.parse("query(50)");
|
||||
assertThat(lazy.getQueryBatchSize()).isEqualTo(50);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -22,7 +22,7 @@ public class TestDataSourceMaxWithEntity extends BaseTestCase {
|
||||
EbeanServer server = Ebean.getServer(null);
|
||||
|
||||
|
||||
DefaultBackgroundExecutor bg = new DefaultBackgroundExecutor(1, 1, 2, 180, 30, "testDs");
|
||||
DefaultBackgroundExecutor bg = new DefaultBackgroundExecutor(1, 30, "testDs");
|
||||
|
||||
try {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
|
||||
@@ -37,6 +37,7 @@ public class DefaultOrmQueryTest {
|
||||
DefaultOrmQuery<Order> q1 = (DefaultOrmQuery<Order>)Ebean.find(Order.class).where().in("name", "a","b","c").query();
|
||||
DefaultOrmQuery<Order> q2 = (DefaultOrmQuery<Order>)Ebean.find(Order.class).where().in("id", 2,2,3).query();
|
||||
|
||||
prepare(q1, q2);
|
||||
assertThat(q1.createQueryPlanKey()).isNotEqualTo(q2.createQueryPlanKey());
|
||||
assertThat(q1.queryBindHash()).isNotEqualTo(q2.queryBindHash());
|
||||
}
|
||||
@@ -47,6 +48,7 @@ public class DefaultOrmQueryTest {
|
||||
DefaultOrmQuery<Order> q1 = (DefaultOrmQuery<Order>)Ebean.find(Order.class).where().in("id", 1,2,3).query();
|
||||
DefaultOrmQuery<Order> q2 = (DefaultOrmQuery<Order>)Ebean.find(Order.class).where().in("id", 2,2,3).query();
|
||||
|
||||
prepare(q1, q2);
|
||||
assertThat(q1.createQueryPlanKey()).isEqualTo(q2.createQueryPlanKey());
|
||||
assertThat(q1.queryBindHash()).isNotEqualTo(q2.queryBindHash());
|
||||
}
|
||||
@@ -57,6 +59,7 @@ public class DefaultOrmQueryTest {
|
||||
DefaultOrmQuery<Order> q1 = (DefaultOrmQuery<Order>)Ebean.find(Order.class).where().in("id", 1,2,3).query();
|
||||
DefaultOrmQuery<Order> q2 = (DefaultOrmQuery<Order>)Ebean.find(Order.class).where().in("id", 1,2,3).query();
|
||||
|
||||
prepare(q1, q2);
|
||||
assertThat(q1.createQueryPlanKey()).isEqualTo(q2.createQueryPlanKey());
|
||||
assertThat(q1.queryBindHash()).isEqualTo(q2.queryBindHash());
|
||||
}
|
||||
@@ -72,7 +75,12 @@ public class DefaultOrmQueryTest {
|
||||
.setFirstRow(1)
|
||||
.setMaxRows(0);
|
||||
|
||||
prepare(query1, query2);
|
||||
assertThat(query1.createQueryPlanKey()).isNotEqualTo(query2.createQueryPlanKey());
|
||||
}
|
||||
|
||||
private void prepare(DefaultOrmQuery<?> q1, DefaultOrmQuery<?> q2) {
|
||||
q1.prepare(null);
|
||||
q2.prepare(null);
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
@Test
|
||||
public void equals_when_defaults() {
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
|
||||
assertSame(key1, key2);
|
||||
}
|
||||
@@ -32,8 +32,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
|
||||
TableJoin tableJoin = tableJoin("id", "customer_id");
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(tableJoin, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(tableJoin, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
@@ -44,8 +44,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
TableJoin tableJoin1 = tableJoin("id", "customer_id");
|
||||
TableJoin tableJoin2 = tableJoin("id", "other_customer_id");
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(tableJoin1, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(tableJoin2, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(tableJoin1, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(tableJoin2, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
@@ -56,8 +56,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
TableJoin tableJoin1 = tableJoin("id", "customer_id");
|
||||
TableJoin tableJoin2 = tableJoin("id", "customer_id");
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(tableJoin1, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(tableJoin2, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(tableJoin1, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(tableJoin2, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
|
||||
assertSame(key1, key2);
|
||||
}
|
||||
@@ -73,8 +73,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
@Test
|
||||
public void equals_when_diffQueryType() {
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.LIST, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.LIST, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
@@ -82,8 +82,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
@Test
|
||||
public void equals_when_firstRowsDifferent() {
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 10, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 10, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
@@ -91,8 +91,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
@Test
|
||||
public void equals_when_maxRowsDifferent() {
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 10, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 10, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
@@ -100,8 +100,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
@Test
|
||||
public void equals_when_firstRowsMaxRowsSame() {
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 10, 20, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 10, 20, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 10, 20, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 10, 20, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
|
||||
assertSame(key1, key2);
|
||||
}
|
||||
@@ -109,8 +109,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
@Test
|
||||
public void equals_when_diffDisableLazyLoading() {
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, true, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, true, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
@@ -119,8 +119,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
public void equals_when_diffOrderByNull() {
|
||||
|
||||
OrderBy<Object> o1 = new OrderBy<Object>("id");
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, o1, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, o1, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
@@ -130,130 +130,107 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
|
||||
OrderBy<Object> o1 = new OrderBy<Object>("id, name");
|
||||
OrderBy<Object> o2 = new OrderBy<Object>("id, name");
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, o1, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, o2, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, o1, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, o2, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
|
||||
assertSame(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffQueryNull() {
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, "query", false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void equals_when_diffQuery() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, "query", false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, "queryDiff", false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_querySame() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, "query", false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, "query", false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertSame(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffDistinct() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, true, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, true, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_sameDistinct() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, true, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, true, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, true, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, true, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertSame(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffSqlDistinct() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, true, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, true, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_sameSqlDistinct() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, true, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, true, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, true, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, true, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertSame(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffMapKeyNull() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, "mapKey", null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, "mapKey", null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffMapKey() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, "mapKey", null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, "diff", null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, "mapKey", null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, "diff", null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_sameMapKey() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, "mapKey", null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, "mapKey", null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, "mapKey", null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, "mapKey", null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertSame(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffIdNull() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, 42, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, 42, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_idBothGiven() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, 42, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, 23, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, 42, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, 23, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertSame(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffTemporalMode() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.DRAFT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.DRAFT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffForUpdate() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, true, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, true, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffRootAliasNull() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, "rootAlias", null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, "rootAlias", null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffRootAlias() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, "rootAlias", null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, "diff", null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, "rootAlias", null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, "diff", null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_sameRootAlias() {
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, "rootAlias", null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, "rootAlias", null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, "rootAlias", null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, "rootAlias", null, null);
|
||||
assertSame(key1, key2);
|
||||
}
|
||||
|
||||
@@ -280,8 +257,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
SpiExpressionList<Customer> list1 = list_id_eq_42();
|
||||
SpiExpressionList<Customer> list2 = list_id_eq_43();
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, list1, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, list2, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, list1, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, list2, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertSame(key1, key2);
|
||||
}
|
||||
|
||||
@@ -292,8 +269,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
SpiExpressionList<Customer> where1 = list_id_eq_42();
|
||||
SpiExpressionList<Customer> where2 = list_id_eq_42_and_name_eq_rob();
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, where1, null, SpiQuery.TemporalMode.DRAFT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, where2, null, SpiQuery.TemporalMode.DRAFT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, where1, null, SpiQuery.TemporalMode.DRAFT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, where2, null, SpiQuery.TemporalMode.DRAFT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@@ -302,8 +279,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
|
||||
SpiExpressionList<Customer> list1 = list_id_eq_42();
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, list1, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, list1, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@@ -312,8 +289,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
|
||||
SpiExpressionList<Customer> list1 = list_id_eq_42();
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, list1, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, list1, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@@ -323,8 +300,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
SpiExpression having1 = list_id_eq_42().copyForPlanKey();
|
||||
SpiExpression having2 = list_id_eq_42_and_name_eq_rob().copyForPlanKey();
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, having1, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, having2, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, having1, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, having2, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@@ -334,8 +311,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
SpiExpression having1 = list_id_eq_42().copyForPlanKey();
|
||||
SpiExpression having2 = list_id_eq_42().copyForPlanKey();
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, having1, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, having2, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, having1, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, having2, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertSame(key1, key2);
|
||||
}
|
||||
|
||||
@@ -344,8 +321,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
|
||||
SpiExpression having1 = list_id_eq_42().copyForPlanKey();
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, having1, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, having1, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
@@ -354,8 +331,8 @@ public class OrmQueryPlanKeyTest extends BaseExpressionTest {
|
||||
|
||||
SpiExpression having1 = list_id_eq_42().copyForPlanKey();
|
||||
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, null, false, false, null, null, null, null, having1, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key1 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, null, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
OrmQueryPlanKey key2 = new OrmQueryPlanKey(null, SpiQuery.Type.BEAN, null, 0, 0, false, null, false, false, null, null, null, null, having1, SpiQuery.TemporalMode.CURRENT, false, null, null, null);
|
||||
assertDifferent(key1, key2);
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -75,7 +75,8 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase {
|
||||
assertEquals(0, Ebean.find(User.class).findList().size());
|
||||
}
|
||||
|
||||
@Test public void testFindByParentIdList() {
|
||||
@Test
|
||||
public void testFindByParentIdList() {
|
||||
|
||||
if (isMsSqlServer()) return;
|
||||
|
||||
@@ -92,7 +93,8 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase {
|
||||
ids.add(1L);
|
||||
ids.add(2L);
|
||||
|
||||
beanProperty.findIdsByParentId(null, ids, null, null);
|
||||
beanProperty.findIdsByParentId(null, ids, null, null);
|
||||
beanProperty.findIdsByParentId(1L, null, null, null);
|
||||
}
|
||||
|
||||
@Entity @Table(name = "em_user") public static class User {
|
||||
|
||||
@@ -5,17 +5,8 @@ import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
|
||||
@Entity
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="loadResult",
|
||||
query="find CalculationResult " +
|
||||
"fetch productConfiguration "+
|
||||
"fetch groupConfiguration "+
|
||||
"where charge = :charge")
|
||||
})
|
||||
public class CalculationResult {
|
||||
|
||||
@Id
|
||||
|
||||
@@ -14,6 +14,8 @@ import com.avaje.tests.model.basic.finder.CustomerFinder;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
@@ -27,6 +29,13 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
/**
|
||||
* Customer entity bean.
|
||||
*/
|
||||
@NamedQueries(
|
||||
value = {
|
||||
@NamedQuery(name = "name", query = "select(name) order by name"),
|
||||
@NamedQuery(name = "withStatus", query = "select(name,status) order by name")
|
||||
}
|
||||
)
|
||||
@NamedQuery(name="withContacts", query = "fetch contacts (firstName, lastName) where id = :id")
|
||||
@Cache(enableQueryCache = true)
|
||||
@DocStore
|
||||
@ChangeLog(inserts = ChangeLogInsertMode.EXCLUDE, updatesThatInclude = {"name", "status"})
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.avaje.tests.query;
|
||||
|
||||
|
||||
import com.avaje.ebean.RawSql;
|
||||
import com.avaje.ebean.RawSqlBuilder;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.Query;
|
||||
import com.avaje.ebean.RawSql;
|
||||
import com.avaje.ebean.RawSqlBuilder;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestIContains extends BaseTestCase {
|
||||
|
||||
@@ -25,15 +25,15 @@ public class TestIContains extends BaseTestCase {
|
||||
query.findList();
|
||||
String generatedSql = query.getGeneratedSql();
|
||||
|
||||
Assert.assertTrue(generatedSql.contains("lower(t0.name)"));
|
||||
assertThat(generatedSql).contains("lower(t0.name)");
|
||||
|
||||
// not case insensitive
|
||||
// case sensitive
|
||||
query = Ebean.find(Customer.class).where().contains("name", "Rob").query();
|
||||
|
||||
query.findList();
|
||||
generatedSql = query.getGeneratedSql();
|
||||
|
||||
Assert.assertTrue(generatedSql.contains(" t0.name "));
|
||||
assertThat(generatedSql).contains(" t0.name ");
|
||||
|
||||
Ebean.find(Customer.class).where().icontains("name", "Rob").findList();
|
||||
Ebean.find(Customer.class).where().icontains("name", "Rob").findList();
|
||||
|
||||
@@ -15,6 +15,8 @@ import com.avaje.tests.model.basic.Order;
|
||||
import com.avaje.tests.model.basic.OrderDetail;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestManyLazyLoadingQuery extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
@@ -55,6 +57,7 @@ public class TestManyLazyLoadingQuery extends BaseTestCase {
|
||||
beanProperty.addWhereParentIdIn(query0, parentIds, false);
|
||||
|
||||
query0.findList();
|
||||
assertThat(query0.getGeneratedSql()).contains(" from o_order_detail t0 where (t0.order_id) in (");
|
||||
|
||||
} finally {
|
||||
Ebean.endTransaction();
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package com.avaje.tests.rawsql;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.Query;
|
||||
@@ -12,6 +7,11 @@ import com.avaje.ebean.RawSql;
|
||||
import com.avaje.ebean.RawSqlBuilder;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class TestRawSqlPositionedParams extends BaseTestCase {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class TestRawSqlPositionedParams extends BaseTestCase {
|
||||
|
||||
RawSql rawSql = RawSqlBuilder
|
||||
.parse("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?")
|
||||
.columnMapping("r.id", "id").columnMapping("r.name", "name").create();
|
||||
.create();
|
||||
|
||||
Query<Customer> query = Ebean.find(Customer.class);
|
||||
query.setRawSql(rawSql);
|
||||
@@ -32,7 +32,7 @@ public class TestRawSqlPositionedParams extends BaseTestCase {
|
||||
|
||||
List<Customer> list = query.findList();
|
||||
|
||||
Assert.assertNotNull(list);
|
||||
assertNotNull(list);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -52,6 +52,6 @@ public class TestRawSqlPositionedParams extends BaseTestCase {
|
||||
|
||||
List<Customer> list = query.findList();
|
||||
|
||||
Assert.assertNotNull(list);
|
||||
assertNotNull(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,17 @@ public class TestOrderByParse extends BaseTestCase {
|
||||
assertTrue(o1.toStringFormat().equals("id desc nulls high"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void add_parse() {
|
||||
|
||||
OrderBy<Object> o1 = new OrderBy<Object>();
|
||||
o1.add("id desc nulls high");
|
||||
assertTrue(o1.getProperties().size() == 1);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(!o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.toStringFormat().equals("id desc nulls high"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseNullsHigh_with_second() {
|
||||
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
grammar EQL;
|
||||
|
||||
select_statement
|
||||
: select_clause? fetch_clause* where_clause? orderby_clause? limit_clause?
|
||||
;
|
||||
|
||||
select_clause
|
||||
: 'select' distinct? '(' fetch_property_group ')'
|
||||
;
|
||||
|
||||
distinct
|
||||
: 'distinct'
|
||||
;
|
||||
|
||||
fetch_clause
|
||||
: fetch_path
|
||||
;
|
||||
|
||||
where_clause
|
||||
: 'where' conditional_expression
|
||||
;
|
||||
|
||||
orderby_clause
|
||||
: 'order' 'by' orderby_property (',' orderby_property)*
|
||||
;
|
||||
|
||||
orderby_property
|
||||
: PATH_VARIABLE asc_desc? nulls_firstlast?
|
||||
;
|
||||
|
||||
nulls_firstlast
|
||||
: 'nulls' 'first'
|
||||
| 'nulls' 'last'
|
||||
;
|
||||
|
||||
asc_desc
|
||||
: 'asc'
|
||||
| 'desc'
|
||||
;
|
||||
|
||||
limit_clause
|
||||
: 'limit' NUMBER_LITERAL offset_clause?
|
||||
;
|
||||
|
||||
offset_clause
|
||||
: 'offset' NUMBER_LITERAL
|
||||
;
|
||||
|
||||
fetch_path
|
||||
: 'fetch' fetch_option? PATH_VARIABLE fetch_property_set?
|
||||
;
|
||||
|
||||
fetch_property_set
|
||||
: '(' fetch_property_group ')'
|
||||
;
|
||||
|
||||
fetch_property_group
|
||||
: fetch_property (',' fetch_property)*
|
||||
;
|
||||
|
||||
fetch_property
|
||||
: PATH_VARIABLE
|
||||
| fetch_query_hint
|
||||
| fetch_lazy_hint
|
||||
;
|
||||
|
||||
fetch_query_hint
|
||||
: '+' fetch_query_option
|
||||
;
|
||||
|
||||
fetch_lazy_hint
|
||||
: '+' fetch_lazy_option
|
||||
;
|
||||
|
||||
fetch_option
|
||||
: fetch_query_option
|
||||
| fetch_lazy_option
|
||||
;
|
||||
|
||||
fetch_query_option
|
||||
: 'query' fetch_batch_size?
|
||||
;
|
||||
|
||||
fetch_lazy_option
|
||||
: 'lazy' fetch_batch_size?
|
||||
;
|
||||
|
||||
fetch_batch_size
|
||||
: '(' NUMBER_LITERAL ')'
|
||||
;
|
||||
|
||||
conditional_expression
|
||||
: conditional_term ('or' conditional_term)*
|
||||
;
|
||||
|
||||
conditional_term
|
||||
: conditional_factor ('and' conditional_factor)*
|
||||
;
|
||||
|
||||
conditional_factor
|
||||
: 'not'? conditional_primary
|
||||
;
|
||||
|
||||
conditional_primary
|
||||
: any_expression
|
||||
| '(' conditional_expression ')'
|
||||
;
|
||||
|
||||
any_expression
|
||||
: comparison_expression
|
||||
| like_expression
|
||||
| between_expression
|
||||
| propertyBetween_expression
|
||||
| in_expression
|
||||
| isNull_expression
|
||||
| isNotNull_expression
|
||||
| isEmpty_expression
|
||||
| isNotEmpty_expression
|
||||
| '(' any_expression ')'
|
||||
;
|
||||
|
||||
in_expression
|
||||
: PATH_VARIABLE 'in' in_value
|
||||
;
|
||||
|
||||
in_value
|
||||
: INPUT_VARIABLE
|
||||
| '(' value_expression (',' value_expression)* ')'
|
||||
;
|
||||
|
||||
between_expression
|
||||
: PATH_VARIABLE 'between' value_expression 'and' value_expression
|
||||
;
|
||||
|
||||
propertyBetween_expression
|
||||
: value_expression 'between' PATH_VARIABLE 'and' PATH_VARIABLE
|
||||
;
|
||||
|
||||
isNull_expression
|
||||
: PATH_VARIABLE 'is' 'null'
|
||||
| PATH_VARIABLE 'isNull'
|
||||
;
|
||||
|
||||
isNotNull_expression
|
||||
: PATH_VARIABLE 'is' 'not' 'null'
|
||||
| PATH_VARIABLE 'isNotNull'
|
||||
| PATH_VARIABLE 'notNull'
|
||||
;
|
||||
|
||||
isEmpty_expression
|
||||
: PATH_VARIABLE 'is' 'empty'
|
||||
| PATH_VARIABLE 'isEmpty'
|
||||
;
|
||||
|
||||
isNotEmpty_expression
|
||||
: PATH_VARIABLE 'is' 'not' 'empty'
|
||||
| PATH_VARIABLE 'isNotEmpty'
|
||||
| PATH_VARIABLE 'notEmpty'
|
||||
;
|
||||
|
||||
like_expression
|
||||
: PATH_VARIABLE like_op value_expression
|
||||
;
|
||||
|
||||
like_op
|
||||
: 'like' | 'ilike'
|
||||
| 'contains' | 'icontains'
|
||||
| 'startsWith' | 'istartsWith'
|
||||
| 'endsWith' | 'iendsWith'
|
||||
;
|
||||
|
||||
comparison_expression
|
||||
: PATH_VARIABLE comparison_operator value_expression
|
||||
;
|
||||
|
||||
comparison_operator
|
||||
: '=' | 'eq'
|
||||
| '>' | 'gt'
|
||||
| '>=' | 'ge' | 'gte'
|
||||
| '<' | 'lt'
|
||||
| '<=' | 'le' | 'lte'
|
||||
| '<>' | '!=' | 'ne'
|
||||
| 'ieq'
|
||||
;
|
||||
|
||||
value_expression
|
||||
: literal
|
||||
| INPUT_VARIABLE
|
||||
;
|
||||
|
||||
literal
|
||||
: STRING_LITERAL
|
||||
| BOOLEAN_LITERAL
|
||||
| NUMBER_LITERAL
|
||||
;
|
||||
|
||||
|
||||
INPUT_VARIABLE
|
||||
: ':' ('a' .. 'z' | 'A' .. 'Z' | '_') ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_')*
|
||||
;
|
||||
|
||||
PATH_VARIABLE
|
||||
: ('a' .. 'z' | 'A' .. 'Z' | '_') ('a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' | '.')*
|
||||
;
|
||||
|
||||
BOOLEAN_LITERAL
|
||||
: 'true'
|
||||
| 'false'
|
||||
;
|
||||
|
||||
NUMBER_LITERAL
|
||||
: '-'? DOUBLE
|
||||
| '-'? INT
|
||||
| ZERO
|
||||
;
|
||||
|
||||
DOUBLE
|
||||
: [0-9]+ '.' [0-9]*;
|
||||
|
||||
INT
|
||||
: [1-9] [0-9]*;
|
||||
|
||||
ZERO : '0';
|
||||
|
||||
STRING_LITERAL
|
||||
: '\'' ( ~'\'' | '\'\'' )* '\''
|
||||
;
|
||||
|
||||
WS
|
||||
: [ \t\r\n] -> skip
|
||||
;
|
||||
@@ -46,4 +46,14 @@
|
||||
</raw-sql>
|
||||
</entity>
|
||||
|
||||
<entity class="com.avaje.tests.model.basic.Customer">
|
||||
<named-query name="withContactsById">
|
||||
<query>
|
||||
select (name, version)
|
||||
fetch contacts (firstName, lastName, email)
|
||||
where id = :id
|
||||
</query>
|
||||
</named-query>
|
||||
</entity>
|
||||
|
||||
</ebean>
|
||||
|
||||
@@ -76,10 +76,10 @@
|
||||
<logger name="com.avaje.ebean" level="INFO"/>
|
||||
<logger name="org.avaje.ebean" level="INFO"/>
|
||||
|
||||
<!--<logger name="org.avaje.ebean.SQL" level="TRACE"/>-->
|
||||
<!--<logger name="org.avaje.ebean.TXN" level="TRACE"/>-->
|
||||
<!--<logger name="org.avaje.ebean.SUM" level="TRACE"/>-->
|
||||
<!--<logger name="org.avaje.ebean.ELA" level="TRACE"/>-->
|
||||
<logger name="org.avaje.ebean.SQL" level="TRACE"/>
|
||||
<logger name="org.avaje.ebean.TXN" level="TRACE"/>
|
||||
<logger name="org.avaje.ebean.SUM" level="TRACE"/>
|
||||
<logger name="org.avaje.ebean.ELA" level="TRACE"/>
|
||||
|
||||
<!--<logger name="org.avaje.ebean.cache.QUERY" level="TRACE"/>-->
|
||||
<!--<logger name="org.avaje.ebean.cache.BEAN" level="TRACE"/>-->
|
||||
|
||||
Reference in New Issue
Block a user