Compare commits

..
Author SHA1 Message Date
rob bygrave 08d241d946 #1966 Remove sequence batching - postgres opps 2020-03-05 00:34:05 +13:00
rob bygrave 1c24ebf6dc Remove Sequence batching in favour of JPA increment 50
Also remove h2sqldb in favour of always using H2
2020-03-05 00:22:20 +13:00
3627 changed files with 41588 additions and 33282 deletions
+1 -8
View File
@@ -7,11 +7,4 @@ do
echo ${file}
cat ${file}
echo
done
for file in ebean-autotune/target/surefire-reports/*.txt
do
echo ${file}
cat ${file}
echo
done
done
-140
View File
@@ -1,140 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.5.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ebean-api</artifactId>
<properties>
<jackson-core.version>2.10.0</jackson-core.version>
<jackson-databind.version>2.10.0</jackson-databind.version>
</properties>
<dependencies>
<!--
Projects are expected to explicit depend on version
of slf4j that they want to use
-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-config</artifactId>
<version>1.0</version>
</dependency>
<!--
Class retention Nonnull and Nullable annotations
to assist with IDE auto-completion with Ebean API
-->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsr305</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>persistence-api</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-annotation</artifactId>
<version>6.13</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-types</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource</artifactId>
<version>5.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration</artifactId>
<version>12.1.4</version>
</dependency>
<!-- Jackson core used internally by Ebean -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-core.version}</version>
</dependency>
<!-- provided scope for JsonNode support -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind.version}</version>
<optional>true</optional>
</dependency>
<!-- Provided scope so that the H2HistoryTrigger can live in Ebean core
and not require a separate module for it -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.199</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
<optional>true</optional>
</dependency>
<!-- provided scope to read validation annotations Size etc -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -1,140 +0,0 @@
package io.ebean;
import io.ebean.config.BeanNotEnhancedException;
import io.ebean.datasource.DataSourceConfigurationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.persistence.PersistenceException;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
/**
* Holds Database instances.
*/
final class DbContext {
private static final Logger logger = LoggerFactory.getLogger(DbContext.class);
static {
EbeanVersion.getVersion();
}
private static final DbContext INSTANCE = new DbContext();
/**
* Cache for fast concurrent read access.
*/
private final ConcurrentHashMap<String, Database> concMap = new ConcurrentHashMap<>();
/**
* Cache for synchronized read, creation and put. Protected by the monitor object.
*/
private final HashMap<String, Database> syncMap = new HashMap<>();
private final Object monitor = new Object();
/**
* The 'default' Database.
*/
private Database defaultDatabase;
private DbContext() {
try {
if (!DbPrimary.isSkip()) {
// look to see if there is a default server defined
String defaultName = DbPrimary.getDefaultServerName();
logger.debug("defaultName:{}", defaultName);
if (defaultName != null && !defaultName.trim().isEmpty()) {
defaultDatabase = getWithCreate(defaultName.trim());
}
}
} catch (BeanNotEnhancedException e) {
throw e;
} catch (DataSourceConfigurationException e) {
String msg = "Configuration error creating DataSource for the default Database." +
" This typically means a missing application-test.yaml or missing ebean-test dependency." +
" See https://ebean.io/docs/trouble-shooting#datasource";
throw new DataSourceConfigurationException(msg, e);
} catch (Throwable e) {
logger.error("Error trying to create the default Database", e);
throw new RuntimeException(e);
}
}
/**
* Return the shared singleton instance.
*/
static DbContext getInstance() {
return INSTANCE;
}
/**
* Return the default database.
*/
Database getDefault() {
if (defaultDatabase == null) {
String msg = "The default Database has not been defined?";
msg += " This is normally set via the ebean.datasource.default property.";
msg += " Otherwise it should be registered programmatically via registerServer()";
throw new PersistenceException(msg);
}
return defaultDatabase;
}
/**
* Return the database by name.
*/
Database get(String name) {
if (name == null || name.isEmpty()) {
return defaultDatabase;
}
// non-synchronized read
Database server = concMap.get(name);
if (server != null) {
return server;
}
// synchronized read, create and put
return getWithCreate(name);
}
/**
* Synchronized read, create and put of Databases.
*/
private Database getWithCreate(String name) {
synchronized (monitor) {
Database server = syncMap.get(name);
if (server == null) {
// register when creating server this way
server = EbeanServerFactory.create(name);
register(server, false);
}
return server;
}
}
/**
* Register a server so we can get it by its name.
*/
void register(Database server, boolean isDefault) {
registerWithName(server.getName(), server, isDefault);
}
private void registerWithName(String name, Database server, boolean isDefault) {
synchronized (monitor) {
concMap.put(name, server);
syncMap.put(name, server);
if (isDefault) {
defaultDatabase = server;
}
}
}
Database mock(String name, Database server, boolean defaultServer) {
Database originalPrimaryServer = this.defaultDatabase;
registerWithName(name, server, defaultServer);
return originalPrimaryServer;
}
}
@@ -1,77 +0,0 @@
package io.ebean;
import io.ebean.config.ContainerConfig;
import io.ebean.config.ServerConfig;
import io.ebean.service.SpiContainer;
import io.ebean.service.SpiContainerFactory;
import javax.persistence.PersistenceException;
import java.util.Iterator;
import java.util.Properties;
import java.util.ServiceLoader;
/**
* Deprecated - please migrate to DatabaseFactory.
* <p>
* Creates EbeanServer instances.
* <p>
* This uses either a ServerConfig or properties in the ebean.properties file to
* configure and create a EbeanServer instance.
* </p>
* <p>
* The EbeanServer instance can either be registered with the Ebean singleton or
* not. The Ebean singleton effectively holds a map of EbeanServers by a name.
* If the EbeanServer is registered with the Ebean singleton you can retrieve it
* later via {@link Ebean#getServer(String)}.
* </p>
* <p>
* One EbeanServer can be nominated as the 'default/primary' EbeanServer. Many
* methods on the Ebean singleton such as {@link Ebean#find(Class)} are just a
* convenient way of using the 'default/primary' EbeanServer.
* </p>
*/
@Deprecated
public class EbeanServerFactory {
/**
* Initialise the container with clustering configuration.
* <p>
* Call this prior to creating any EbeanServer instances or alternatively set the
* ContainerConfig on the ServerConfig when creating the first EbeanServer instance.
*/
public static synchronized void initialiseContainer(ContainerConfig containerConfig) {
DatabaseFactory.initialiseContainer(containerConfig);
}
/**
* Create using ebean.properties to configure the database.
*/
public static synchronized EbeanServer create(String name) {
return (EbeanServer)DatabaseFactory.create(name);
}
/**
* Create using the ServerConfig object to configure the database.
*/
public static synchronized EbeanServer create(ServerConfig config) {
return (EbeanServer)DatabaseFactory.create(config);
}
/**
* Create using the ServerConfig additionally specifying a classLoader to use as the context class loader.
*/
public static synchronized EbeanServer createWithContextClassLoader(ServerConfig config, ClassLoader classLoader) {
return (EbeanServer)DatabaseFactory.createWithContextClassLoader(config, classLoader);
}
/**
* Shutdown gracefully all EbeanServers cleaning up any resources as required.
* <p>
* This is typically invoked via JVM shutdown hook and not explicitly called.
* </p>
*/
public static synchronized void shutdown() {
DatabaseFactory.shutdown();
}
}
@@ -1,18 +0,0 @@
package io.ebean.config;
/**
* Used to provide some automatic configuration early in the creation of a Database.
*/
public interface AutoConfigure {
/**
* Perform configuration for the DatabaseConfig prior to properties load.
*/
void preConfigure(DatabaseConfig config);
/**
* Provide some configuration the DatabaseConfig prior to server creation but after properties have been applied.
*/
void postConfigure(DatabaseConfig config);
}
@@ -1,39 +0,0 @@
package io.ebean.config;
/**
* Provides a ServiceLoader based mechanism to configure a DatabaseConfig.
* <p>
* Provide an implementation and register it via the standard Java ServiceLoader mechanism
* via a file at <code>META-INF/services/io.ebean.config.DatabaseConfigProvider</code>.
* </p>
* <p>
* If you are using a DI container like Spring or Guice you are unlikely to use this but instead use a
* spring specific configuration. When we are not using a DI container we may use this mechanism to
* explicitly register the entity beans and avoid classpath scanning.
* </p>
* <pre>{@code
*
* public class EbeanConfigProvider implements DatabaseConfigProvider {
*
* Override
* public void apply(DatabaseConfig config) {
*
* // register the entity bean classes explicitly
* config.addClass(Customer.class);
* config.addClass(User.class);
* ...
* }
* }
*
* }</pre>
*/
public interface DatabaseConfigProvider {
/**
* Apply the configuration to the DatabaseConfig.
* <p>
* Typically we explicitly register entity bean classes and thus avoid classpath scanning.
* </p>
*/
void apply(DatabaseConfig config);
}
@@ -1,88 +0,0 @@
package io.ebean.config;
import com.fasterxml.jackson.core.JsonFactory;
import io.avaje.config.Config;
import io.ebean.DatabaseFactory;
import io.ebean.PersistenceContextScope;
import io.ebean.Query;
import io.ebean.Transaction;
import io.ebean.annotation.Encrypted;
import io.ebean.annotation.PersistBatch;
import io.ebean.annotation.Platform;
import io.ebean.cache.ServerCachePlugin;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.config.dbplatform.DbEncrypt;
import io.ebean.config.dbplatform.DbType;
import io.ebean.config.dbplatform.IdType;
import io.ebean.datasource.DataSourceConfig;
import io.ebean.event.BeanFindController;
import io.ebean.event.BeanPersistController;
import io.ebean.event.BeanPersistListener;
import io.ebean.event.BeanPostConstructListener;
import io.ebean.event.BeanPostLoad;
import io.ebean.event.BeanQueryAdapter;
import io.ebean.event.BulkTableEventListener;
import io.ebean.event.ServerConfigStartup;
import io.ebean.event.changelog.ChangeLogListener;
import io.ebean.event.changelog.ChangeLogPrepare;
import io.ebean.event.changelog.ChangeLogRegister;
import io.ebean.event.readaudit.ReadAuditLogger;
import io.ebean.event.readaudit.ReadAuditPrepare;
import io.ebean.migration.MigrationRunner;
import io.ebean.util.StringHelper;
import javax.persistence.EnumType;
import javax.sql.DataSource;
import java.time.Clock;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.ServiceLoader;
/**
* Deprecated - please migrate to <code>io.ebean.DatabaseConfig</code>.
*
* The configuration used for creating a Database.
* <p>
* Used to programmatically construct a Database and optionally register it
* with the DB singleton.
* </p>
* <p>
* If you just use DB without this programmatic configuration DB will read
* the application.properties file and take the configuration from there. This usually
* includes searching the class path and automatically registering any entity
* classes and listeners etc.
* </p>
* <pre>{@code
*
* ServerConfig config = new ServerConfig();
*
* // read the ebean.properties and load
* // those settings into this serverConfig object
* config.loadFromProperties();
*
* // explicitly register the entity beans to avoid classpath scanning
* config.addClass(Customer.class);
* config.addClass(User.class);
*
* Database database = DatabaseFactory.create(config);
*
* }</pre>
*
* <p>
* Note that ServerConfigProvider provides a standard Java ServiceLoader mechanism that can
* be used to apply configuration to the ServerConfig.
* </p>
*
* @author emcgreal
* @author rbygrave
* @see DatabaseFactory
*/
@Deprecated
public class ServerConfig extends DatabaseConfig {
}
@@ -1,57 +0,0 @@
package io.ebean.config.dbplatform;
import io.ebean.BackgroundExecutor;
import javax.sql.DataSource;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* Database sequence based IdGenerator using Sequence Step 1 but batch fetch many sequence values.
*/
public abstract class SequenceBatchIdGenerator extends SequenceIdGenerator {
/**
* Construct where batchSize is the sequence step size.
*
*/
public SequenceBatchIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) {
super(be, ds, seqName, batchSize);
}
/**
* If allocateSize is large load some sequences in a background thread.
* <p>
* For example, when inserting a bean with a cascade on a OneToMany with many
* beans Ebean can call this to ensure .
* </p>
*/
@Override
public void preAllocateIds(int requestSize) {
if (allocationSize > 1 && requestSize > allocationSize) {
// only bother if allocateSize is bigger than
// the normal loading batchSize
if (requestSize > 100) {
// max out at 100 for now
requestSize = 100;
}
loadInBackground(requestSize);
}
}
/**
* Add the next set of Ids as the next value plus all the following numbers up to the step size.
*/
@Override
protected List<Long> readIds(ResultSet resultSet, int loadSize) throws SQLException {
List<Long> newIds = new ArrayList<>(loadSize);
while (resultSet.next()) {
newIds.add(resultSet.getLong(1));
}
return newIds;
}
}
@@ -1,35 +0,0 @@
package io.ebean.config.dbplatform.db2;
import io.ebean.BackgroundExecutor;
import io.ebean.config.dbplatform.SequenceBatchIdGenerator;
import javax.sql.DataSource;
/**
* DB2 specific sequence Id Generator.
*/
public class DB2SequenceIdGenerator extends SequenceBatchIdGenerator {
private final String baseSql;
private final String unionBaseSql;
/**
* Construct given a dataSource and sql to return the next sequence value.
*/
public DB2SequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) {
super(be, ds, seqName, batchSize);
this.baseSql = "values nextval for " + seqName;
this.unionBaseSql = " union " + baseSql;
}
@Override
public String getSql(int batchSize) {
StringBuilder sb = new StringBuilder();
sb.append(baseSql);
for (int i = 1; i < batchSize; i++) {
sb.append(unionBaseSql);
}
return sb.toString();
}
}
@@ -1,35 +0,0 @@
package io.ebean.config.dbplatform.h2;
import io.ebean.BackgroundExecutor;
import io.ebean.config.dbplatform.SequenceBatchIdGenerator;
import javax.sql.DataSource;
/**
* H2 specific sequence Id Generator.
*/
public class H2SequenceIdGenerator extends SequenceBatchIdGenerator {
private final String baseSql;
private final String unionBaseSql;
/**
* Construct given a dataSource and sql to return the next sequence value.
*/
public H2SequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) {
super(be, ds, seqName, batchSize);
this.baseSql = "select " + seqName + ".nextval";
this.unionBaseSql = " union " + baseSql;
}
@Override
public String getSql(int batchSize) {
StringBuilder sb = new StringBuilder();
sb.append(baseSql);
for (int i = 1; i < batchSize; i++) {
sb.append(unionBaseSql);
}
return sb.toString();
}
}
@@ -1,38 +0,0 @@
package io.ebean.config.dbplatform.hsqldb;
import io.ebean.BackgroundExecutor;
import io.ebean.annotation.Platform;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.config.dbplatform.DbPlatformType;
import io.ebean.config.dbplatform.DbType;
import io.ebean.config.dbplatform.IdType;
import io.ebean.config.dbplatform.PlatformIdGenerator;
import io.ebean.config.dbplatform.h2.H2DbEncrypt;
import io.ebean.config.dbplatform.h2.H2SequenceIdGenerator;
import javax.sql.DataSource;
/**
* H2 specific platform.
*/
public class HsqldbPlatform extends DatabasePlatform {
public HsqldbPlatform() {
super();
this.platform = Platform.HSQLDB;
this.dbEncrypt = new H2DbEncrypt();
this.truncateTable = "delete from %s";
this.dbIdentity.setIdType(IdType.IDENTITY);
this.dbIdentity.setSupportsGetGeneratedKeys(true);
this.dbIdentity.setSupportsSequence(true);
this.dbIdentity.setSupportsIdentity(true);
dbTypeMap.put(DbType.INTEGER, new DbPlatformType("integer", false));
}
@Override
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) {
return new H2SequenceIdGenerator(be, ds, seqName, sequenceBatchSize);
}
}
@@ -1,4 +0,0 @@
/**
* Hsqldb specific support.
*/
package io.ebean.config.dbplatform.hsqldb;
@@ -1,38 +0,0 @@
package io.ebean.config.dbplatform.mariadb;
import io.ebean.config.dbplatform.DbStandardHistorySupport;
/**
* History support for MariaDB.
*/
public class MariaDbHistorySupport extends DbStandardHistorySupport {
/**
* Return the ' as of timestamp ?' clause appended after the table name.
*/
@Override
public String getAsOfViewSuffix(String asOfViewSuffix) {
return " for system_time as of ?";
}
@Override
public String getVersionsBetweenSuffix(String asOfViewSuffix) {
return " for system_time between ? and ?";
}
/**
* Returns the SQL Server specific effective start column.
*/
@Override
public String getSysPeriodLower(String tableAlias, String sysPeriod) {
return tableAlias + ".row_start";
}
/**
* Returns the SQL Server specific effective end column.
*/
@Override
public String getSysPeriodUpper(String tableAlias, String sysPeriod) {
return tableAlias + ".row_end";
}
}
@@ -1,16 +0,0 @@
package io.ebean.config.dbplatform.mariadb;
import io.ebean.annotation.Platform;
import io.ebean.config.dbplatform.mysql.BaseMySqlPlatform;
/**
* MariaDB platform.
*/
public class MariaDbPlatform extends BaseMySqlPlatform {
public MariaDbPlatform() {
super();
this.platform = Platform.MARIADB;
this.historySupport = new MariaDbHistorySupport();
}
}
@@ -1,15 +0,0 @@
package io.ebean.config.dbplatform.mysql;
import io.ebean.annotation.Platform;
/**
* MySQL specific platform.
*/
public class MySqlPlatform extends BaseMySqlPlatform {
public MySqlPlatform() {
super();
this.platform = Platform.MYSQL;
}
}
@@ -1,24 +0,0 @@
package io.ebean.config.dbplatform.nuodb;
import io.ebean.BackgroundExecutor;
import io.ebean.config.dbplatform.SequenceStepIdGenerator;
import javax.sql.DataSource;
public class NuoDbSequence extends SequenceStepIdGenerator {
private final String nextSql;
/**
* Construct where batchSize is the sequence step size.
*/
public NuoDbSequence(BackgroundExecutor be, DataSource ds, String seqName, int stepSize) {
super(be, ds, seqName, stepSize);
this.nextSql = "select next value for " + seqName + " from dual";
}
@Override
public String getSql(int batchSize) {
return nextSql;
}
}
@@ -1,27 +0,0 @@
package io.ebean.config.dbplatform.oracle;
import io.ebean.BackgroundExecutor;
import io.ebean.config.dbplatform.SequenceBatchIdGenerator;
import javax.sql.DataSource;
/**
* Oracle specific sequence Id Generator.
*/
public class OracleSequenceIdGenerator extends SequenceBatchIdGenerator {
private final String baseSql;
/**
* Construct given a dataSource and sql to return the next sequence value.
*/
public OracleSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) {
super(be, ds, seqName, batchSize);
this.baseSql = "select " + seqName + ".nextval, a from (select level as a FROM dual CONNECT BY level <= ";
}
@Override
public String getSql(int batchSize) {
return baseSql + batchSize + ")";
}
}
@@ -1,27 +0,0 @@
package io.ebean.config.dbplatform.postgres;
import io.ebean.BackgroundExecutor;
import io.ebean.config.dbplatform.SequenceBatchIdGenerator;
import javax.sql.DataSource;
/**
* Postgres specific sequence Id Generator.
*/
public class PostgresSequenceIdGenerator extends SequenceBatchIdGenerator {
private final String baseSql;
/**
* Construct given a dataSource and sql to return the next sequence value.
*/
public PostgresSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) {
super(be, ds, seqName, batchSize);
this.baseSql = "select nextval('" + seqName + "'), s.generate_series from (select generate_series from generate_series(1,";
}
@Override
public String getSql(int batchSize) {
return baseSql + batchSize + ") ) as s";
}
}
@@ -1,24 +0,0 @@
package io.ebean.config.dbplatform.sqlserver;
import io.ebean.BackgroundExecutor;
import io.ebean.config.dbplatform.SequenceStepIdGenerator;
import javax.sql.DataSource;
public class SqlServerStepSequence extends SequenceStepIdGenerator {
private final String nextSql;
/**
* Construct where batchSize is the sequence step size.
*/
public SqlServerStepSequence(BackgroundExecutor be, DataSource ds, String seqName, int stepSize) {
super(be, ds, seqName, stepSize);
this.nextSql = "select next value for "+seqName;
}
@Override
public String getSql(int batchSize) {
return nextSql;
}
}
@@ -1,7 +0,0 @@
package io.ebean.docstore;
/**
* Document Mapping for a bean marker interface.
*/
public interface DocMapping {
}
@@ -1,7 +0,0 @@
package io.ebean.docstore;
/**
* Document query request context marker interface.
*/
public interface DocQueryContext<T> {
}
@@ -1,7 +0,0 @@
package io.ebean.docstore;
/**
* Document update context marker interface.
*/
public interface DocUpdateContext {
}
@@ -1,98 +0,0 @@
package io.ebean.util;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
/**
* Annotation utility methods to find annotations.
*/
public class AnnotationUtil {
/**
* Determine if the supplied {@link Annotation} is defined in the core JDK {@code java.lang.annotation} package.
*/
public static boolean notJavaLang(Annotation annotation) {
return !annotation.annotationType().getName().startsWith("java.lang.annotation");
}
/**
* Simple get on field or method with no meta-annotations or platform filtering.
*/
public static <A extends Annotation> A get(AnnotatedElement element, Class<A> annotation) {
return element.getAnnotation(annotation);
}
/**
* Simple has with no meta-annotations or platform filtering.
*/
public static <A extends Annotation> boolean has(AnnotatedElement element, Class<A> annotation) {
return get(element, annotation) != null;
}
/**
* On class get the annotation - includes inheritance.
*/
public static <A extends Annotation> A typeGet(Class<?> clazz, Class<A> annotationType) {
while (clazz != null && clazz != Object.class) {
final A val = clazz.getAnnotation(annotationType);
if (val != null) {
return val;
}
clazz = clazz.getSuperclass();
}
return null;
}
/**
* On class get all the annotations - includes inheritance.
*/
public static <A extends Annotation> Set<A> typeGetAll(Class<?> clazz, Class<A> annotationType) {
Set<A> result = new LinkedHashSet<>();
typeGetAllCollect(clazz, annotationType, result);
return result;
}
private static <A extends Annotation> void typeGetAllCollect(Class<?> clazz, Class<A> annotationType, Set<A> result) {
while (clazz != null && clazz != Object.class) {
final A val = clazz.getAnnotation(annotationType);
if (val != null) {
result.add(val);
}
clazz = clazz.getSuperclass();
}
}
/**
* On class simple check for annotation - includes inheritance.
*/
public static <A extends Annotation> boolean typeHas(Class<?> clazz, Class<A> annotation) {
return typeGet(clazz, annotation) != null;
}
/**
* Find all the annotations for the filter searching meta-annotations.
*/
public static Set<Annotation> metaFindAllFor(AnnotatedElement element, Set<Class<?>> filter) {
Set<Annotation> visited = new HashSet<>();
Set<Annotation> result = new LinkedHashSet<>();
for (Annotation ann : element.getAnnotations()) {
metaAdd(ann, filter, visited, result);
}
return result;
}
private static void metaAdd(Annotation ann, Set<Class<?>> filter, Set<Annotation> visited, Set<Annotation> result) {
if (notJavaLang(ann) && visited.add(ann)) {
if (filter.contains(ann.annotationType())) {
result.add(ann);
} else {
for (Annotation metaAnn : ann.annotationType().getAnnotations()) {
metaAdd(metaAnn, filter, visited, result);
}
}
}
}
}
@@ -1,147 +0,0 @@
package io.ebean.util;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
/**
* Utility String class that supports String manipulation functions.
*/
public class StringHelper {
private static final Pattern SPLIT_NAMES = Pattern.compile("[\\s,;]+");
private static final String[] EMPTY_STRING_ARRAY = new String[0];
/**
* Return true if the value is null or an empty string.
*/
public static boolean isNull(String value) {
return value == null || value.trim().isEmpty();
}
/**
* Parses out a list of Name Value pairs that are delimited together. Will
* always return a StringMap. If allNameValuePairs is null, or no name values
* can be parsed out an empty StringMap is returned.
*
* @param source the entire string to be parsed.
* @param listDelimiter (typically ';') the delimited between the list
* @param nameValueSeparator (typically '=') the separator between the name and value
*/
public static Map<String, String> delimitedToMap(String source, String listDelimiter, String nameValueSeparator) {
Map<String, String> params = new HashMap<>();
if (source == null || source.isEmpty()) {
return params;
}
// trim off any leading listDelimiter...
source = trimFront(source, listDelimiter);
return delimitedToMap(params, source, listDelimiter, nameValueSeparator);
}
/**
* Trims off recurring strings from the front of a string.
*
* @param source the source string
* @param trim the string to trim off the front
*/
private static String trimFront(String source, String trim) {
while (true) {
if (source.indexOf(trim) == 0) {
source = source.substring(trim.length());
} else {
return source;
}
}
}
/**
* Recursively pulls out the key value pairs from a raw string.
*/
private static Map<String, String> delimitedToMap(Map<String, String> map, String source, String listDelimiter, String nameValueSeparator) {
int pos = 0;
while (true) {
if (pos >= source.length()) {
return map;
}
int equalsPos = source.indexOf(nameValueSeparator, pos);
int delimPos = source.indexOf(listDelimiter, pos);
if (delimPos == -1) {
delimPos = source.length();
}
if (equalsPos == -1) {
return map;
}
if (delimPos == (equalsPos + 1)) {
pos = delimPos + 1;
continue;
}
if (equalsPos > delimPos) {
// there is a key without a value?
String key = source.substring(pos, delimPos);
key = key.trim();
if (!key.isEmpty()) {
map.put(key, null);
}
pos = delimPos + 1;
continue;
}
String key = source.substring(pos, equalsPos);
String value = source.substring(equalsPos + 1, delimPos);
map.put(key.trim(), value);
pos = delimPos + 1;
}
}
/**
* This method takes a String and will replace all occurrences of the match
* String with that of the replace String.
*
* @param source the source string
* @param match the string used to find a match
* @param replace the string used to replace match with
* @return the source string after the search and replace
*/
public static String replace(String source, String match, String replace) {
if (source == null) {
return null;
}
if (replace == null) {
return source;
}
return source.replace(match, replace);
}
/**
* Return new line and carriage return with space.
*/
public static String removeNewLines(String source) {
source = source.replace('\n', ' ');
return source.replace('\r', ' ');
}
/**
* Splits at any whitespace "," or ";" and trims the result.
* It does not return empty entries.
*/
public static String[] splitNames(String names) {
if (names == null || names.isEmpty()) {
return EMPTY_STRING_ARRAY;
}
String[] result = SPLIT_NAMES.split(names);
if (result.length == 0) {
return EMPTY_STRING_ARRAY;
}
if ("".equals(result[0])) { // input string starts with whitespace
if (result.length == 1) { // input string contains only whitespace
return EMPTY_STRING_ARRAY;
} else {
String[] ret = new String[result.length-1]; // remove first entry
System.arraycopy(result, 1, ret, 0, ret.length);
return ret;
}
} else {
return result;
}
}
}
@@ -1,2 +0,0 @@
Manifest-Version: 1.0
Automatic-Module-Name: io.ebean.api
@@ -1,55 +0,0 @@
package io.ebean.config.dbplatform;
import org.junit.Test;
import java.sql.Types;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import static org.assertj.core.api.Assertions.assertThat;
public class DbDefaultValueTest {
@Test
public void toSqlLiteral_timestamp() {
assertThat(ts("2001-10-26T21:32:52")).isEqualTo("'2001-10-26T21:32:52'");
assertThat(ts("2001-10-26T21:32:52+02:00")).isEqualTo("'2001-10-26T21:32:52+02:00'");
assertThat(ts("2001-10-26T19:32:52Z")).isEqualTo("'2001-10-26T19:32:52Z'");
assertThat(ts("2001-10-26T19:32:52+00:00")).isEqualTo("'2001-10-26T19:32:52+00:00'");
assertThat(ts("-2001-10-26T21:32:52")).isEqualTo("'-2001-10-26T21:32:52'");
assertThat(ts("2001-10-26T21:32:52.12679")).isEqualTo("'2001-10-26T21:32:52.12679'");
}
private String ts(String input) {
return DbDefaultValue.toSqlLiteral(input, OffsetDateTime.class, Types.TIMESTAMP);
}
@Test
public void toSqlLiteral_date() {
assertThat(date("2001-10-26")).isEqualTo("'2001-10-26'");
assertThat(date("2001-10-26+02:00")).isEqualTo("'2001-10-26+02:00'");
assertThat(date("2001-10-26Z")).isEqualTo("'2001-10-26Z'");
assertThat(date("2001-10-26+00:00")).isEqualTo("'2001-10-26+00:00'");
assertThat(date("-2001-10-26")).isEqualTo("'-2001-10-26'");
assertThat(date("-20000-04-01")).isEqualTo("'-20000-04-01'");
}
private String date(String input) {
return DbDefaultValue.toSqlLiteral(input, LocalDate.class, Types.DATE);
}
@Test
public void toSqlLiteral_time() {
assertThat(time("21:32:52")).isEqualTo("'21:32:52'");
assertThat(time("21:32:52+02:00")).isEqualTo("'21:32:52+02:00'");
assertThat(time("19:32:52Z")).isEqualTo("'19:32:52Z'");
assertThat(time("19:32:52+00:00")).isEqualTo("'19:32:52+00:00'");
assertThat(time("21:32:52.12679")).isEqualTo("'21:32:52.12679'");
}
private String time(String input) {
return DbDefaultValue.toSqlLiteral(input, LocalTime.class, Types.TIME);
}
}
-65
View File
@@ -1,65 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.5.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ebean-autotune</artifactId>
<dependencies>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>${project.version}</version>
</dependency>
<!-- needed for java 11+ -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.avaje.composite</groupId>
<artifactId>junit</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.17</version>
<extensions>true</extensions>
<configuration>
<tiles>
<!-- other tiles ... -->
<tile>io.ebean.tile:enhancement:12.5.0</tile>
</tiles>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -1,15 +0,0 @@
package io.ebeaninternal.server.autotune.service;
import io.ebean.config.DatabaseConfig;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.server.autotune.AutoTuneService;
import io.ebeaninternal.server.autotune.AutoTuneServiceProvider;
public class AutoTuneServiceFactory implements AutoTuneServiceProvider {
@Override
public AutoTuneService create(SpiEbeanServer server, DatabaseConfig config) {
return new DefaultAutoTuneService(server, config);
}
}
@@ -1,2 +0,0 @@
Manifest-Version: 1.0
Automatic-Module-Name: io.ebean.autotune
@@ -1 +0,0 @@
io.ebeaninternal.server.autotune.service.AutoTuneServiceFactory
@@ -1,16 +0,0 @@
package org.tests.autofetch;
import io.ebean.DB;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.server.deploy.BeanDescriptor;
public class BaseTestCase {
protected SpiEbeanServer spiEbeanServer() {
return (SpiEbeanServer) DB.getDefault();
}
protected <T> BeanDescriptor<T> getBeanDescriptor(Class<T> cls) {
return spiEbeanServer().getBeanDescriptor(cls);
}
}
@@ -1,32 +0,0 @@
package org.tests.autofetch;
//import io.ebean.Ebean;
//import org.tests.model.basic.EBasicClob;
//import java.util.List;
public class MainAutoFetchExcludeLazyLobs {
// public static void main(String[] args) {
//
// EBasicClob a = new EBasicClob();
// a.setName("name 1");
// a.setTitle("a title");
// a.setDescription("not that meaningful");
//
// Ebean.save(a);
//
// List<EBasicClob> list = Ebean.find(EBasicClob.class)
// .setAutoTune(true)
// .findList();
//
// for (EBasicClob bean : list) {
// bean.getName();
// // although we read the description
// // autofetch will not include it later
// bean.getDescription();
// }
//
//
// }
}
@@ -1,28 +0,0 @@
package org.tests.autofetch;
public class MainAutoQueryTune1 {
// public static void main(String[] args) {
//
// ResetBasicData.reset();
//
// MainAutoQueryTune1 me = new MainAutoQueryTune1();
// me.tuneJoin();
// }
//
// private void tuneJoin() {
// List<Order> list = Ebean.find(Order.class)
// .setAutoTune(true)
// .fetch("customer")
// .where()
// .eq("status", Order.Status.NEW)
// .eq("customer.name", "Rob")
// .order().asc("id")
// .findList();
//
// for (Order order : list) {
// order.getId();
// order.getOrderDate();
// }
// }
}
@@ -1,172 +0,0 @@
package org.tests.autofetch;
//import io.ebean.BaseTestCase;
//import io.ebean.Ebean;
//import io.ebean.EbeanServer;
//import io.ebean.Query;
//import io.ebean.bean.EntityBean;
//import io.ebean.bean.EntityBeanIntercept;
//import io.ebean.cache.ServerCacheManager;
//import io.ebeaninternal.api.SpiQuery;
//import io.ebeaninternal.server.autotune.model.Origin;
//import io.ebeaninternal.server.autotune.service.TunedQueryInfo;
//import io.ebeaninternal.server.querydefn.OrmQueryDetail;
//import org.ebeantest.LoggedSqlCollector;
//import org.junit.Assert;
//import org.junit.Test;
//import org.tests.model.basic.Order;
//import org.tests.model.basic.ResetBasicData;
//
//import java.util.List;
//import java.util.Set;
public class TunedQueryInfoTest extends BaseTestCase {
// private void init() {
//
// ResetBasicData.reset();
//
// ServerCacheManager serverCacheManager = Ebean.getServer(null).getServerCacheManager();
// serverCacheManager.clearAll();
// }
//
// @Test
// public void withSelectEmpty() {
//
// init();
//
// OrmQueryDetail tunedDetail = new OrmQueryDetail();
// tunedDetail.select("");
//
// TunedQueryInfo tunedInfo = createTunedQueryInfo(tunedDetail);
//
// Query<Order> query = server.find(Order.class).setId(1);
//
// tunedInfo.tuneQuery((SpiQuery<?>) query);
//
// Order order = query.findOne();
// EntityBean eb = (EntityBean) order;
// EntityBeanIntercept ebi = eb._ebean_getIntercept();
//
// Assert.assertTrue(ebi.isFullyLoadedBean());
//
// Set<String> loadedPropertyNames = ebi.getLoadedPropertyNames();
// Assert.assertNull(loadedPropertyNames);
//
// // invoke lazy loading
// order.getCustomer();
// }
//
// @Test
// public void withSelectSomethingThatDoesNotExist() {
//
// init();
//
// OrmQueryDetail tunedDetail = new OrmQueryDetail();
// tunedDetail.select("somethingThatDoesNotExist");
//
// TunedQueryInfo tunedInfo = createTunedQueryInfo(tunedDetail);
//
// Query<Order> query = server.find(Order.class).setId(1);
//
// tunedInfo.tuneQuery((SpiQuery<?>) query);
//
// LoggedSqlCollector.start();
//
// Order order = query.findOne();
// EntityBean eb = (EntityBean) order;
// EntityBeanIntercept ebi = eb._ebean_getIntercept();
//
// Assert.assertFalse(ebi.isFullyLoadedBean());
//
// // id and any ToMany relationships
// Set<String> loadedPropertyNames = ebi.getLoadedPropertyNames();
// Assert.assertNotNull(loadedPropertyNames);
//
// // invoke lazy loading
// order.getCustomer();
//
// List<String> loggedSql = LoggedSqlCollector.stop();
// Assert.assertEquals(2, loggedSql.size());
//
// Assert.assertTrue(trimSql(loggedSql.get(0), 1).contains("select t0.id, t0.id from o_order t0 where t0.id = ?"));
// Assert.assertTrue(trimSql(loggedSql.get(1), 1).contains("select t0.id, t0.status,"));
// }
//
// private TunedQueryInfo createTunedQueryInfo(OrmQueryDetail tunedDetail) {
// Origin origin = new Origin();
// origin.setDetail(tunedDetail.asString());
// return new TunedQueryInfo(origin);
// }
//
// @Test
// public void withSelectSomeIncludeLazyLoaded() {
//
// init();
//
// OrmQueryDetail tunedDetail = new OrmQueryDetail();
// tunedDetail.select("status, customer");
//
// TunedQueryInfo tunedInfo = createTunedQueryInfo(tunedDetail);
//
// Query<Order> query = server.find(Order.class).setId(1);
//
// tunedInfo.tuneQuery((SpiQuery<?>) query);
//
// LoggedSqlCollector.start();
//
// Order order = query.findOne();
// EntityBean eb = (EntityBean) order;
// EntityBeanIntercept ebi = eb._ebean_getIntercept();
//
// Assert.assertFalse(ebi.isFullyLoadedBean());
//
// Set<String> loadedPropertyNames = ebi.getLoadedPropertyNames();
// Assert.assertNotNull(loadedPropertyNames);
//
// Assert.assertTrue(loadedPropertyNames.contains("status"));
// Assert.assertTrue(loadedPropertyNames.contains("customer"));
//
// // no lazy loading expected here
// order.getCustomer();
//
// List<String> loggedSql = LoggedSqlCollector.stop();
// Assert.assertEquals(1, loggedSql.size());
// }
//
// @Test
// public void withSelectSome() {
//
// init();
//
// OrmQueryDetail tunedDetail = new OrmQueryDetail();
// tunedDetail.select("status");
//
// TunedQueryInfo tunedInfo = createTunedQueryInfo(tunedDetail);
//
// Query<Order> query = server.find(Order.class).setId(1);
//
// tunedInfo.tuneQuery((SpiQuery<?>) query);
//
// LoggedSqlCollector.start();
//
// Order order = query.findOne();
// EntityBean eb = (EntityBean) order;
// EntityBeanIntercept ebi = eb._ebean_getIntercept();
//
// Assert.assertFalse(ebi.isFullyLoadedBean());
//
// Set<String> loadedPropertyNames = ebi.getLoadedPropertyNames();
// Assert.assertNotNull(loadedPropertyNames);
//
// Assert.assertTrue(loadedPropertyNames.contains("status"));
// Assert.assertFalse(loadedPropertyNames.contains("customer"));
//
// // no lazy loading expected here
// order.getCustomer();
//
// List<String> loggedSql = LoggedSqlCollector.stop();
// Assert.assertEquals(2, loggedSql.size());
// }
}
@@ -1,69 +0,0 @@
package org.tests.autofetch;
//import io.ebean.BaseTestCase;
//import io.ebean.Ebean;
//import io.ebean.EbeanServer;
//import io.ebean.Query;
//import io.ebean.bean.EntityBean;
//import io.ebean.bean.EntityBeanIntercept;
//import org.ebeantest.LoggedSqlCollector;
//import org.junit.Assert;
//import org.junit.Test;
//import org.tests.model.basic.Address;
//import org.tests.model.basic.Customer;
//import org.tests.model.basic.ResetBasicData;
import java.util.List;
import java.util.Set;
public class TunedQueryWithNullFetchedBeanTest extends BaseTestCase {
// EbeanServer server = Ebean.getServer(null);
//
// @Test
// public void withFetchOfNullBeanJoin() {
//
// ResetBasicData.reset();
//
// Customer newCustomer = new Customer();
// newCustomer.setName("TestFetchBillingAddress");
// server.save(newCustomer);
//
// Query<Customer> query = server.find(Customer.class)
// .setId(newCustomer.getId())
// .fetch("billingAddress", "id");
//
// LoggedSqlCollector.start();
//
// Customer customer = query.findOne();
// EntityBean eb = (EntityBean) customer;
// EntityBeanIntercept ebi = eb._ebean_getIntercept();
//
// Assert.assertTrue(ebi.isFullyLoadedBean());
//
// // find the internal property index for "billingAddress"
// String[] propNames = eb._ebean_getPropertyNames();
// int pos = 0;
// for (int i = 0; i < propNames.length; i++) {
// if (propNames[i].equals("billingAddress")) {
// pos = i;
// }
// }
//
// // The billing address is loaded (but value null)
// Assert.assertTrue(ebi.isLoadedProperty(pos));
//
// Set<String> loadedPropertyNames = ebi.getLoadedPropertyNames();
// Assert.assertNull(loadedPropertyNames);
//
// // no lazy loading expected here, value is null
// Address billingAddress = customer.getBillingAddress();
// Assert.assertNull(billingAddress);
//
// // assert only one query executed
// List<String> loggedSql = LoggedSqlCollector.stop();
// Assert.assertEquals(1, loggedSql.size());
//
// Ebean.delete(newCustomer);
// }
}
@@ -1,38 +0,0 @@
package org.tests.model.basic;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "address")
public class Address extends BaseModel {
String line1;
String line2;
String city;
public String getLine1() {
return line1;
}
public void setLine1(String line1) {
this.line1 = line1;
}
public String getLine2() {
return line2;
}
public void setLine2(String line2) {
this.line2 = line2;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
}
@@ -1,58 +0,0 @@
package org.tests.model.basic;
import io.ebean.Model;
import io.ebean.annotation.WhenCreated;
import io.ebean.annotation.WhenModified;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import java.time.Instant;
@MappedSuperclass
public class BaseModel extends Model {
@Id
long id;
@WhenCreated
Instant whenCreated;
@WhenModified
Instant whenModified;
@Version
long version;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Instant getWhenCreated() {
return whenCreated;
}
public void setWhenCreated(Instant whenCreated) {
this.whenCreated = whenCreated;
}
public Instant getWhenModified() {
return whenModified;
}
public void setWhenModified(Instant whenModified) {
this.whenModified = whenModified;
}
public long getVersion() {
return version;
}
public void setVersion(long version) {
this.version = version;
}
}
@@ -1,41 +0,0 @@
package org.tests.model.basic;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "o_customer")
public class Customer extends BaseModel {
String name;
String note;
@ManyToOne
Address billingAddress;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
public Address getBillingAddress() {
return billingAddress;
}
public void setBillingAddress(Address billingAddress) {
this.billingAddress = billingAddress;
}
}
@@ -1,60 +0,0 @@
package org.tests.model.basic;
import io.ebean.Model;
import io.ebean.annotation.WhenModified;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import java.sql.Timestamp;
import java.time.LocalDate;
@Entity
@Table(name = "orders")
public class Order extends BaseModel {
public enum Status {
NEW,
APPROVED,
SHIPPED,
COMPLETE
}
@Enumerated(EnumType.STRING)
Status status = Status.NEW;
LocalDate orderDate;
@ManyToOne(cascade = CascadeType.PERSIST)
Customer customer;
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public LocalDate getOrderDate() {
return orderDate;
}
public void setOrderDate(LocalDate orderDate) {
this.orderDate = orderDate;
}
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
}
@@ -1,11 +0,0 @@
ebean.ddl.generate=true
ebean.ddl.run=true
datasource.default=h2
datasource.h2.username=sa
datasource.h2.password=
datasource.h2.url=jdbc:h2:mem:h2AutoTune
datasource.pg.username=sa
datasource.pg.password=
datasource.pg.url=jdbc:h2:mem:h2AutoTune
@@ -1,21 +0,0 @@
<configuration scan="true" scanPeriod="10 seconds">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>TRACE</level>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>
<logger name="io.ebean.docker" level="TRACE"/>
<!-- <logger name="io.ebean.DDL" level="DEBUG"/>-->
<!-- <logger name="io.ebean.SQL" level="TRACE"/>-->
<!-- <logger name="io.ebean.TXN" level="TRACE"/>-->
<!-- <logger name="io.ebean.SUM" level="TRACE"/>-->
</configuration>
-111
View File
@@ -1,111 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.5.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ebean-bom</artifactId>
<packaging>pom</packaging>
<properties>
<ebean-agent.version>12.5.0</ebean-agent.version>
<ebean-maven-plugin.version>12.5.0</ebean-maven-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- dependencies external to this ebean.git build -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-agent</artifactId>
<version>${ebean-agent.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-maven-plugin</artifactId>
<version>${ebean-maven-plugin.version}</version>
</dependency>
<!-- modules -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddlgen</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-xml</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-autotune</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>kotlin-querybean-generator</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
-349
View File
@@ -1,349 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.5.1-SNAPSHOT</version>
</parent>
<artifactId>ebean-core</artifactId>
<packaging>jar</packaging>
<name>ebean-core</name>
<url>http://ebean-orm.github.io/</url>
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>HEAD</tag>
</scm>
<properties>
<jackson-core.version>2.10.0</jackson-core.version>
<jackson-databind.version>2.10.0</jackson-databind.version>
</properties>
<profiles>
<profile>
<!-- Note: to use this profile, you need to download manually the db2jcc4 driver.
After that, install it into your local maven repository:
mvn install:install-file \
-Dfile=db2jcc4.jar \
-DgroupId=com.ibm.jdbc \
-DartifactId=db2jcc4 \
-Dversion=4.23.42 \
-Dpackaging=jar
-->
<id>db2</id>
<dependencies>
<dependency>
<groupId>com.ibm.jdbc</groupId>
<artifactId>db2jcc4</artifactId>
<version>4.23.42</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencies>
<!-- keep testing in core using ebean-ddlgen -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddlgen</artifactId>
<version>12.5.0</version>
<scope>test</scope>
</dependency>
<!-- test scope for supporting ebean-ddlgen -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.8-1</version>
</dependency>
<!--
Class retention Nonnull and Nullable annotations
to assist with IDE auto-completion with Ebean API
-->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsr305</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.ebean</groupId>-->
<!-- <artifactId>ebean-migration</artifactId>-->
<!-- <version>12.1.4</version>-->
<!-- </dependency>-->
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
<optional>true</optional>
</dependency>
<!-- validation annotations Size etc -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.7</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
<optional>true</optional>
</dependency>
<!-- Jackson core used internally by Ebean -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-core.version}</version>
</dependency>
<!-- provided scope for JsonNode support -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind.version}</version>
<optional>true</optional>
</dependency>
<!-- Provided scope for Postgres JSON/JSONB support -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.10</version>
<optional>true</optional>
</dependency>
<!-- Test scope -->
<dependency>
<groupId>com.nuodb.jdbc</groupId>
<artifactId>nuodb-jdbc</artifactId>
<version>20.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc10</artifactId>
<version>19.3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean.test</groupId>
<artifactId>ebean-test-docker</artifactId>
<version>3.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<!-- Provided scope so that the H2HistoryTrigger can live in Ebean core
and not require a separate module for it -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.199</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.15.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.2.2.jre8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.17</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sap.cloud.db.jdbc</groupId>
<artifactId>ngdbc</artifactId>
<version>2.3.48</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.avaje.composite</groupId>
<artifactId>junit</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>mod-uuid</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.ebean</groupId>
<artifactId>ebean-maven-plugin</artifactId>
<version>12.5.0</version>
<executions>
<execution>
<id>test</id>
<phase>process-test-classes</phase>
<configuration>
<transformArgs>debug=0</transformArgs>
</configuration>
<goals>
<goal>testEnhance</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<trimStackTrace>false</trimStackTrace>
<failIfNoTests>false</failIfNoTests>
<includes>
<include>**/Test*.java</include>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
</includes>
<systemProperties>
<property>
<!-- transfer datasource.default parameter -->
<name>datasource.default</name>
<value>${datasource.default}</value>
</property>
<property>
<!-- transfer dbClockDelta parameter -->
<name>dbClockDelta</name>
<value>${dbClockDelta}</value>
</property>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<doctitle>Ebean 12</doctitle>
<overview>src/main/java/io/ebean/overview.html</overview>
<excludePackageNames>io.ebeaninternal.*:io.ebeanservice:io.ebean.common:io.ebean.bean:io.ebean.service:io.ebean.metric:io.ebean.util:io.ebean.config.properties:io.ebean.config.dbplatform</excludePackageNames>
<linksource>true</linksource>
<overview>src/main/java/com/avaje/ebean/overview.html</overview>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -1,16 +0,0 @@
package io.ebeaninternal.api;
import io.ebean.bean.BeanCollection;
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
/**
* Controls the loading of ManyToOne and OneToOne relationships.
*/
public interface LoadBeanContext extends LoadSecondaryQuery {
/**
* Register a BeanCollection into the load context.
*/
void register(BeanPropertyAssocMany<?> many, BeanCollection<?> collection);
}
@@ -1,15 +0,0 @@
package io.ebeaninternal.api;
/**
* DDL generate and run for drop all/create all.
*/
public interface SpiDdlGenerator {
/**
* Generate and run the DDL for drop-all and create-all scripts.
* <p>
* Run based on on property settings for ebean.ddl.generate and ebean.ddl.run etc.
*/
void execute(boolean online);
}
@@ -1,13 +0,0 @@
package io.ebeaninternal.api;
/**
* Provides the DDL Generator for create-all/drop-all.
*/
public interface SpiDdlGeneratorProvider {
/**
* Provide the DDL generator.
*/
SpiDdlGenerator generator(SpiEbeanServer server);
}
@@ -1,9 +0,0 @@
package io.ebeaninternal.server.autotune;
import io.ebean.config.DatabaseConfig;
import io.ebeaninternal.api.SpiEbeanServer;
public interface AutoTuneServiceProvider {
AutoTuneService create(SpiEbeanServer server, DatabaseConfig config);
}
@@ -1,34 +0,0 @@
package io.ebeaninternal.server.autotune;
import io.ebeaninternal.api.SpiQuery;
/**
* Noop service when AutoTuneService is not available.
*/
public class NoAutoTuneService implements AutoTuneService {
@Override
public void startup() {
// do nothing
}
@Override
public boolean tuneQuery(SpiQuery<?> query) {
return false;
}
@Override
public void collectProfiling() {
// do nothing
}
@Override
public void reportProfiling() {
// do nothing
}
@Override
public void shutdown() {
// do nothing
}
}
@@ -1,54 +0,0 @@
package io.ebeaninternal.server.cache;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
/**
* Bean Id value plus discriminator type.
* <p>
* Put into L2 cache such that we know the type of a bean with inheritance.
*/
public class CachedBeanId implements Externalizable {
private String discValue;
private Object id;
public CachedBeanId(String discValue, Object id) {
this.discValue = discValue;
this.id = id;
}
/**
* Construct from serialisation.
*/
public CachedBeanId() {
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeUTF(discValue);
out.writeObject(id);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
discValue = in.readUTF();
id = in.readObject();
}
@Override
public String toString() {
return discValue + ":" + id;
}
public String getDiscValue() {
return discValue;
}
public Object getId() {
return id;
}
}
@@ -1,267 +0,0 @@
package io.ebeaninternal.server.core;
import io.ebean.config.ContainerConfig;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.DatabaseConfigProvider;
import io.ebean.config.ModuleInfoLoader;
import io.ebean.config.ServerConfig;
import io.ebean.config.ServerConfigProvider;
import io.ebean.config.TenantMode;
import io.ebean.config.UnderscoreNamingConvention;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.config.dbplatform.h2.H2Platform;
import io.ebean.service.SpiContainer;
import io.ebeaninternal.api.SpiBackgroundExecutor;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.DbOffline;
import io.ebeaninternal.server.cluster.ClusterManager;
import io.ebeaninternal.server.core.bootup.BootupClassPathSearch;
import io.ebeaninternal.server.core.bootup.BootupClasses;
import io.ebean.event.ShutdownManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.persistence.PersistenceException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.ServiceLoader;
/**
* Default Server side implementation of ServerFactory.
*/
public class DefaultContainer implements SpiContainer {
private static final Logger logger = LoggerFactory.getLogger("io.ebean.internal.DefaultContainer");
private final ClusterManager clusterManager;
public DefaultContainer(ContainerConfig containerConfig) {
this.clusterManager = new ClusterManager(containerConfig);
// register so that we can shutdown any Ebean wide
// resources such as clustering
ShutdownManager.registerContainer(this);
}
@Override
public void shutdown() {
clusterManager.shutdown();
ShutdownManager.shutdown();
}
/**
* Create the server reading configuration information from ebean.properties.
*/
@Override
public SpiEbeanServer createServer(String name) {
DatabaseConfig config = new DatabaseConfig();
config.setName(name);
config.loadFromProperties();
return createServer(config);
}
private SpiBackgroundExecutor createBackgroundExecutor(DatabaseConfig config) {
String namePrefix = "ebean-" + config.getName();
int schedulePoolSize = config.getBackgroundExecutorSchedulePoolSize();
int shutdownSecs = config.getBackgroundExecutorShutdownSecs();
return new DefaultBackgroundExecutor(schedulePoolSize, shutdownSecs, namePrefix);
}
/**
* Create the implementation from the configuration.
*/
@Override
public SpiEbeanServer createServer(DatabaseConfig config) {
synchronized (this) {
applyConfigServices(config);
setNamingConvention(config);
BootupClasses bootupClasses = getBootupClasses(config);
boolean online = true;
if (config.isDocStoreOnly()) {
config.setDatabasePlatform(new H2Platform());
} else {
TenantMode tenantMode = config.getTenantMode();
if (TenantMode.DB != tenantMode) {
setDataSource(config);
if (!tenantMode.isDynamicDataSource()) {
// check the autoCommit and Transaction Isolation
online = checkDataSource(config);
}
}
}
// determine database platform (Oracle etc)
setDatabasePlatform(config);
if (config.getDbEncrypt() != null) {
// use a configured DbEncrypt rather than the platform default
config.getDatabasePlatform().setDbEncrypt(config.getDbEncrypt());
}
// inform the NamingConvention of the associated DatabasePlatform
config.getNamingConvention().setDatabasePlatform(config.getDatabasePlatform());
// executor and l2 caching service setup early (used during server construction)
SpiBackgroundExecutor executor = createBackgroundExecutor(config);
InternalConfiguration c = new InternalConfiguration(online, clusterManager, executor, config, bootupClasses);
DefaultServer server = new DefaultServer(c, c.cacheManager());
// generate and run DDL if required
// if there are any other tasks requiring action in their plugins, do them as well
if (!DbOffline.isGenerateMigration()) {
startServer(online, server);
}
DbOffline.reset();
return server;
}
}
private void applyConfigServices(DatabaseConfig config) {
if (config.isDefaultServer()) {
boolean appliedConfig = false;
for (DatabaseConfigProvider configProvider : ServiceLoader.load(DatabaseConfigProvider.class)) {
configProvider.apply(config);
appliedConfig = true;
}
if (!appliedConfig && config instanceof ServerConfig) {
for (ServerConfigProvider configProvider : ServiceLoader.load(ServerConfigProvider.class)) {
configProvider.apply((ServerConfig)config);
}
}
if (config.isAutoLoadModuleInfo()) {
// auto register entity classes (default db)
for (ModuleInfoLoader loader : ServiceLoader.load(ModuleInfoLoader.class)) {
config.addAll(loader.entityClasses());
}
}
} else if (config.isAutoLoadModuleInfo()) {
// auto register entity classes (other named db)
for (ModuleInfoLoader loader : ServiceLoader.load(ModuleInfoLoader.class)) {
config.addAll(loader.entityClassesFor(config.getName()));
}
}
}
private void startServer(boolean online, DefaultServer server) {
server.executePlugins(online);
// initialise prior to registering with clusterManager
server.initialise();
if (online) {
if (clusterManager.isClustering()) {
clusterManager.registerServer(server);
}
}
// start any services after registering with clusterManager
server.start();
}
/**
* Get the entities, scalarTypes, Listeners etc combining the class registered
* ones with the already created instances.
*/
private BootupClasses getBootupClasses(DatabaseConfig config) {
BootupClasses bootup = getBootupClasses1(config);
bootup.addIdGenerators(config.getIdGenerators());
bootup.addPersistControllers(config.getPersistControllers());
bootup.addPostLoaders(config.getPostLoaders());
bootup.addPostConstructListeners(config.getPostConstructListeners());
bootup.addFindControllers(config.getFindControllers());
bootup.addPersistListeners(config.getPersistListeners());
bootup.addQueryAdapters(config.getQueryAdapters());
bootup.addServerConfigStartup(config.getServerConfigStartupListeners());
bootup.addChangeLogInstances(config);
bootup.runServerConfigStartup(config);
return bootup;
}
/**
* Get the class based entities, scalarTypes, Listeners etc.
*/
private BootupClasses getBootupClasses1(DatabaseConfig config) {
List<Class<?>> entityClasses = config.getClasses();
if (config.isDisableClasspathSearch() || (entityClasses != null && !entityClasses.isEmpty())) {
// use classes we explicitly added via configuration
return new BootupClasses(entityClasses);
}
return BootupClassPathSearch.search(config);
}
/**
* Set the naming convention to underscore if it has not already been set.
*/
private void setNamingConvention(DatabaseConfig config) {
if (config.getNamingConvention() == null) {
config.setNamingConvention(new UnderscoreNamingConvention());
}
}
/**
* Set the DatabasePlatform if it has not already been set.
*/
private void setDatabasePlatform(DatabaseConfig config) {
DatabasePlatform platform = config.getDatabasePlatform();
if (platform == null) {
if (config.getTenantMode().isDynamicDataSource()) {
throw new IllegalStateException("DatabasePlatform must be explicitly set on DatabaseConfig for TenantMode "+config.getTenantMode());
}
// automatically determine the platform
platform = new DatabasePlatformFactory().create(config);
config.setDatabasePlatform(platform);
}
logger.info("DatabasePlatform name:{} platform:{}", config.getName(), platform.getName());
platform.configure(config.getPlatformConfig());
}
/**
* Set the DataSource if it has not already been set.
*/
private void setDataSource(DatabaseConfig config) {
if (isOfflineMode(config)) {
logger.debug("... DbOffline using platform [{}]", DbOffline.getPlatform());
} else {
InitDataSource.init(config);
}
}
private boolean isOfflineMode(DatabaseConfig config) {
return config.isDbOffline() || DbOffline.isSet();
}
/**
* Check the autoCommit and Transaction Isolation levels of the DataSource.
* <p>
* If autoCommit is true this could be a real problem.
* </p>
* <p>
* If the Isolation level is not READ_COMMITTED then optimistic concurrency
* checking may not work as expected.
* </p>
*/
private boolean checkDataSource(DatabaseConfig config) {
if (isOfflineMode(config)) {
return false;
}
if (config.getDataSource() == null) {
if (config.getDataSourceConfig().isOffline()) {
// this is ok - offline DDL generation etc
return false;
}
throw new RuntimeException("DataSource not set?");
}
try (Connection connection = config.getDataSource().getConnection()) {
if (connection.getAutoCommit()) {
logger.warn("DataSource [{}] has autoCommit defaulting to true!", config.getName());
}
return true;
} catch (SQLException ex) {
throw new PersistenceException(ex);
}
}
}
@@ -1,145 +0,0 @@
package io.ebeaninternal.server.core;
import io.ebean.config.DatabaseConfig;
import io.ebean.datasource.DataSourceAlertFactory;
import io.ebean.datasource.DataSourceConfig;
import io.ebean.datasource.DataSourceFactory;
import io.ebean.datasource.DataSourcePoolListener;
import javax.persistence.PersistenceException;
import javax.sql.DataSource;
/**
* Initialise the main DataSource and read-only DataSource.
*/
class InitDataSource {
private final JndiDataSourceLookup jndiDataSourceFactory = new JndiDataSourceLookup();
private final DatabaseConfig config;
/**
* Create and set the main DataSource and read-only DataSource.
*/
static void init(DatabaseConfig config) {
new InitDataSource(config).initialise();
}
InitDataSource(DatabaseConfig config) {
this.config = config;
}
private void initialise() {
if (config.getDataSource() == null) {
config.setDataSource(initDataSource());
}
if (config.getReadOnlyDataSource() == null) {
config.setReadOnlyDataSource(initReadOnlyDataSource());
}
}
/**
* Initialise the "main" read write DataSource from configuration.
*/
private DataSource initDataSource() {
final String jndiName = config.getDataSourceJndiName();
if (jndiName != null) {
return jndiDataSource(jndiName);
}
return createFromConfig(config.getDataSourceConfig(), false);
}
private DataSource jndiDataSource(String jndiName) {
DataSource ds = jndiDataSourceFactory.lookup(jndiName);
if (ds == null) {
throw new PersistenceException("JNDI lookup for DataSource " + jndiName + " returned null.");
}
return ds;
}
/**
* Initialise the "read only" DataSource from configuration.
*/
private DataSource initReadOnlyDataSource() {
DataSourceConfig roConfig = readOnlyConfig();
return roConfig == null ? null : createFromConfig(roConfig, true);
}
DataSourceConfig readOnlyConfig() {
DataSourceConfig roConfig = config.getReadOnlyDataSourceConfig();
if (roConfig == null) {
// it has explicitly been set to null, not expected but ok
return null;
}
if (urlSet(roConfig.getUrl())) {
return roConfig;
}
// convenient alternate place to set the read-only url
final String readOnlyUrl = config.getDataSourceConfig().getReadOnlyUrl();
if (urlSet(readOnlyUrl)) {
roConfig.setUrl(readOnlyUrl);
return roConfig;
}
if (config.isAutoReadOnlyDataSource()) {
roConfig.setUrl(null); // blank out in case it is "none"
return roConfig;
} else {
return null;
}
}
private boolean urlSet(String url) {
return url != null && !"none".equalsIgnoreCase(url) && !url.trim().isEmpty();
}
private DataSource createFromConfig(DataSourceConfig dsConfig, boolean readOnly) {
if (dsConfig == null) {
throw new PersistenceException("No DataSourceConfig defined for " + config.getName());
}
if (dsConfig.isOffline()) {
if (config.getDatabasePlatformName() == null) {
throw new PersistenceException("You MUST specify a DatabasePlatformName on DatabaseConfig when offline");
}
return null;
}
attachAlert(dsConfig);
attachListener(dsConfig);
if (readOnly) {
// setup to use AutoCommit such that we skip explicit commit
dsConfig.setAutoCommit(true);
dsConfig.setReadOnly(true);
dsConfig.setDefaults(config.getDataSourceConfig());
dsConfig.setIsolationLevel(config.getDataSourceConfig().getIsolationLevel());
}
return create(dsConfig, readOnly);
}
private DataSource create(DataSourceConfig dsConfig, boolean readOnly) {
String poolName = config.getName() + (readOnly ? "-ro" : "");
return DataSourceFactory.create(poolName, dsConfig);
}
/**
* Attach DataSourceAlert via service loader if present.
*/
private void attachAlert(DataSourceConfig dsConfig) {
DataSourceAlertFactory alertFactory = config.service(DataSourceAlertFactory.class);
if (alertFactory != null) {
dsConfig.setAlert(alertFactory.createAlert());
}
}
/**
* Create and attach a DataSourcePoolListener if it has been specified via properties and there is not one already attached.
*/
private void attachListener(DataSourceConfig dsConfig) {
if (dsConfig.getListener() == null) {
String poolListener = dsConfig.getPoolListener();
if (poolListener != null) {
dsConfig.setListener((DataSourcePoolListener) config.getClassLoadConfig().newInstance(poolListener));
}
}
}
}
@@ -1,70 +0,0 @@
package io.ebeaninternal.server.core;
import io.ebeaninternal.server.dto.DtoNamedQueries;
import io.ebeaninternal.xmapping.api.XmapDto;
import io.ebeaninternal.xmapping.api.XmapEbean;
import io.ebeaninternal.xmapping.api.XmapRawSql;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Reads the Xml deployment information.
*/
class InternalConfigXmlMap {
private static final Logger log = LoggerFactory.getLogger(InternalConfigXmlMap.class);
private final List<XmapEbean> xmlEbeanList;
private final ClassLoader classLoader;
private final Map<Class<?>, DtoNamedQueries> dtoNamedQueries = new HashMap<>();
InternalConfigXmlMap(List<XmapEbean> xmlEbeanList, ClassLoader classLoader) {
this.xmlEbeanList = xmlEbeanList;
this.classLoader = classLoader;
initDtoMapping();
}
void initDtoMapping() {
if (xmlEbeanList != null) {
for (XmapEbean mapping : xmlEbeanList) {
List<XmapDto> dtoList = mapping.getDto();
for (XmapDto dto : dtoList) {
readDtoMapping(dto);
}
}
}
}
/**
* Return the XML deployment information for entity beans.
*/
List<XmapEbean> xmlDeployment() {
return xmlEbeanList;
}
/**
* Return the named queries for Dto beans.
*/
Map<Class<?>, DtoNamedQueries> readDtoMapping() {
return dtoNamedQueries;
}
private void readDtoMapping(XmapDto dto) {
Class<?> dtoClass;
try {
dtoClass = Class.forName(dto.getClazz(), false, classLoader);
} catch (Exception e) {
log.error("Could not load dto bean class " + dto.getClazz() + " for ebean xml entry");
return;
}
DtoNamedQueries namedQueries = dtoNamedQueries.computeIfAbsent(dtoClass, aClass -> new DtoNamedQueries());
for (XmapRawSql sql : dto.getRawSql()) {
namedQueries.addRawSql(sql.getName(), sql.getQuery());
}
}
}
@@ -1,51 +0,0 @@
package io.ebeaninternal.server.deploy;
import io.ebean.util.StringHelper;
import io.ebeaninternal.server.core.InternString;
/**
* Used hold meta data when a bean property is overridden.
* <p>
* Typically this is for Embedded Beans.
* </p>
*/
class BeanPropertyOverride {
private final String dbColumn;
private final boolean dbNullable;
private final int dbLength;
private final int dbScale;
private final String dbColumnDefn;
BeanPropertyOverride(String dbColumn, boolean dbNullable, int dbLength, int dbScale, String dbColumnDefn) {
this.dbColumn = InternString.intern(dbColumn);
this.dbNullable = dbNullable;
this.dbLength = dbLength;
this.dbScale = dbScale;
this.dbColumnDefn = dbColumnDefn;
}
String getDbColumn() {
return dbColumn;
}
boolean isDbNullable() {
return dbNullable;
}
int getDbLength() {
return dbLength;
}
int getDbScale() {
return dbScale;
}
String getDbColumnDefn() {
return dbColumnDefn;
}
String replace(String src, String srcDbColumn) {
return StringHelper.replace(src, srcDbColumn, dbColumn);
}
}
@@ -1,75 +0,0 @@
package io.ebeaninternal.server.deploy.parse;
import io.ebean.annotation.DbMigration;
import io.ebean.annotation.Index;
import io.ebean.annotation.Indices;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import static io.ebean.util.AnnotationUtil.get;
public class AnnotationFind {
public static Set<JoinColumn> joinColumns(Field field) {
final JoinColumn col = get(field, JoinColumn.class);
if (col != null) {
return Collections.singleton(col);
}
final JoinColumns cols = get(field, JoinColumns.class);
if (cols != null) {
Set<JoinColumn> result = new LinkedHashSet<>();
Collections.addAll(result, cols.value());
return result;
}
return Collections.emptySet();
}
public static Set<AttributeOverride> attributeOverrides(Field field) {
final AttributeOverride ann = get(field, AttributeOverride.class);
if (ann != null) {
return Collections.singleton(ann);
}
final AttributeOverrides collection = get(field, AttributeOverrides.class);
if (collection != null) {
Set<AttributeOverride> result = new LinkedHashSet<>();
Collections.addAll(result, collection.value());
return result;
}
return Collections.emptySet();
}
public static Set<Index> indexes(Field field) {
final Index ann = get(field, Index.class);
if (ann != null) {
return Collections.singleton(ann);
}
final Indices collection = get(field, Indices.class);
if (collection != null) {
Set<Index> result = new LinkedHashSet<>();
Collections.addAll(result, collection.value());
return result;
}
return Collections.emptySet();
}
public static Set<DbMigration> dbMigrations(Field field) {
final DbMigration ann = get(field, DbMigration.class);
if (ann != null) {
return Collections.singleton(ann);
}
final DbMigration.List collection = get(field, DbMigration.List.class);
if (collection != null) {
Set<DbMigration> result = new LinkedHashSet<>();
Collections.addAll(result, collection.value());
return result;
}
return Collections.emptySet();
}
}
@@ -1,8 +0,0 @@
package io.ebeaninternal.server.deploy.parse;
class InitMetaJacksonAnnotation {
static void init(ReadAnnotationConfig readConfig) {
readConfig.addMetaAnnotation(com.fasterxml.jackson.annotation.JacksonAnnotation.class);
}
}
@@ -1,11 +0,0 @@
package io.ebeaninternal.server.deploy.parse;
import javax.validation.constraints.Size;
class InitMetaValidationAnnotation {
static void init(ReadAnnotationConfig readConfig) {
readConfig.addMetaAnnotation(Size.class);
readConfig.addMetaAnnotation(Size.List.class);
}
}
@@ -1,94 +0,0 @@
package io.ebeaninternal.server.dto;
import io.ebean.ProfileLocation;
import io.ebean.metric.MetricFactory;
import io.ebean.metric.QueryPlanMetric;
import io.ebeaninternal.api.SpiDtoQuery;
/**
* Request to map a resultSet columns for a query into a DTO bean.
*/
public class DtoMappingRequest {
private final Class type;
private final String label;
private final ProfileLocation profileLocation;
private final String sql;
private final boolean relaxedMode;
private final DtoColumn[] columnMeta;
public DtoMappingRequest(SpiDtoQuery query, String sql, DtoColumn[] columnMeta) {
this.type = query.getType();
this.label = query.getPlanLabel();
this.profileLocation = query.getProfileLocation();
this.sql = sql;
this.relaxedMode = query.isRelaxedMode();
this.columnMeta = columnMeta;
}
public DtoColumn[] getColumnMeta() {
return columnMeta;
}
public boolean isRelaxedMode() {
return relaxedMode;
}
public String getLabel() {
return label;
}
public String getSql() {
return sql;
}
public QueryPlanMetric createMetric() {
return MetricFactory.get().createQueryPlanMetric(type, label, profileLocation, sql);
}
/**
* Map all DB columns to setters.
*/
DtoReadSet[] mapSetters(DtoMeta meta) {
DtoReadSet[] setterProps = new DtoReadSet[columnMeta.length];
for (int i = 0; i < columnMeta.length; i++) {
setterProps[i] = mapColumn(i, meta);
}
return setterProps;
}
/**
* Map DB columns after constructor to setters.
*/
DtoReadSet[] mapArgPlusSetters(DtoMeta meta, int firstOnes) {
DtoReadSet[] setterProps = new DtoReadSet[columnMeta.length - firstOnes];
int pos = 0;
for (int i = firstOnes; i < columnMeta.length; i++) {
setterProps[pos++] = mapColumn(i, meta);
}
return setterProps;
}
private DtoReadSet mapColumn(int pos, DtoMeta meta) {
String label = columnMeta[pos].getLabel();
DtoReadSet property = meta.findProperty(label);
if (property == null || property.isReadOnly()) {
if (isRelaxedMode()) {
property = DtoReadSetColumnSkip.INSTANCE;
} else {
throw new IllegalStateException(unableToMapColumnMessage(columnMeta[pos], meta));
}
}
return property;
}
private String unableToMapColumnMessage(DtoColumn col, DtoMeta meta) {
return "Unable to map DB column " + col + " to a property with a setter method on " + meta.dtoType()+". Consider query.setRelaxedMode() to skip mapping this column.";
}
}
@@ -1,16 +0,0 @@
package io.ebeaninternal.server.expression.platform;
import io.ebeaninternal.api.SpiExpressionRequest;
import io.ebeaninternal.server.expression.Op;
/**
* MariaDB specific handling of platform specific expressions.
*/
class MariaDbExpression extends BasicDbExpression {
@Override
public void json(SpiExpressionRequest request, String propName, String path, Op operator, Object value) {
request.append("(").append(propName).append(" ->> '$.").append(path).append("')");
request.append(operator.bind());
}
}
@@ -1,329 +0,0 @@
// Generated from /home/rob/github/ebean-dir/ebean/src/test/resources/EQL.g4 by ANTLR 4.8
package io.ebeaninternal.server.grammer.antlr;
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
/**
* This class provides an empty implementation of {@link EQLVisitor},
* which can be extended to create a visitor which only needs to handle a subset
* of the available methods.
*
* @param <T> The return type of the visit operation. Use {@link Void} for
* operations with no return type.
*/
public class EQLBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements EQLVisitor<T> {
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitSelect_statement(EQLParser.Select_statementContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitSelect_properties(EQLParser.Select_propertiesContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitSelect_clause(EQLParser.Select_clauseContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitDistinct(EQLParser.DistinctContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFetch_clause(EQLParser.Fetch_clauseContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitWhere_clause(EQLParser.Where_clauseContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitOrderby_clause(EQLParser.Orderby_clauseContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitOrderby_property(EQLParser.Orderby_propertyContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitNulls_firstlast(EQLParser.Nulls_firstlastContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitAsc_desc(EQLParser.Asc_descContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitLimit_clause(EQLParser.Limit_clauseContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitOffset_clause(EQLParser.Offset_clauseContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFetch_path(EQLParser.Fetch_pathContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFetch_property_set(EQLParser.Fetch_property_setContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFetch_property_group(EQLParser.Fetch_property_groupContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFetch_path_path(EQLParser.Fetch_path_pathContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFetch_property(EQLParser.Fetch_propertyContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFetch_query_hint(EQLParser.Fetch_query_hintContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFetch_option(EQLParser.Fetch_optionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFetch_query_option(EQLParser.Fetch_query_optionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitConditional_expression(EQLParser.Conditional_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitConditional_term(EQLParser.Conditional_termContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitConditional_factor(EQLParser.Conditional_factorContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitConditional_primary(EQLParser.Conditional_primaryContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitAny_expression(EQLParser.Any_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitInOrEmpty_expression(EQLParser.InOrEmpty_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIn_expression(EQLParser.In_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIn_value(EQLParser.In_valueContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitBetween_expression(EQLParser.Between_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitInrange_expression(EQLParser.Inrange_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitInrange_op(EQLParser.Inrange_opContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIsNull_expression(EQLParser.IsNull_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitLike_expression(EQLParser.Like_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitLike_op(EQLParser.Like_opContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitComparison_expression(EQLParser.Comparison_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitComparison_operator(EQLParser.Comparison_operatorContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitValue_expression(EQLParser.Value_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitLiteral(EQLParser.LiteralContext ctx) { return visitChildren(ctx); }
}
File diff suppressed because one or more lines are too long
@@ -1,374 +0,0 @@
// Generated from /home/rob/github/ebean-dir/ebean/src/test/resources/EQL.g4 by ANTLR 4.8
package io.ebeaninternal.server.grammer.antlr;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.RuntimeMetaData;
import org.antlr.v4.runtime.Vocabulary;
import org.antlr.v4.runtime.VocabularyImpl;
import org.antlr.v4.runtime.atn.ATN;
import org.antlr.v4.runtime.atn.ATNDeserializer;
import org.antlr.v4.runtime.atn.LexerATNSimulator;
import org.antlr.v4.runtime.atn.PredictionContextCache;
import org.antlr.v4.runtime.dfa.DFA;
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class EQLLexer extends Lexer {
static { RuntimeMetaData.checkVersion("4.8", 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, T__57=58, T__58=59,
T__59=60, T__60=61, T__61=62, T__62=63, T__63=64, T__64=65, T__65=66,
T__66=67, INPUT_VARIABLE=68, PATH_VARIABLE=69, QUOTED_PATH_VARIABLE=70,
PROP_FORMULA=71, BOOLEAN_LITERAL=72, NUMBER_LITERAL=73, DOUBLE=74, INT=75,
ZERO=76, STRING_LITERAL=77, WS=78;
public static String[] channelNames = {
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
};
public static String[] modeNames = {
"DEFAULT_MODE"
};
private static String[] makeRuleNames() {
return new String[] {
"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",
"T__57", "T__58", "T__59", "T__60", "T__61", "T__62", "T__63", "T__64",
"T__65", "T__66", "INPUT_VARIABLE", "PATH_VARIABLE", "QUOTED_PATH_VARIABLE",
"PROP_FORMULA", "BOOLEAN_LITERAL", "NUMBER_LITERAL", "DOUBLE", "INT",
"ZERO", "STRING_LITERAL", "WS"
};
}
public static final String[] ruleNames = makeRuleNames();
private static String[] makeLiteralNames() {
return new String[] {
null, "'('", "')'", "'select'", "'distinct'", "'where'", "'order'", "'by'",
"','", "'nulls'", "'first'", "'last'", "'asc'", "'desc'", "'limit'",
"'offset'", "'fetch'", "'+'", "'query'", "'lazy'", "'or'", "'and'", "'not'",
"'inOrEmpty'", "'in'", "'between'", "'to'", "'inrange'", "'inRange'",
"'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'", "'ine'", "'eqOrNull'",
"'gtOrNull'", "'ltOrNull'", "'geOrNull'", "'leOrNull'", null, null, null,
null, null, null, null, null, "'0'"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
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, null, null,
null, null, null, null, null, null, null, null, "INPUT_VARIABLE", "PATH_VARIABLE",
"QUOTED_PATH_VARIABLE", "PROP_FORMULA", "BOOLEAN_LITERAL", "NUMBER_LITERAL",
"DOUBLE", "INT", "ZERO", "STRING_LITERAL", "WS"
};
}
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
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[] getChannelNames() { return channelNames; }
@Override
public String[] getModeNames() { return modeNames; }
@Override
public ATN getATN() { return _ATN; }
public static final String _serializedATN =
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2P\u029f\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\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I"+
"\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\3\2\3\2\3\3\3\3\3\4\3\4\3\4\3"+
"\4\3\4\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\30\3\30\3\30\3\30\3\30\3"+
"\30\3\30\3\31\3\31\3\31\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3\33\3"+
"\33\3\33\3\34\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\36\3\36\3\36\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-\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\62\3\62\3\62\3\63\3\63\3\63\3\64\3\64\3\64\3\65\3\65\3\65"+
"\3\65\3\66\3\66\3\67\3\67\3\67\38\38\38\39\39\39\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@"+
"\3A\3A\3A\3A\3A\3A\3A\3A\3A\3B\3B\3B\3B\3B\3B\3B\3B\3B\3C\3C\3C\3C\3C"+
"\3C\3C\3C\3C\3D\3D\3D\3D\3D\3D\3D\3D\3D\3E\3E\3E\7E\u0221\nE\fE\16E\u0224"+
"\13E\3E\3E\7E\u0228\nE\fE\16E\u022b\13E\5E\u022d\nE\3F\3F\7F\u0231\nF"+
"\fF\16F\u0234\13F\3G\3G\3G\3G\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3"+
"H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3"+
"H\3H\3H\3H\3H\3H\5H\u0264\nH\3I\3I\3I\3I\3I\3I\3I\3I\3I\5I\u026f\nI\3"+
"J\5J\u0272\nJ\3J\3J\5J\u0276\nJ\3J\3J\5J\u027a\nJ\3K\6K\u027d\nK\rK\16"+
"K\u027e\3K\3K\7K\u0283\nK\fK\16K\u0286\13K\3L\3L\7L\u028a\nL\fL\16L\u028d"+
"\13L\3M\3M\3N\3N\3N\3N\7N\u0295\nN\fN\16N\u0298\13N\3N\3N\3O\3O\3O\3O"+
"\2\2P\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\u0087E\u0089F\u008bG\u008d"+
"H\u008fI\u0091J\u0093K\u0095L\u0097M\u0099N\u009bO\u009dP\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\"\"\2\u02b0\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\2G\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\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\177\3\2\2\2\2\u0081\3\2\2"+
"\2\2\u0083\3\2\2\2\2\u0085\3\2\2\2\2\u0087\3\2\2\2\2\u0089\3\2\2\2\2\u008b"+
"\3\2\2\2\2\u008d\3\2\2\2\2\u008f\3\2\2\2\2\u0091\3\2\2\2\2\u0093\3\2\2"+
"\2\2\u0095\3\2\2\2\2\u0097\3\2\2\2\2\u0099\3\2\2\2\2\u009b\3\2\2\2\2\u009d"+
"\3\2\2\2\3\u009f\3\2\2\2\5\u00a1\3\2\2\2\7\u00a3\3\2\2\2\t\u00aa\3\2\2"+
"\2\13\u00b3\3\2\2\2\r\u00b9\3\2\2\2\17\u00bf\3\2\2\2\21\u00c2\3\2\2\2"+
"\23\u00c4\3\2\2\2\25\u00ca\3\2\2\2\27\u00d0\3\2\2\2\31\u00d5\3\2\2\2\33"+
"\u00d9\3\2\2\2\35\u00de\3\2\2\2\37\u00e4\3\2\2\2!\u00eb\3\2\2\2#\u00f1"+
"\3\2\2\2%\u00f3\3\2\2\2\'\u00f9\3\2\2\2)\u00fe\3\2\2\2+\u0101\3\2\2\2"+
"-\u0105\3\2\2\2/\u0109\3\2\2\2\61\u0113\3\2\2\2\63\u0116\3\2\2\2\65\u011e"+
"\3\2\2\2\67\u0121\3\2\2\29\u0129\3\2\2\2;\u0131\3\2\2\2=\u0134\3\2\2\2"+
"?\u0139\3\2\2\2A\u0140\3\2\2\2C\u014a\3\2\2\2E\u0152\3\2\2\2G\u0158\3"+
"\2\2\2I\u0160\3\2\2\2K\u016b\3\2\2\2M\u0174\3\2\2\2O\u0179\3\2\2\2Q\u017f"+
"\3\2\2\2S\u0188\3\2\2\2U\u0192\3\2\2\2W\u019d\3\2\2\2Y\u01a9\3\2\2\2["+
"\u01b2\3\2\2\2]\u01bc\3\2\2\2_\u01be\3\2\2\2a\u01c1\3\2\2\2c\u01c3\3\2"+
"\2\2e\u01c6\3\2\2\2g\u01c9\3\2\2\2i\u01cc\3\2\2\2k\u01d0\3\2\2\2m\u01d2"+
"\3\2\2\2o\u01d5\3\2\2\2q\u01d8\3\2\2\2s\u01db\3\2\2\2u\u01df\3\2\2\2w"+
"\u01e2\3\2\2\2y\u01e5\3\2\2\2{\u01e8\3\2\2\2}\u01ec\3\2\2\2\177\u01f0"+
"\3\2\2\2\u0081\u01f9\3\2\2\2\u0083\u0202\3\2\2\2\u0085\u020b\3\2\2\2\u0087"+
"\u0214\3\2\2\2\u0089\u022c\3\2\2\2\u008b\u022e\3\2\2\2\u008d\u0235\3\2"+
"\2\2\u008f\u0263\3\2\2\2\u0091\u026e\3\2\2\2\u0093\u0279\3\2\2\2\u0095"+
"\u027c\3\2\2\2\u0097\u0287\3\2\2\2\u0099\u028e\3\2\2\2\u009b\u0290\3\2"+
"\2\2\u009d\u029b\3\2\2\2\u009f\u00a0\7*\2\2\u00a0\4\3\2\2\2\u00a1\u00a2"+
"\7+\2\2\u00a2\6\3\2\2\2\u00a3\u00a4\7u\2\2\u00a4\u00a5\7g\2\2\u00a5\u00a6"+
"\7n\2\2\u00a6\u00a7\7g\2\2\u00a7\u00a8\7e\2\2\u00a8\u00a9\7v\2\2\u00a9"+
"\b\3\2\2\2\u00aa\u00ab\7f\2\2\u00ab\u00ac\7k\2\2\u00ac\u00ad\7u\2\2\u00ad"+
"\u00ae\7v\2\2\u00ae\u00af\7k\2\2\u00af\u00b0\7p\2\2\u00b0\u00b1\7e\2\2"+
"\u00b1\u00b2\7v\2\2\u00b2\n\3\2\2\2\u00b3\u00b4\7y\2\2\u00b4\u00b5\7j"+
"\2\2\u00b5\u00b6\7g\2\2\u00b6\u00b7\7t\2\2\u00b7\u00b8\7g\2\2\u00b8\f"+
"\3\2\2\2\u00b9\u00ba\7q\2\2\u00ba\u00bb\7t\2\2\u00bb\u00bc\7f\2\2\u00bc"+
"\u00bd\7g\2\2\u00bd\u00be\7t\2\2\u00be\16\3\2\2\2\u00bf\u00c0\7d\2\2\u00c0"+
"\u00c1\7{\2\2\u00c1\20\3\2\2\2\u00c2\u00c3\7.\2\2\u00c3\22\3\2\2\2\u00c4"+
"\u00c5\7p\2\2\u00c5\u00c6\7w\2\2\u00c6\u00c7\7n\2\2\u00c7\u00c8\7n\2\2"+
"\u00c8\u00c9\7u\2\2\u00c9\24\3\2\2\2\u00ca\u00cb\7h\2\2\u00cb\u00cc\7"+
"k\2\2\u00cc\u00cd\7t\2\2\u00cd\u00ce\7u\2\2\u00ce\u00cf\7v\2\2\u00cf\26"+
"\3\2\2\2\u00d0\u00d1\7n\2\2\u00d1\u00d2\7c\2\2\u00d2\u00d3\7u\2\2\u00d3"+
"\u00d4\7v\2\2\u00d4\30\3\2\2\2\u00d5\u00d6\7c\2\2\u00d6\u00d7\7u\2\2\u00d7"+
"\u00d8\7e\2\2\u00d8\32\3\2\2\2\u00d9\u00da\7f\2\2\u00da\u00db\7g\2\2\u00db"+
"\u00dc\7u\2\2\u00dc\u00dd\7e\2\2\u00dd\34\3\2\2\2\u00de\u00df\7n\2\2\u00df"+
"\u00e0\7k\2\2\u00e0\u00e1\7o\2\2\u00e1\u00e2\7k\2\2\u00e2\u00e3\7v\2\2"+
"\u00e3\36\3\2\2\2\u00e4\u00e5\7q\2\2\u00e5\u00e6\7h\2\2\u00e6\u00e7\7"+
"h\2\2\u00e7\u00e8\7u\2\2\u00e8\u00e9\7g\2\2\u00e9\u00ea\7v\2\2\u00ea "+
"\3\2\2\2\u00eb\u00ec\7h\2\2\u00ec\u00ed\7g\2\2\u00ed\u00ee\7v\2\2\u00ee"+
"\u00ef\7e\2\2\u00ef\u00f0\7j\2\2\u00f0\"\3\2\2\2\u00f1\u00f2\7-\2\2\u00f2"+
"$\3\2\2\2\u00f3\u00f4\7s\2\2\u00f4\u00f5\7w\2\2\u00f5\u00f6\7g\2\2\u00f6"+
"\u00f7\7t\2\2\u00f7\u00f8\7{\2\2\u00f8&\3\2\2\2\u00f9\u00fa\7n\2\2\u00fa"+
"\u00fb\7c\2\2\u00fb\u00fc\7|\2\2\u00fc\u00fd\7{\2\2\u00fd(\3\2\2\2\u00fe"+
"\u00ff\7q\2\2\u00ff\u0100\7t\2\2\u0100*\3\2\2\2\u0101\u0102\7c\2\2\u0102"+
"\u0103\7p\2\2\u0103\u0104\7f\2\2\u0104,\3\2\2\2\u0105\u0106\7p\2\2\u0106"+
"\u0107\7q\2\2\u0107\u0108\7v\2\2\u0108.\3\2\2\2\u0109\u010a\7k\2\2\u010a"+
"\u010b\7p\2\2\u010b\u010c\7Q\2\2\u010c\u010d\7t\2\2\u010d\u010e\7G\2\2"+
"\u010e\u010f\7o\2\2\u010f\u0110\7r\2\2\u0110\u0111\7v\2\2\u0111\u0112"+
"\7{\2\2\u0112\60\3\2\2\2\u0113\u0114\7k\2\2\u0114\u0115\7p\2\2\u0115\62"+
"\3\2\2\2\u0116\u0117\7d\2\2\u0117\u0118\7g\2\2\u0118\u0119\7v\2\2\u0119"+
"\u011a\7y\2\2\u011a\u011b\7g\2\2\u011b\u011c\7g\2\2\u011c\u011d\7p\2\2"+
"\u011d\64\3\2\2\2\u011e\u011f\7v\2\2\u011f\u0120\7q\2\2\u0120\66\3\2\2"+
"\2\u0121\u0122\7k\2\2\u0122\u0123\7p\2\2\u0123\u0124\7t\2\2\u0124\u0125"+
"\7c\2\2\u0125\u0126\7p\2\2\u0126\u0127\7i\2\2\u0127\u0128\7g\2\2\u0128"+
"8\3\2\2\2\u0129\u012a\7k\2\2\u012a\u012b\7p\2\2\u012b\u012c\7T\2\2\u012c"+
"\u012d\7c\2\2\u012d\u012e\7p\2\2\u012e\u012f\7i\2\2\u012f\u0130\7g\2\2"+
"\u0130:\3\2\2\2\u0131\u0132\7k\2\2\u0132\u0133\7u\2\2\u0133<\3\2\2\2\u0134"+
"\u0135\7p\2\2\u0135\u0136\7w\2\2\u0136\u0137\7n\2\2\u0137\u0138\7n\2\2"+
"\u0138>\3\2\2\2\u0139\u013a\7k\2\2\u013a\u013b\7u\2\2\u013b\u013c\7P\2"+
"\2\u013c\u013d\7w\2\2\u013d\u013e\7n\2\2\u013e\u013f\7n\2\2\u013f@\3\2"+
"\2\2\u0140\u0141\7k\2\2\u0141\u0142\7u\2\2\u0142\u0143\7P\2\2\u0143\u0144"+
"\7q\2\2\u0144\u0145\7v\2\2\u0145\u0146\7P\2\2\u0146\u0147\7w\2\2\u0147"+
"\u0148\7n\2\2\u0148\u0149\7n\2\2\u0149B\3\2\2\2\u014a\u014b\7p\2\2\u014b"+
"\u014c\7q\2\2\u014c\u014d\7v\2\2\u014d\u014e\7P\2\2\u014e\u014f\7w\2\2"+
"\u014f\u0150\7n\2\2\u0150\u0151\7n\2\2\u0151D\3\2\2\2\u0152\u0153\7g\2"+
"\2\u0153\u0154\7o\2\2\u0154\u0155\7r\2\2\u0155\u0156\7v\2\2\u0156\u0157"+
"\7{\2\2\u0157F\3\2\2\2\u0158\u0159\7k\2\2\u0159\u015a\7u\2\2\u015a\u015b"+
"\7G\2\2\u015b\u015c\7o\2\2\u015c\u015d\7r\2\2\u015d\u015e\7v\2\2\u015e"+
"\u015f\7{\2\2\u015fH\3\2\2\2\u0160\u0161\7k\2\2\u0161\u0162\7u\2\2\u0162"+
"\u0163\7P\2\2\u0163\u0164\7q\2\2\u0164\u0165\7v\2\2\u0165\u0166\7G\2\2"+
"\u0166\u0167\7o\2\2\u0167\u0168\7r\2\2\u0168\u0169\7v\2\2\u0169\u016a"+
"\7{\2\2\u016aJ\3\2\2\2\u016b\u016c\7p\2\2\u016c\u016d\7q\2\2\u016d\u016e"+
"\7v\2\2\u016e\u016f\7G\2\2\u016f\u0170\7o\2\2\u0170\u0171\7r\2\2\u0171"+
"\u0172\7v\2\2\u0172\u0173\7{\2\2\u0173L\3\2\2\2\u0174\u0175\7n\2\2\u0175"+
"\u0176\7k\2\2\u0176\u0177\7m\2\2\u0177\u0178\7g\2\2\u0178N\3\2\2\2\u0179"+
"\u017a\7k\2\2\u017a\u017b\7n\2\2\u017b\u017c\7k\2\2\u017c\u017d\7m\2\2"+
"\u017d\u017e\7g\2\2\u017eP\3\2\2\2\u017f\u0180\7e\2\2\u0180\u0181\7q\2"+
"\2\u0181\u0182\7p\2\2\u0182\u0183\7v\2\2\u0183\u0184\7c\2\2\u0184\u0185"+
"\7k\2\2\u0185\u0186\7p\2\2\u0186\u0187\7u\2\2\u0187R\3\2\2\2\u0188\u0189"+
"\7k\2\2\u0189\u018a\7e\2\2\u018a\u018b\7q\2\2\u018b\u018c\7p\2\2\u018c"+
"\u018d\7v\2\2\u018d\u018e\7c\2\2\u018e\u018f\7k\2\2\u018f\u0190\7p\2\2"+
"\u0190\u0191\7u\2\2\u0191T\3\2\2\2\u0192\u0193\7u\2\2\u0193\u0194\7v\2"+
"\2\u0194\u0195\7c\2\2\u0195\u0196\7t\2\2\u0196\u0197\7v\2\2\u0197\u0198"+
"\7u\2\2\u0198\u0199\7Y\2\2\u0199\u019a\7k\2\2\u019a\u019b\7v\2\2\u019b"+
"\u019c\7j\2\2\u019cV\3\2\2\2\u019d\u019e\7k\2\2\u019e\u019f\7u\2\2\u019f"+
"\u01a0\7v\2\2\u01a0\u01a1\7c\2\2\u01a1\u01a2\7t\2\2\u01a2\u01a3\7v\2\2"+
"\u01a3\u01a4\7u\2\2\u01a4\u01a5\7Y\2\2\u01a5\u01a6\7k\2\2\u01a6\u01a7"+
"\7v\2\2\u01a7\u01a8\7j\2\2\u01a8X\3\2\2\2\u01a9\u01aa\7g\2\2\u01aa\u01ab"+
"\7p\2\2\u01ab\u01ac\7f\2\2\u01ac\u01ad\7u\2\2\u01ad\u01ae\7Y\2\2\u01ae"+
"\u01af\7k\2\2\u01af\u01b0\7v\2\2\u01b0\u01b1\7j\2\2\u01b1Z\3\2\2\2\u01b2"+
"\u01b3\7k\2\2\u01b3\u01b4\7g\2\2\u01b4\u01b5\7p\2\2\u01b5\u01b6\7f\2\2"+
"\u01b6\u01b7\7u\2\2\u01b7\u01b8\7Y\2\2\u01b8\u01b9\7k\2\2\u01b9\u01ba"+
"\7v\2\2\u01ba\u01bb\7j\2\2\u01bb\\\3\2\2\2\u01bc\u01bd\7?\2\2\u01bd^\3"+
"\2\2\2\u01be\u01bf\7g\2\2\u01bf\u01c0\7s\2\2\u01c0`\3\2\2\2\u01c1\u01c2"+
"\7@\2\2\u01c2b\3\2\2\2\u01c3\u01c4\7i\2\2\u01c4\u01c5\7v\2\2\u01c5d\3"+
"\2\2\2\u01c6\u01c7\7@\2\2\u01c7\u01c8\7?\2\2\u01c8f\3\2\2\2\u01c9\u01ca"+
"\7i\2\2\u01ca\u01cb\7g\2\2\u01cbh\3\2\2\2\u01cc\u01cd\7i\2\2\u01cd\u01ce"+
"\7v\2\2\u01ce\u01cf\7g\2\2\u01cfj\3\2\2\2\u01d0\u01d1\7>\2\2\u01d1l\3"+
"\2\2\2\u01d2\u01d3\7n\2\2\u01d3\u01d4\7v\2\2\u01d4n\3\2\2\2\u01d5\u01d6"+
"\7>\2\2\u01d6\u01d7\7?\2\2\u01d7p\3\2\2\2\u01d8\u01d9\7n\2\2\u01d9\u01da"+
"\7g\2\2\u01dar\3\2\2\2\u01db\u01dc\7n\2\2\u01dc\u01dd\7v\2\2\u01dd\u01de"+
"\7g\2\2\u01det\3\2\2\2\u01df\u01e0\7>\2\2\u01e0\u01e1\7@\2\2\u01e1v\3"+
"\2\2\2\u01e2\u01e3\7#\2\2\u01e3\u01e4\7?\2\2\u01e4x\3\2\2\2\u01e5\u01e6"+
"\7p\2\2\u01e6\u01e7\7g\2\2\u01e7z\3\2\2\2\u01e8\u01e9\7k\2\2\u01e9\u01ea"+
"\7g\2\2\u01ea\u01eb\7s\2\2\u01eb|\3\2\2\2\u01ec\u01ed\7k\2\2\u01ed\u01ee"+
"\7p\2\2\u01ee\u01ef\7g\2\2\u01ef~\3\2\2\2\u01f0\u01f1\7g\2\2\u01f1\u01f2"+
"\7s\2\2\u01f2\u01f3\7Q\2\2\u01f3\u01f4\7t\2\2\u01f4\u01f5\7P\2\2\u01f5"+
"\u01f6\7w\2\2\u01f6\u01f7\7n\2\2\u01f7\u01f8\7n\2\2\u01f8\u0080\3\2\2"+
"\2\u01f9\u01fa\7i\2\2\u01fa\u01fb\7v\2\2\u01fb\u01fc\7Q\2\2\u01fc\u01fd"+
"\7t\2\2\u01fd\u01fe\7P\2\2\u01fe\u01ff\7w\2\2\u01ff\u0200\7n\2\2\u0200"+
"\u0201\7n\2\2\u0201\u0082\3\2\2\2\u0202\u0203\7n\2\2\u0203\u0204\7v\2"+
"\2\u0204\u0205\7Q\2\2\u0205\u0206\7t\2\2\u0206\u0207\7P\2\2\u0207\u0208"+
"\7w\2\2\u0208\u0209\7n\2\2\u0209\u020a\7n\2\2\u020a\u0084\3\2\2\2\u020b"+
"\u020c\7i\2\2\u020c\u020d\7g\2\2\u020d\u020e\7Q\2\2\u020e\u020f\7t\2\2"+
"\u020f\u0210\7P\2\2\u0210\u0211\7w\2\2\u0211\u0212\7n\2\2\u0212\u0213"+
"\7n\2\2\u0213\u0086\3\2\2\2\u0214\u0215\7n\2\2\u0215\u0216\7g\2\2\u0216"+
"\u0217\7Q\2\2\u0217\u0218\7t\2\2\u0218\u0219\7P\2\2\u0219\u021a\7w\2\2"+
"\u021a\u021b\7n\2\2\u021b\u021c\7n\2\2\u021c\u0088\3\2\2\2\u021d\u021e"+
"\7<\2\2\u021e\u0222\t\2\2\2\u021f\u0221\t\3\2\2\u0220\u021f\3\2\2\2\u0221"+
"\u0224\3\2\2\2\u0222\u0220\3\2\2\2\u0222\u0223\3\2\2\2\u0223\u022d\3\2"+
"\2\2\u0224\u0222\3\2\2\2\u0225\u0229\7A\2\2\u0226\u0228\4\62;\2\u0227"+
"\u0226\3\2\2\2\u0228\u022b\3\2\2\2\u0229\u0227\3\2\2\2\u0229\u022a\3\2"+
"\2\2\u022a\u022d\3\2\2\2\u022b\u0229\3\2\2\2\u022c\u021d\3\2\2\2\u022c"+
"\u0225\3\2\2\2\u022d\u008a\3\2\2\2\u022e\u0232\t\2\2\2\u022f\u0231\t\4"+
"\2\2\u0230\u022f\3\2\2\2\u0231\u0234\3\2\2\2\u0232\u0230\3\2\2\2\u0232"+
"\u0233\3\2\2\2\u0233\u008c\3\2\2\2\u0234\u0232\3\2\2\2\u0235\u0236\7b"+
"\2\2\u0236\u0237\5\u008bF\2\u0237\u0238\7b\2\2\u0238\u008e\3\2\2\2\u0239"+
"\u023a\7u\2\2\u023a\u023b\7w\2\2\u023b\u023c\7o\2\2\u023c\u023d\7*\2\2"+
"\u023d\u023e\3\2\2\2\u023e\u023f\5\u008bF\2\u023f\u0240\7+\2\2\u0240\u0264"+
"\3\2\2\2\u0241\u0242\7o\2\2\u0242\u0243\7c\2\2\u0243\u0244\7z\2\2\u0244"+
"\u0245\7*\2\2\u0245\u0246\3\2\2\2\u0246\u0247\5\u008bF\2\u0247\u0248\7"+
"+\2\2\u0248\u0264\3\2\2\2\u0249\u024a\7o\2\2\u024a\u024b\7k\2\2\u024b"+
"\u024c\7p\2\2\u024c\u024d\7*\2\2\u024d\u024e\3\2\2\2\u024e\u024f\5\u008b"+
"F\2\u024f\u0250\7+\2\2\u0250\u0264\3\2\2\2\u0251\u0252\7c\2\2\u0252\u0253"+
"\7x\2\2\u0253\u0254\7i\2\2\u0254\u0255\7*\2\2\u0255\u0256\3\2\2\2\u0256"+
"\u0257\5\u008bF\2\u0257\u0258\7+\2\2\u0258\u0264\3\2\2\2\u0259\u025a\7"+
"e\2\2\u025a\u025b\7q\2\2\u025b\u025c\7w\2\2\u025c\u025d\7p\2\2\u025d\u025e"+
"\7v\2\2\u025e\u025f\7*\2\2\u025f\u0260\3\2\2\2\u0260\u0261\5\u008bF\2"+
"\u0261\u0262\7+\2\2\u0262\u0264\3\2\2\2\u0263\u0239\3\2\2\2\u0263\u0241"+
"\3\2\2\2\u0263\u0249\3\2\2\2\u0263\u0251\3\2\2\2\u0263\u0259\3\2\2\2\u0264"+
"\u0090\3\2\2\2\u0265\u0266\7v\2\2\u0266\u0267\7t\2\2\u0267\u0268\7w\2"+
"\2\u0268\u026f\7g\2\2\u0269\u026a\7h\2\2\u026a\u026b\7c\2\2\u026b\u026c"+
"\7n\2\2\u026c\u026d\7u\2\2\u026d\u026f\7g\2\2\u026e\u0265\3\2\2\2\u026e"+
"\u0269\3\2\2\2\u026f\u0092\3\2\2\2\u0270\u0272\7/\2\2\u0271\u0270\3\2"+
"\2\2\u0271\u0272\3\2\2\2\u0272\u0273\3\2\2\2\u0273\u027a\5\u0095K\2\u0274"+
"\u0276\7/\2\2\u0275\u0274\3\2\2\2\u0275\u0276\3\2\2\2\u0276\u0277\3\2"+
"\2\2\u0277\u027a\5\u0097L\2\u0278\u027a\5\u0099M\2\u0279\u0271\3\2\2\2"+
"\u0279\u0275\3\2\2\2\u0279\u0278\3\2\2\2\u027a\u0094\3\2\2\2\u027b\u027d"+
"\t\5\2\2\u027c\u027b\3\2\2\2\u027d\u027e\3\2\2\2\u027e\u027c\3\2\2\2\u027e"+
"\u027f\3\2\2\2\u027f\u0280\3\2\2\2\u0280\u0284\7\60\2\2\u0281\u0283\t"+
"\5\2\2\u0282\u0281\3\2\2\2\u0283\u0286\3\2\2\2\u0284\u0282\3\2\2\2\u0284"+
"\u0285\3\2\2\2\u0285\u0096\3\2\2\2\u0286\u0284\3\2\2\2\u0287\u028b\t\6"+
"\2\2\u0288\u028a\t\5\2\2\u0289\u0288\3\2\2\2\u028a\u028d\3\2\2\2\u028b"+
"\u0289\3\2\2\2\u028b\u028c\3\2\2\2\u028c\u0098\3\2\2\2\u028d\u028b\3\2"+
"\2\2\u028e\u028f\7\62\2\2\u028f\u009a\3\2\2\2\u0290\u0296\7)\2\2\u0291"+
"\u0295\n\7\2\2\u0292\u0293\7)\2\2\u0293\u0295\7)\2\2\u0294\u0291\3\2\2"+
"\2\u0294\u0292\3\2\2\2\u0295\u0298\3\2\2\2\u0296\u0294\3\2\2\2\u0296\u0297"+
"\3\2\2\2\u0297\u0299\3\2\2\2\u0298\u0296\3\2\2\2\u0299\u029a\7)\2\2\u029a"+
"\u009c\3\2\2\2\u029b\u029c\t\b\2\2\u029c\u029d\3\2\2\2\u029d\u029e\bO"+
"\2\2\u029e\u009e\3\2\2\2\21\2\u0222\u0229\u022c\u0232\u0263\u026e\u0271"+
"\u0275\u0279\u027e\u0284\u028b\u0294\u0296\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);
}
}
}
@@ -1,283 +0,0 @@
// Generated from /home/rob/github/ebean-dir/ebean/src/test/resources/EQL.g4 by ANTLR 4.8
package io.ebeaninternal.server.grammer.antlr;
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
/**
* This interface defines a complete generic visitor for a parse tree produced
* by {@link EQLParser}.
*
* @param <T> The return type of the visit operation. Use {@link Void} for
* operations with no return type.
*/
public interface EQLVisitor<T> extends ParseTreeVisitor<T> {
/**
* Visit a parse tree produced by {@link EQLParser#select_statement}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitSelect_statement(EQLParser.Select_statementContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#select_properties}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitSelect_properties(EQLParser.Select_propertiesContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#select_clause}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitSelect_clause(EQLParser.Select_clauseContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#distinct}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitDistinct(EQLParser.DistinctContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#fetch_clause}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitFetch_clause(EQLParser.Fetch_clauseContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#where_clause}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitWhere_clause(EQLParser.Where_clauseContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#orderby_clause}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitOrderby_clause(EQLParser.Orderby_clauseContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#orderby_property}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitOrderby_property(EQLParser.Orderby_propertyContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#nulls_firstlast}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitNulls_firstlast(EQLParser.Nulls_firstlastContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#asc_desc}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitAsc_desc(EQLParser.Asc_descContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#limit_clause}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitLimit_clause(EQLParser.Limit_clauseContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#offset_clause}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitOffset_clause(EQLParser.Offset_clauseContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#fetch_path}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitFetch_path(EQLParser.Fetch_pathContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#fetch_property_set}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitFetch_property_set(EQLParser.Fetch_property_setContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#fetch_property_group}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitFetch_property_group(EQLParser.Fetch_property_groupContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#fetch_path_path}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitFetch_path_path(EQLParser.Fetch_path_pathContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#fetch_property}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitFetch_property(EQLParser.Fetch_propertyContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#fetch_query_hint}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitFetch_query_hint(EQLParser.Fetch_query_hintContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#fetch_lazy_hint}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitFetch_lazy_hint(EQLParser.Fetch_lazy_hintContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#fetch_option}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitFetch_option(EQLParser.Fetch_optionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#fetch_query_option}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitFetch_query_option(EQLParser.Fetch_query_optionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#fetch_lazy_option}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitFetch_lazy_option(EQLParser.Fetch_lazy_optionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#fetch_batch_size}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitFetch_batch_size(EQLParser.Fetch_batch_sizeContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#conditional_expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitConditional_expression(EQLParser.Conditional_expressionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#conditional_term}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitConditional_term(EQLParser.Conditional_termContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#conditional_factor}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitConditional_factor(EQLParser.Conditional_factorContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#conditional_primary}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitConditional_primary(EQLParser.Conditional_primaryContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#any_expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitAny_expression(EQLParser.Any_expressionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#inOrEmpty_expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitInOrEmpty_expression(EQLParser.InOrEmpty_expressionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#in_expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitIn_expression(EQLParser.In_expressionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#in_value}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitIn_value(EQLParser.In_valueContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#between_expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitBetween_expression(EQLParser.Between_expressionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#inrange_expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitInrange_expression(EQLParser.Inrange_expressionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#inrange_op}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitInrange_op(EQLParser.Inrange_opContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#propertyBetween_expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitPropertyBetween_expression(EQLParser.PropertyBetween_expressionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#isNull_expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitIsNull_expression(EQLParser.IsNull_expressionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#isNotNull_expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitIsNotNull_expression(EQLParser.IsNotNull_expressionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#isEmpty_expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitIsEmpty_expression(EQLParser.IsEmpty_expressionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#isNotEmpty_expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitIsNotEmpty_expression(EQLParser.IsNotEmpty_expressionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#like_expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitLike_expression(EQLParser.Like_expressionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#like_op}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitLike_op(EQLParser.Like_opContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#comparison_expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitComparison_expression(EQLParser.Comparison_expressionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#comparison_operator}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitComparison_operator(EQLParser.Comparison_operatorContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#value_expression}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitValue_expression(EQLParser.Value_expressionContext ctx);
/**
* Visit a parse tree produced by {@link EQLParser#literal}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitLiteral(EQLParser.LiteralContext ctx);
}
@@ -1,14 +0,0 @@
package io.ebeaninternal.server.persist;
/**
* Utility to improve logging of raw SQL that contains new line characters.
*/
public class TrimLogSql {
/**
* Replace new line chars for nicer logging of multi-line sql strings.
*/
public static String trim(String sql) {
return sql.replace("\n","\\n ");
}
}
@@ -1 +0,0 @@
io.ebeaninternal.server.profile.DMetricFactory
@@ -1,48 +0,0 @@
package io.ebean;
import io.ebean.annotation.ForPlatform;
import io.ebean.annotation.IgnorePlatform;
import io.ebean.annotation.Platform;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
/**
* This testrunner checks for an {@link IgnorePlatform} annotation and ignores the test.
*
* @author Roland Praml, FOCONIS AG
*/
public class ConditionalTestRunner extends BlockJUnit4ClassRunner {
public ConditionalTestRunner(Class<?> klass) throws InitializationError {
super(klass);
}
@Override
public void runChild(FrameworkMethod method, RunNotifier notifier) {
ForPlatform forPlatform = method.getAnnotation(ForPlatform.class);
if (forPlatform != null) {
if (!platformMath(forPlatform.value())) {
notifier.fireTestIgnored(describeChild(method));
return;
}
}
IgnorePlatform ignore = method.getAnnotation(IgnorePlatform.class);
if (ignore == null || !platformMath(ignore.value())) {
super.runChild(method, notifier);
} else {
notifier.fireTestIgnored(describeChild(method));
}
}
private boolean platformMath(Platform[] platforms) {
Platform basePlatform = DB.getDefault().getPlatform().base();
for (Platform platform : platforms) {
if (platform.equals(basePlatform)) {
return true;
}
}
return false;
}
}
@@ -1,109 +0,0 @@
package io.ebean;
import io.ebean.util.StringHelper;
import org.junit.Test;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class StringHelperTest {
@Test
public void isNull() {
assertTrue(StringHelper.isNull(null));
assertTrue(StringHelper.isNull(""));
assertTrue(StringHelper.isNull(" "));
assertFalse(StringHelper.isNull("a"));
}
@Test
public void replaceString() {
assertEquals("sJmethJng", StringHelper.replace("somethong", "o","J"));
assertEquals("somethong", StringHelper.replace("somethong", "o", null));
assertNull(StringHelper.replace(null, "o","J"));
}
@Test
public void testSplitNames() {
assertThat(StringHelper.splitNames("")).hasSize(0);
assertThat(StringHelper.splitNames(" , ;")).hasSize(0);
assertThat(StringHelper.splitNames("foo bar")).containsExactly("foo", "bar");
assertThat(StringHelper.splitNames(" foo \n bar ")).containsExactly("foo", "bar");
assertThat(StringHelper.splitNames(" foo , bar ;")).containsExactly("foo", "bar");
assertThat(StringHelper.splitNames("foo, bar")).containsExactly("foo", "bar");
assertThat(StringHelper.splitNames("foo, bar baz")).containsExactly("foo", "bar", "baz");
assertThat(StringHelper.splitNames("foo, bar\nbaz")).containsExactly("foo", "bar", "baz");
}
@Test
public void removeNewLines() {
String content = "This is\na\rmultiline\r\ntext\n\r";
content = StringHelper.removeNewLines(content);
assertThat(content).isEqualTo("This is a multiline text ");
}
@Test
public void testDelimitedToMap() {
String content = "name1=blah; name2 = blubb ;name3\n=foo";
Map<String, String> map = StringHelper.delimitedToMap(content, ";", "=");
assertThat(map)
.containsEntry("name1", "blah")
.containsEntry("name2", " blubb ") // white space is not trimmed
.containsEntry("name3", "foo");
}
@Test
public void testDelimitedToMap_expect_trimLeading() {
String content = ";name1=foo;name2=bar;";
Map<String, String> map = StringHelper.delimitedToMap(content, ";", "=");
assertThat(map).hasSize(2)
.containsEntry("name1", "foo")
.containsEntry("name2", "bar");
}
@Test
public void testDelimitedToMap_when_emptyEntry() {
String content = ";name1=foo;=;name2=bar;";
Map<String, String> map = StringHelper.delimitedToMap(content, ";", "=");
assertThat(map).hasSize(2)
.containsEntry("name1", "foo")
.containsEntry("name2", "bar");
}
@Test
public void testDelimitedToMap_when_missingValue() {
String content = ";name1=foo;nameX;name2=bar;";
Map<String, String> map = StringHelper.delimitedToMap(content, ";", "=");
assertThat(map).hasSize(3)
.containsEntry("nameX", null)
.containsEntry("name1", "foo")
.containsEntry("name2", "bar");
}
@Test
public void testDelimitedToMap_when_missingValueAtEnd() {
String content = ";name1=foo;nameX;name2=bar;nameX2";
Map<String, String> map = StringHelper.delimitedToMap(content, ";", "=");
assertThat(map).hasSize(3)
.containsEntry("nameX", null)
.containsEntry("name1", "foo")
.containsEntry("name2", "bar");
}
@Test
public void testDelimitedToMap_when_null() {
Map<String, String> map = StringHelper.delimitedToMap(null, ";", "=");
assertThat(map).isEmpty();
}
@Test
public void testDelimitedToMap_when_empty() {
Map<String, String> map = StringHelper.delimitedToMap("", ";", "=");
assertThat(map).isEmpty();
}
}
@@ -1,135 +0,0 @@
package io.ebean.bean;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import org.tests.compositekeys.db.AuditInfo;
import org.tests.model.basic.Customer;
import org.tests.model.basic.EBasic;
import org.tests.model.basic.ResetBasicData;
import org.junit.Test;
import java.sql.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class EntityBeanInterceptTest extends BaseTestCase {
@Test
public void testHasDirtyProperty() {
ResetBasicData.reset();
List<Customer> list = DB.find(Customer.class).findList();
Set<String> propertyNames = new HashSet<>();
propertyNames.add("name");
propertyNames.add("status");
Customer customer = list.get(0);
EntityBeanIntercept ebi = ebi(customer);
assertFalse(ebi.hasDirtyProperty(propertyNames));
customer.setAnniversary(new Date(System.currentTimeMillis()));
assertFalse(ebi.hasDirtyProperty(propertyNames));
customer.setStatus(Customer.Status.ACTIVE);
assertTrue(ebi.hasDirtyProperty(propertyNames));
}
@Test
public void isPartial_when_new() {
EBasic basic = new EBasic();
EntityBeanIntercept ebi = ebi(basic);
assertThat(ebi.isPartial()).isTrue();
}
@Test
public void isPartial_when_partial() {
EBasic basic = new EBasic();
basic.setId(42);
basic.setName("some");
EntityBeanIntercept ebi = ebi(basic);
assertThat(ebi.isPartial()).isTrue();
}
@Test
public void isPartial_when_full() {
EBasic basic = new EBasic();
basic.setId(42);
basic.setName("some");
basic.setDescription("asd");
basic.setSomeDate(null);
basic.setStatus(EBasic.Status.ACTIVE);
EntityBeanIntercept ebi = ebi(basic);
assertThat(ebi.isPartial()).isFalse();
}
@Test
public void isEmbeddedNewOrDirty() {
AuditInfo auditInfo = new AuditInfo();
EntityBeanIntercept ebi = ebi(auditInfo);
assertTrue(ebi.isNew());
assertTrue(ebi.isEmbeddedNewOrDirty(auditInfo));
auditInfo.setUpdatedBy("initial");
ebi.setLoaded();
assertTrue(ebi.isLoaded());
assertFalse(ebi.isEmbeddedNewOrDirty(auditInfo));
auditInfo.setUpdatedBy("nowDirty");
assertTrue(ebi.isDirty());
assertTrue(ebi.isEmbeddedNewOrDirty(auditInfo));
assertFalse(ebi.isEmbeddedNewOrDirty(null));
}
@Test
public void setEmbeddedLoaded() {
AuditInfo auditInfo = new AuditInfo();
EntityBeanIntercept ebi = ebi(auditInfo);
assertFalse(ebi.isLoaded());
ebi.setEmbeddedLoaded(auditInfo);
assertTrue(ebi.isLoaded());
}
@Test
public void initialisedMany() {
Customer customer = new Customer();
EntityBeanIntercept ebi = ebi(customer);
final int contactsPos = findProperty("contacts", ebi);
assertFalse(ebi.isLoadedProperty(contactsPos));
ebi.initialisedMany(contactsPos);
assertTrue(ebi.isLoadedProperty(contactsPos));
}
private int findProperty(String name, EntityBeanIntercept eb) {
final String[] names = eb.getOwner()._ebean_getPropertyNames();
for (int i = 0; i < names.length; i++) {
if (names[i].equals(name)) {
return i;
}
}
throw new RuntimeException("property not found");
}
@SuppressWarnings("unchecked")
private EntityBeanIntercept ebi(Object bean) {
return ((EntityBean)bean)._ebean_getIntercept();
}
}
@@ -1,44 +0,0 @@
package io.ebean.config.dbplatform;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
public class DbIdentityTest {
@Test
public void getSelectLastInsertedId() {
DbIdentity identity = new DbIdentity();
identity.setSelectLastInsertedIdTemplate("lastid for {table}");
assertEquals("lastid for customer",identity.getSelectLastInsertedId("customer"));
assertEquals("lastid for contact",identity.getSelectLastInsertedId("contact"));
identity.setSelectLastInsertedIdTemplate("A{table}B{table}C");
assertEquals("AoneBoneC",identity.getSelectLastInsertedId("one"));
identity.setSelectLastInsertedIdTemplate("{table}A{table}");
assertEquals("oneAone",identity.getSelectLastInsertedId("one"));
}
@Test
public void getSelectLastInsertedId_when_null() {
DbIdentity identity = new DbIdentity();
assertNull(identity.getSelectLastInsertedId("customer"));
assertNull(identity.getSelectLastInsertedId("contact"));
}
@Test
public void getSelectLastInsertedId_when_noPlaceHolder() {
DbIdentity identity = new DbIdentity();
identity.setSelectLastInsertedIdTemplate("lastid");
assertEquals("lastid",identity.getSelectLastInsertedId("customer"));
assertEquals("lastid",identity.getSelectLastInsertedId("contact"));
}
}
@@ -1,35 +0,0 @@
package io.ebean.config.dbplatform;
import io.ebean.config.PlatformConfig;
import io.ebean.config.dbplatform.hana.HanaPlatform;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class HanaPlatformTest {
HanaPlatform platform = new HanaPlatform();
@Test
public void uuid_default() {
HanaPlatform platform = new HanaPlatform();
platform.configure(new PlatformConfig());
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("varchar(40)");
}
@Test
public void uuid_as_binary() {
HanaPlatform platform = new HanaPlatform();
PlatformConfig config = new PlatformConfig();
config.setDbUuid(PlatformConfig.DbUuid.AUTO_BINARY);
platform.configure(config);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("varbinary(16)");
}
}
@@ -1,34 +0,0 @@
package io.ebean.config.dbplatform;
import io.ebean.config.PlatformConfig;
import io.ebean.config.dbplatform.oracle.OraclePlatform;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class OraclePlatformTest {
@Test
public void uuid_default() {
OraclePlatform platform = new OraclePlatform();
platform.configure(new PlatformConfig(), false);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("varchar2(40)");
}
@Test
public void uuid_as_binary() {
OraclePlatform platform = new OraclePlatform();
PlatformConfig config = new PlatformConfig();
config.setDbUuid(PlatformConfig.DbUuid.AUTO_BINARY);
platform.configure(config, false);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("raw(16)");
}
}
@@ -1,23 +0,0 @@
package io.ebean.config.dbplatform;
import io.ebean.config.PlatformConfig;
import io.ebean.config.dbplatform.postgres.PostgresPlatform;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class PostgresPlatformTest {
@Test
public void testUuidType() {
PostgresPlatform platform = new PostgresPlatform();
platform.configure(new PlatformConfig(), false);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
String columnDefn = dbType.renderType(0, 0);
assertThat(columnDefn).isEqualTo("uuid");
}
}
@@ -1,46 +0,0 @@
package io.ebean.config.dbplatform;
import io.ebean.config.PlatformConfig;
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class SqlserverPlatformTest {
SqlServer17Platform platform = new SqlServer17Platform();
@Test
public void uuid_default() {
platform.configure(new PlatformConfig());
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("uniqueidentifier");
}
@Test
public void uuid_as_binary() {
PlatformConfig config = new PlatformConfig();
config.setDbUuid(PlatformConfig.DbUuid.BINARY);
platform.configure(config);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("binary(16)");
}
@Test
public void uuid_as_varchar() {
PlatformConfig config = new PlatformConfig();
config.setDbUuid(PlatformConfig.DbUuid.VARCHAR);
platform.configure(config);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("nvarchar(40)");
}
}
@@ -1,127 +0,0 @@
package io.ebeaninternal.server.cache;
import io.ebean.BaseTestCase;
import io.ebean.bean.EntityBean;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.server.deploy.BeanDescriptor;
import io.ebeaninternal.server.transaction.DefaultPersistenceContext;
import org.junit.Test;
import org.tests.model.basic.Address;
import org.tests.model.basic.Car;
import org.tests.model.basic.Contact;
import org.tests.model.basic.Customer;
import java.sql.Date;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
public class CachedBeanDataFromBeanTest extends BaseTestCase {
private final SpiEbeanServer server = spiEbeanServer();
@Test
public void extract() {
BeanDescriptor<Customer> desc = server.getBeanDescriptor(Customer.class);
Date largeDate = new Date(9223372036825200000L);
Customer customer = new Customer();
customer.setId(42);
customer.setName("Rob");
customer.setAnniversary(largeDate);
Address billingAddress = new Address();
billingAddress.setId(12);
billingAddress.setCity("SomePlace");
customer.setBillingAddress(billingAddress);
CachedBeanData cacheData = CachedBeanDataFromBean.extract(desc, (EntityBean) customer);
assertEquals(cacheData.getData("id"), "42");
assertEquals(cacheData.getData("name"), "Rob");
assertEquals(cacheData.getData("billingAddress"), "12");
assertEquals(cacheData.getData("anniversary"), "9223372036825200000");
}
@Test
public void inheritance() {
Car car = new Car();
car.setId(42);
car.setDriver("Jimmy");
car.setNotes("some notes");
BeanDescriptor<Car> carDesc = server.getBeanDescriptor(Car.class);
CachedBeanData cacheData = CachedBeanDataFromBean.extract(carDesc, (EntityBean) car);
Car newCar = new Car();
EntityBean entityBean = (EntityBean) newCar;
CachedBeanDataToBean.load(carDesc, entityBean, cacheData, new DefaultPersistenceContext());
assertEquals(newCar.getId(), car.getId());
assertEquals(newCar.getDriver(), car.getDriver());
assertEquals(newCar.getNotes(), car.getNotes());
}
@SuppressWarnings("unchecked")
@Test
public void dirtyScalar_expect_originalValueUsed() {
Contact contact = new Contact();
contact.setId(42);
contact.setLastName("Bygrave");
contact.setFirstName("Foo");
contact.setEmail("rob@email.com");
EntityBean entityBean = (EntityBean)contact;
entityBean._ebean_getIntercept().setLoaded();
// mutate, dirty
contact.setLastName("Banana");
final BeanDescriptor<Contact> desc = getBeanDescriptor(Contact.class);
CachedBeanData cacheData = CachedBeanDataFromBean.extract(desc, entityBean);
final Map<String, Object> data = cacheData.getData();
assertThat(data.get("id")).isEqualTo("42");
assertThat(data.get("lastName")).isEqualTo("Bygrave"); // ORIGINAL VALUE
assertThat(data.get("firstName")).isEqualTo(contact.getFirstName());
assertThat(data.get("email")).isEqualTo(contact.getEmail());
}
@Test
public void dirtyManyToOne_expect_originalValueUsed() {
Customer customer = new Customer();
customer.setId(99);
Contact contact = new Contact();
contact.setFirstName("Foo");
contact.setLastName("Bygrave");
contact.setEmail("rob@email.com");
contact.setCustomer(customer);
EntityBean entityBean = (EntityBean)contact;
entityBean._ebean_getIntercept().setLoaded();
// mutate, dirty
Customer customer2 = new Customer();
customer2.setId(108);
contact.setCustomer(customer2);
contact.setLastName("Banana");
final BeanDescriptor<Contact> desc = getBeanDescriptor(Contact.class);
CachedBeanData cacheData = CachedBeanDataFromBean.extract(desc, entityBean);
final Map<String, Object> data = cacheData.getData();
assertThat(data.get("lastName")).isEqualTo("Bygrave"); // Original value
assertThat(data.get("customer")).isEqualTo("99"); // Original value
assertThat(data.get("firstName")).isEqualTo(contact.getFirstName());
assertThat(data.get("email")).isEqualTo(contact.getEmail());
}
}
@@ -1,22 +0,0 @@
package io.ebeaninternal.server.core;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class DtoQueryRequestTest {
@Test
public void testParse() {
assertEquals("foo", DtoQueryRequest.parseColumn("foo"));
assertEquals("bar", DtoQueryRequest.parseColumn("_e_t0_bar"));
assertEquals("BAR", DtoQueryRequest.parseColumn("_E_T0_BAR"));
assertEquals("baz", DtoQueryRequest.parseColumn("_e_t42_baz"));
assertEquals("BAZ", DtoQueryRequest.parseColumn("_E_T42_BAZ"));
assertEquals("e_t42_nope", DtoQueryRequest.parseColumn("e_t42_nope"));
assertEquals("_f_t42_nope", DtoQueryRequest.parseColumn("_f_t42_nope"));
}
}
@@ -1,124 +0,0 @@
package io.ebeaninternal.server.core;
import io.ebean.config.ServerConfig;
import io.ebean.datasource.DataSourceConfig;
import org.junit.Test;
import static org.junit.Assert.*;
public class InitDataSourceTest {
private ServerConfig newConfig(String readOnlyUrl) {
ServerConfig config = new ServerConfig();
DataSourceConfig roConfig = new DataSourceConfig();
roConfig.setUrl(readOnlyUrl);
config.setReadOnlyDataSourceConfig(roConfig);
return config;
}
@Test
public void readOnlyConfig_nullByDefault() {
InitDataSource init = new InitDataSource(new ServerConfig());
assertNull(init.readOnlyConfig());
}
@Test
public void readOnlyConfig_null_whenSetNullExplicitly() {
ServerConfig config = new ServerConfig();
config.setReadOnlyDataSourceConfig(null);
assertNull(new InitDataSource(config).readOnlyConfig());
}
@Test
public void readOnlyConfig_null_whenSetNullExplicitly_2() {
assertNull(new InitDataSource(newConfig(null)).readOnlyConfig());
assertNull(new InitDataSource(newConfig("")).readOnlyConfig());
assertNull(new InitDataSource(newConfig(" ")).readOnlyConfig());
}
@Test
public void readOnlyConfig_null_whenValueNONE() {
assertNull(new InitDataSource(newConfig("none")).readOnlyConfig());
assertNull(new InitDataSource(newConfig("None")).readOnlyConfig());
assertNull(new InitDataSource(newConfig("NONE")).readOnlyConfig());
}
@Test
public void readOnlyConfig_when_autoReadOnlyDataSource() {
ServerConfig config = new ServerConfig();
config.setAutoReadOnlyDataSource(true);
assertNotNull(new InitDataSource(config).readOnlyConfig());
}
@Test
public void readOnlyConfig_when_autoReadOnlyDataSource_expect_setToNull() {
ServerConfig config = newConfig("none");
config.setAutoReadOnlyDataSource(true);
final DataSourceConfig readOnlyConfig = new InitDataSource(config).readOnlyConfig();
assertNull(readOnlyConfig.getUrl());
}
@Test
public void readOnlyConfig_when_urlSet() {
ServerConfig config = newConfig("foo");
final DataSourceConfig roConfig = new InitDataSource(config).readOnlyConfig();
assertNotNull(roConfig);
assertEquals("foo", roConfig.getUrl());
}
@Test
public void readOnlyConfig_when_readOnlyUrlSetOnMain() {
ServerConfig config = newConfig(null);
// alternate location to set read-only url for developer convenience
config.getDataSourceConfig().setReadOnlyUrl("bar");
final DataSourceConfig roConfig = new InitDataSource(config).readOnlyConfig();
assertNotNull(roConfig);
assertEquals("bar", roConfig.getUrl());
}
@Test
public void readOnlyConfig_when_readOnlyUrlSetOnMain_withNone() {
ServerConfig config = newConfig("None");
// alternate location to set read-only url for developer convenience
config.getDataSourceConfig().setReadOnlyUrl("bar");
final DataSourceConfig roConfig = new InitDataSource(config).readOnlyConfig();
assertNotNull(roConfig);
assertEquals("bar", roConfig.getUrl());
}
@Test
public void readOnlyConfig_when_bothReadOnlyUrlsSet() {
ServerConfig config = newConfig("one");
config.getDataSourceConfig().setReadOnlyUrl("two");
final DataSourceConfig roConfig = new InitDataSource(config).readOnlyConfig();
assertNotNull(roConfig);
assertEquals("one", roConfig.getUrl());
}
@Test
public void readOnlyConfig_when_readOnlyUrlSetOnMain_withNoneNone() {
ServerConfig config = newConfig("none");
// alternate location to set read-only url for developer convenience
config.getDataSourceConfig().setReadOnlyUrl("none");
final DataSourceConfig roConfig = new InitDataSource(config).readOnlyConfig();
assertNull(roConfig);
}
@Test
public void readOnlyConfig_when_urlSet_2() {
ServerConfig config = new ServerConfig();
config.getReadOnlyDataSourceConfig().setUrl("foo");
final DataSourceConfig roConfig = new InitDataSource(config).readOnlyConfig();
assertNotNull(roConfig);
assertEquals("foo", roConfig.getUrl());
}
}
@@ -1,120 +0,0 @@
package io.ebeaninternal.server.dto;
import org.junit.Test;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
public class DtoMetaBuilderTest {
@Test
public void includeMethod() {
Map<String, Method> methods = getIncludedMethodsFor(D0.class);
assertThat(methods).hasSize(2);
assertThat(methods.get("setName")).isNotNull();
assertThat(methods.get("setId")).isNotNull();
}
@Test
public void includeMethod_when_notStrictlySetters() {
Map<String, Method> methods = getIncludedMethodsFor(D1.class);
assertThat(methods).hasSize(3);
assertThat(methods.get("setNameThen")).isNotNull();
assertThat(methods.get("setIdFor")).isNotNull();
assertThat(methods.get("setI")).isNotNull();
}
@Test
public void propertyType() {
Map<String, Method> methods = getIncludedMethodsFor(D0.class);
assertThat(methods).hasSize(2);
assertThat(DtoMetaBuilder.propertyType(methods.get("setName"))).isEqualTo(String.class);
assertThat(DtoMetaBuilder.propertyType(methods.get("setId"))).isEqualTo(long.class);
}
@Test
public void propertyName() {
assertThat(DtoMetaBuilder.propertyName("setName")).isEqualTo("name");
assertThat(DtoMetaBuilder.propertyName("setId")).isEqualTo("id");
assertThat(DtoMetaBuilder.propertyName("setI")).isEqualTo("i");
assertThat(DtoMetaBuilder.propertyName("setfoo")).isEqualTo("foo");
}
private Map<String, Method> getIncludedMethodsFor(Class<?> cls) {
Map<String,Method> included = new HashMap<>();
for (Method method : cls.getMethods()) {
if (DtoMetaBuilder.includeMethod(method)) {
included.put(method.getName(), method);
}
}
return included;
}
@SuppressWarnings("unused")
static class D0 {
private String name;
private long id;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setId(long id) {
this.id = id;
}
public void setNamePlus(String name, long id) {
this.name = name;
this.id = id;
}
public static void setFoo(String foo) {
}
protected void setProtected(String foo) {
}
private void setPrivate(String foo) {
}
private void setPackage(String foo) {
}
}
@SuppressWarnings("unused")
static class D1 {
public void setNameThen(String name) {
}
public void setIdFor(long id) {
}
public void setI(long val) {
}
public void set(long val) {
}
public D1 setA(long val) {
return this;
}
}
}
@@ -1,29 +0,0 @@
package io.ebeaninternal.server.query;
import io.ebeaninternal.api.SpiQuery;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class SqlTreeAliasTest {
@Test
public void parseRootAlias_when_rootAliasIsNull() {
SqlTreeAlias treeAlias = new SqlTreeAlias(null, SpiQuery.TemporalMode.CURRENT);
assertEquals("A B", treeAlias.parseRootAlias("${}A ${}B"));
assertEquals("ABC", treeAlias.parseRootAlias("A${}B${}C"));
}
@Test
public void parseRootAlias_when_rootAliasHasValue() {
SqlTreeAlias treeAlias = new SqlTreeAlias("t0", SpiQuery.TemporalMode.CURRENT);
assertEquals("t0.A t0.B", treeAlias.parseRootAlias("${}A ${}B"));
assertEquals("At0.Bt0.C", treeAlias.parseRootAlias("A${}B${}C"));
}
}
@@ -1,14 +0,0 @@
package io.ebeaninternal.server.querydefn;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class OrmUpdatePropertiesTest {
@Test
public void trim() {
assertEquals("ship_id", OrmUpdateProperties.trim("${}ship_id"));
assertEquals("(ship_id)", OrmUpdateProperties.trim("(${}ship_id)"));
}
}
@@ -1,263 +0,0 @@
package io.ebeaninternal.server.transaction;
import io.ebean.bean.PersistenceContext;
import io.ebeaninternal.server.deploy.PersistenceContextUtil;
import org.junit.Test;
import org.tests.model.basic.Car;
import org.tests.model.basic.Contact;
import org.tests.model.basic.Customer;
import org.tests.model.basic.Product;
import org.tests.model.basic.Vehicle;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class DefaultPersistenceContextTest {
private final Customer customer42;
private final Car car1;
public DefaultPersistenceContextTest() {
customer42 = new Customer();
customer42.setId(42);
car1 = new Car();
car1.setId(1);
}
private DefaultPersistenceContext pc() {
return new DefaultPersistenceContext();
}
private DefaultPersistenceContext pcWith42() {
DefaultPersistenceContext pc = pc();
pc.put(Customer.class, 42, customer42);
return pc;
}
Class<?> root(Class<?> cls) {
return PersistenceContextUtil.root(cls);
}
@Test
public void put_get_withInheritance() {
PersistenceContext pc = pc();
pc.put(root(Vehicle.class), 1, car1);
Object found = pc.get(root(Car.class), 1);
assertThat(found).isSameAs(car1);
}
@Test
public void put_get() {
PersistenceContext pc = pc();
pc.put(Customer.class, customer42.getId(), customer42);
Object found = pc.get(Customer.class, 42);
assertThat(found).isSameAs(customer42);
}
@Test
public void putIfAbsent_when_absent() {
PersistenceContext pc = pc();
Object existing = pc.putIfAbsent(Customer.class, customer42.getId(), customer42);
assertThat(existing).isNull();
}
@Test
public void putIfAbsent_when_notAbsent() {
PersistenceContext pc = pcWith42();
Object existing = pc.putIfAbsent(Customer.class, customer42.getId(), new Customer());
assertThat(existing).isSameAs(customer42);
}
@Test
public void get_when_empty() {
PersistenceContext pc = pc();
Object found = pc.get(Customer.class, 42);
assertThat(found).isNull();
}
@Test
public void get_when_there() {
PersistenceContext pc = pcWith42();
Object found = pc.get(Customer.class, 42);
assertThat(found).isSameAs(customer42);
}
@Test
public void getWithOption_when_empty() {
PersistenceContext pc = pc();
PersistenceContext.WithOption withOption = pc.getWithOption(Customer.class, 42);
assertThat(withOption).isNull();
}
@Test
public void getWithOption_when_there() {
PersistenceContext pc = pcWith42();
PersistenceContext.WithOption withOption = pc.getWithOption(Customer.class, 42);
assertThat(withOption.getBean()).isSameAs(customer42);
}
@Test
public void getWithOption_when_deleted() {
PersistenceContext pc = pcWith42();
pc.deleted(Customer.class, 42);
PersistenceContext.WithOption withOption = pc.getWithOption(Customer.class, 42);
assertThat(withOption.isDeleted()).isTrue();
assertThat(withOption.getBean()).isNull();
}
@Test
public void size_when_empty() {
PersistenceContext pc = pc();
assertThat(pc.size(Customer.class)).isEqualTo(0);
}
@Test
public void size_when_some() {
PersistenceContext pc = pcWith42();
assertThat(pc.size(Customer.class)).isEqualTo(1);
}
@Test
public void clear() {
PersistenceContext pc = pcWith42();
pc.clear();
assertThat(pc.size(Customer.class)).isEqualTo(0);
}
@Test
public void clearClass() {
PersistenceContext pc = pcWith42();
pc.clear(Customer.class);
assertThat(pc.size(Customer.class)).isEqualTo(0);
}
@Test
public void clearClassAndId() {
PersistenceContext pc = pcWith42();
pc.put(Customer.class, 43, new Customer());
pc.clear(Customer.class, 42);
assertThat(pc.size(Customer.class)).isEqualTo(1);
pc.clear(Customer.class, 43);
assertThat(pc.size(Customer.class)).isEqualTo(0);
}
@Test
public void forIterate() {
final DefaultPersistenceContext pc = pcWith42();
final Object origCustomer42 = pc.get(Customer.class, 42);
// act
final PersistenceContext pcIterate = pc.forIterate();
assertThat(pc).isNotSameAs(pcIterate);
assertThat(pcIterate.size(Customer.class)).isEqualTo(1);
// assert same instance (bean effectively transferred to iterator persistence context
final Object customer42 = pcIterate.get(Customer.class, 42);
assertThat(customer42).isSameAs(origCustomer42);
final PersistenceContext.WithOption option = pcIterate.getWithOption(Customer.class, 42);
assertThat(option.getBean()).isSameAs(origCustomer42);
}
@Test
public void forIterate_many() {
DefaultPersistenceContext pc = new DefaultPersistenceContext();
addCustomers(pc, 1, 100);
addContacts(pc, 1, 1010);
assertThat(pc.size(Customer.class)).isEqualTo(100);
assertThat(pc.size(Contact.class)).isEqualTo(1010);
// act
final PersistenceContext pcIterate = pc.forIterate();
assertThat(pcIterate.size(Customer.class)).isEqualTo(100);
assertThat(pcIterate.size(Contact.class)).isEqualTo(1010);
}
@Test
public void forIterate_resetLimit_forIterateReset() {
DefaultPersistenceContext initialPc = new DefaultPersistenceContext();
addCustomers(initialPc, 1, 100);
addContacts(initialPc, 1, 1010);
final PersistenceContext pcIterate = initialPc.forIterate();
assertFalse(pcIterate.resetLimit());
// added 900 NEW contact beans
addContacts(pcIterate, 2000, 900);
assertThat(pcIterate.size(Contact.class)).isEqualTo(1910);
assertFalse(pcIterate.resetLimit());
// boundary, added 1000 NEW contact beans (still false)
addContacts(pcIterate, 3000, 100);
assertFalse(pcIterate.resetLimit());
addContacts(pcIterate, 4000, 1);
addProducts(pcIterate, 1, 100);
// ACT - over 1000 added beans boundary for contacts so returns true
assertTrue(pcIterate.resetLimit());
assertThat(pcIterate.size(Contact.class)).isEqualTo(2011);
assertThat(pcIterate.size(Customer.class)).isEqualTo(100);
assertThat(pcIterate.size(Product.class)).isEqualTo(100);
// ACT - obtain new PC forIterateReset
PersistenceContext pcReset = pcIterate.forIterateReset();
// keeps original customer beans as no new added beans there
assertThat(pcReset.size(Customer.class)).isEqualTo(100); // customers didn't change
// added beans to contacts and products so those where reset
assertThat(pcReset.size(Contact.class)).isEqualTo(0);
assertThat(pcReset.size(Product.class)).isEqualTo(0);
}
@Test
public void toString_sillyTest() {
DefaultPersistenceContext pc = pcWith42();
assertThat(pc.toString()).contains("org.tests.model.basic.Customer");
}
private void addCustomers(PersistenceContext pc, int start, int loop) {
for (int i = start; i < start + loop; i++) {
Customer bean = new Customer();
bean.setId(i);
pc.put(Customer.class, i, bean);
}
}
private void addContacts(PersistenceContext pc, int start, int loop) {
for (int i = start; i < start + loop; i++) {
Contact bean = new Contact();
bean.setId(i);
pc.put(Contact.class, i, bean);
}
}
private void addProducts(PersistenceContext pc, int start, int loop) {
for (int i = start; i < start + loop; i++) {
Product bean = new Product();
bean.setId(i);
pc.put(Product.class, i, bean);
}
}
}
@@ -1,18 +0,0 @@
package main;
import io.ebean.docker.commands.MariaDBConfig;
import io.ebean.docker.commands.MariaDBContainer;
public class StartMariaDb {
public static void main(String[] args) {
MariaDBConfig config = new MariaDBConfig("10.5");
config.setDbName("unit");
config.setUser("unit");
config.setPassword("unit");
MariaDBContainer container = new MariaDBContainer(config);
container.startWithDropCreate();
}
}
@@ -1,63 +0,0 @@
package org.tests.basic;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import org.junit.Test;
import org.tests.model.basic.Article;
import org.tests.model.basic.Section;
import org.tests.model.basic.SubSection;
import static org.assertj.core.api.Assertions.assertThat;
public class TestDeleteCascadingOneToMany extends BaseTestCase {
@Test
public void testDeleteCascadingOneToMany() {
Section s0 = new Section("some content");
Article a0 = new Article("art1", "auth1");
a0.addSection(s0);
DB.save(a0);
DB.delete(a0);
}
@Test
public void l2cache_updateBeanOnly_expect_doesNotUpdateManyIds() {
// setup, create our graph - Bean -> OneToMany -> OneToMany
Section s0 = new Section("c0");
s0.getSubSections().add(new SubSection("sub0"));
Article a0 = new Article("a2", "a2");
a0.getSections().add(s0);
DB.save(a0);
// load into l2 bean cache
final Article bean0 = DB.find(Article.class, a0.getId());
for (Section section : bean0.getSections()) {
section.getSubSections().size(); // ensure the collections are loaded into l2 cache
}
// mutate the manyIds associated with the bean
final Article bean1 = DB.find(Article.class, a0.getId());
final Section section1 = bean1.getSections().get(0);
section1.getSubSections().clear(); // orphan remove will delete sub0 - this is cause of EntityNotFoundException: Bean not found during lazy load or refresh
section1.getSubSections().add(new SubSection("sub-replacement"));
DB.save(bean1);
bean0.setName("a2mod");
// save bean but we have not mutated the collections
// should NOT update the l2 manyIds (Bug will PUT the original manyIds into l2 COLL cache)
DB.save(bean0);
// fetch again hitting l2 cache
final Article beanLast = DB.find(Article.class, a0.getId());
// invoke lazy loading - hits l2 cache and get the expected result
for (Section section : beanLast.getSections()) {
for (SubSection subSection : section.getSubSections()) {
assertThat(subSection.getTitle()).isEqualTo("sub-replacement");
}
}
}
}
@@ -1,68 +0,0 @@
package org.tests.cache;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebeantest.LoggedSql;
import org.junit.Test;
import org.tests.model.basic.Contact;
import org.tests.model.basic.Customer;
import java.sql.Date;
import java.time.LocalDate;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Test class testing a wrong behaviour of the bean cache.
*/
public class TestBeanCacheContactLazyLoad extends BaseTestCase {
/**
* This test shows a wrong behaviour of the bean cache up to at least Ebean 12.4.*:
* <ul>
* <li>bean partially fetched via natural key, filling the cache</li>
* <li>bean modified using a setter</li>
* <li>getter called on non-loaded property to trigger lazy load</li>
* <li>bean fetched again using the same natural key, to hit cache</li>
* <li>it is expected, that the fetched bean does not contain the modification from before</li>
* </ul>
*/
@Test
public void testBeanCacheWithLazyLoading() {
final Customer customer = new Customer();
customer.setName("Customer");
customer.setAnniversary(Date.valueOf(LocalDate.of(2010, 1, 1)));
DB.save(customer);
final Contact contact = new Contact();
contact.setFirstName("Tim");
contact.setLastName("Button");
contact.setPhone("1234567890");
contact.setMobile("4567890123");
contact.setEmail("tim@button.com");
contact.setCustomer(customer);
DB.save(contact);
// Only get two properties, so we have to lazy-load later
final Contact contactDb = DB.find(Contact.class).where().eq("email", "tim@button.com").select("email,lastName").findOne();
assertThat(contactDb).isNotNull();
LoggedSql.start();
contactDb.setLastName("Buttonnnn");
List<String> sql = LoggedSql.collect();
assertThat(sql).isEmpty(); // setter did not trigger lazy load
// trigger lazy load
assertThat(contactDb.getPhone()).isEqualTo("1234567890");
sql = LoggedSql.collect();
assertThat(sql).isNotEmpty(); // Lazy-load took place
final Contact contactDb2 = DB.find(Contact.class).where().eq("email", "tim@button.com").select("email,lastName").findOne();
sql = LoggedSql.stop();
assertThat(sql).isEmpty(); // We expect that the bean was loaded from cache
assertThat(contactDb2).isNotNull();
assertThat(contactDb2.getLastName()).isEqualTo("Button");
}
}
@@ -1,48 +0,0 @@
package org.tests.defaultvalues;
import io.ebean.annotation.Draft;
import io.ebean.annotation.Draftable;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import java.util.List;
@Entity
@Draftable
public class DefaultsModel {
@Id
Integer id;
@Draft
boolean draft;
@OneToMany(cascade = CascadeType.ALL)
List<ReferencedDefaultsModel> relatedModels;
public Integer getId() {
return id;
}
public void setId(final Integer id) {
this.id = id;
}
public List<ReferencedDefaultsModel> getRelatedModels() {
return relatedModels;
}
public void setRelatedModels(final List<ReferencedDefaultsModel> relatedModels) {
this.relatedModels = relatedModels;
}
public boolean isDraft() {
return draft;
}
public void setDraft(final boolean draft) {
this.draft = draft;
}
}
@@ -1,44 +0,0 @@
package org.tests.defaultvalues;
import io.ebean.annotation.Draft;
import io.ebean.annotation.Draftable;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
@Draftable
public class ReferencedDefaultsModel {
@Id
Integer id;
String name;
@Draft
boolean draft;
public Integer getId() {
return id;
}
public void setId(final Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public boolean isDraft() {
return draft;
}
public void setDraft(final boolean draft) {
this.draft = draft;
}
}
@@ -1,38 +0,0 @@
package org.tests.defaultvalues;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import org.ebeantest.LoggedSqlCollector;
import org.junit.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class TestDefaults extends BaseTestCase {
@Test
public void testInsertDefaultValues() {
final DefaultsModel main = new DefaultsModel();
for (int i = 0; i < 5; i++) {
final ReferencedDefaultsModel ref = new ReferencedDefaultsModel();
ref.setName("r" + i);
main.getRelatedModels().add(ref);
}
LoggedSqlCollector.start();
Ebean.save(main);
final List<String> current = LoggedSqlCollector.current();
assertThat(current).isNotEmpty();
if (isMySql() || isMariaDB()) {
assertThat(current.get(0)).contains("insert into defaults_model_draft values (default);");
} else if (isSqlServer()) {
assertThat(current.get(0)).contains("insert into defaults_model_draft (id) values (?)");
} else {
assertThat(current.get(0)).contains("insert into defaults_model_draft default values;");
}
}
}
@@ -1,70 +0,0 @@
package org.tests.inheritance;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import io.ebeantest.LoggedSql;
import org.ebeantest.LoggedSqlCollector;
import org.junit.Test;
import org.tests.inheritance.order.OrderMasterInheritance;
import org.tests.inheritance.order.OrderedA;
import org.tests.inheritance.order.OrderedB;
import org.tests.inheritance.order.OrderedParent;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class TestInheritanceOrderColumn extends BaseTestCase {
@Test
public void test() {
final OrderMasterInheritance master = new OrderMasterInheritance();
final OrderedA orderedA = new OrderedA();
orderedA.setCommonName("commonOrderedA");
orderedA.setOrderedAName("orderedA");
final OrderedB orderedB = new OrderedB();
orderedB.setCommonName("commonOrderedB");
orderedB.setOrderedBName("orderedB");
master.getReferenced().add(orderedA);
master.getReferenced().add(orderedB);
LoggedSqlCollector.start();
Ebean.save(master);
List<String> sql = LoggedSqlCollector.stop();
assertThat(sql).hasSize(5);
// Some platforms insert ids and others don't need to...
assertSql(trimId(sql, 1))
.contains("insert into ordered_parent (order_master_inheritance_id, dtype, common_name, ordered_aname, sort_order) values");
assertSql(trimId(sql, 3))
.contains("insert into ordered_parent (order_master_inheritance_id, dtype, common_name, ordered_bname, sort_order) values");
OrderMasterInheritance result = Ebean.find(OrderMasterInheritance.class).findOne();
assertThat(result.getReferenced())
.extracting(OrderedParent::getCommonName)
.containsExactly("commonOrderedA", "commonOrderedB");
// Swap the two
result.getReferenced().add(0, result.getReferenced().remove(1));
assertThat(result.getReferenced())
.extracting(OrderedParent::getCommonName)
.containsExactly("commonOrderedB", "commonOrderedA");
LoggedSql.start();
Ebean.save(result);
sql = LoggedSqlCollector.stop();
assertThat(sql).hasSize(3);
assertThat(sql.get(0)).contains("update ordered_parent set sort_order=? where id=?");
result = Ebean.find(OrderMasterInheritance.class).findOne();
assertThat(result.getReferenced())
.extracting(OrderedParent::getCommonName)
.containsExactly("commonOrderedB", "commonOrderedA");
}
private String trimId(List<String> sql, int i) {
return sql.get(i).replace("(id, ", "(");
}
}
@@ -1,19 +0,0 @@
package org.tests.inheritance.cache;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
@Entity
public class CIAddress extends CIBaseModel {
@ManyToOne
public CIStreetParent street;
public CIStreetParent getStreet() {
return street;
}
public void setStreet(CIStreetParent street) {
this.street = street;
}
}
@@ -1,23 +0,0 @@
package org.tests.inheritance.cache;
import io.ebean.Model;
import io.ebean.annotation.Cache;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
@Cache(enableQueryCache=true)
@MappedSuperclass
public abstract class CIBaseModel extends Model {
@Id
protected long id;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
}
@@ -1,19 +0,0 @@
package org.tests.inheritance.cache;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
@Entity
@DiscriminatorValue(value="1")
public class CICustomer extends CICustomerParent {
public String notes;
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
}
@@ -1,27 +0,0 @@
package org.tests.inheritance.cache;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "dtype", discriminatorType = DiscriminatorType.INTEGER)
@DiscriminatorValue(value = "0")
public class CICustomerParent extends CIBaseModel {
@ManyToOne
protected CIAddress address;
public CIAddress getAddress() {
return address;
}
public void setAddress(CIAddress adress) {
this.address = adress;
}
}
@@ -1,23 +0,0 @@
package org.tests.inheritance.cache;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "street")
@DiscriminatorValue(value = "1")
public class CIStreet extends CIStreetParent {
@Column(name="num")
protected String number;
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
}
@@ -1,25 +0,0 @@
package org.tests.inheritance.cache;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "dtype", discriminatorType = DiscriminatorType.INTEGER)
@DiscriminatorValue(value = "0")
public class CIStreetParent extends CIBaseModel {
protected String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -1,63 +0,0 @@
package org.tests.inheritance.cache;
import io.ebean.DB;
import org.junit.Assert;
import org.junit.Test;
public class TestInheritCacheRefLoad {
@Test
public void findWithRefToInheritStreetBean_expect_correctStreetType() {
DB.find(CICustomerParent.class).delete();
DB.find(CIAddress.class).delete();
DB.find(CIStreet.class).delete();
//=========================================================================
// 1 - Create Data (Customer(dtype 1) -> Address(no dtype) -> Street(dtype 1)
//=========================================================================
CIStreet street = new CIStreet();
street.save();
CIAddress address = new CIAddress();
address.setStreet(street);
address.save();
CICustomer customer = new CICustomer();
customer.setAddress(address);
customer.save();
//=========================================================================
// 2 - Read Data (no Cache Hit)
//=========================================================================
Class streetClass = reloadCustomer(customer, false); //returns Street -> OK
Assert.assertEquals("org.tests.inheritance.cache.CIStreet", streetClass.getName());
streetClass = reloadCustomer(customer, false); //returns Street -> OK
Assert.assertEquals("org.tests.inheritance.cache.CIStreet", streetClass.getName());
//=========================================================================
// 3 - Read Data (L2-Cache Hit)
//=========================================================================
streetClass = reloadCustomer(customer, true); //returns Street -> OK
Assert.assertEquals("org.tests.inheritance.cache.CIStreet", streetClass.getName());
streetClass = reloadCustomer(customer, true); //returns StreetParent -> NOT OK
Assert.assertEquals("org.tests.inheritance.cache.CIStreet", streetClass.getName());
}
public Class reloadCustomer(CICustomer customer, boolean l2Cache) {
// Load Customer via Query, L2Cache on/off
CICustomer customerReloaded =
DB.find(CICustomer.class)
.where().eq("id", customer.getId())
.setUseCache(l2Cache)
.findOne();
//Access Street by lazy Loading
Class streetClassLazyLoaded = customerReloaded.getAddress().getStreet().getClass();
//Show Cache Hits
System.out.println("Class of Street (Cache on: " + l2Cache + "): " + streetClassLazyLoaded + " | Cache Hit: " + DB.getDefault().getServerCacheManager().getQueryCache(streetClassLazyLoaded).getStatistics(false).getHitCount());
return streetClassLazyLoaded;
}
}
@@ -1,64 +0,0 @@
package org.tests.inheritance.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import java.util.List;
@Entity
public class Configurations {
@Id
@Column(name = "id")
private Integer id;
private String name;
@OneToMany
private List<GroupConfiguration> groupConfigurations;
@OneToMany
private List<ProductConfiguration> productConfigurations;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<GroupConfiguration> getGroupConfigurations() {
return groupConfigurations;
}
public void setGroupConfigurations(List<GroupConfiguration> groupConfigurations) {
this.groupConfigurations = groupConfigurations;
}
public void addGroupConfiguration(GroupConfiguration groupConfiguration) {
groupConfiguration.setConfigurations(this);
groupConfigurations.add(groupConfiguration);
}
public List<ProductConfiguration> getProductConfigurations() {
return productConfigurations;
}
public void setProductConfigurations(List<ProductConfiguration> productConfigurations) {
this.productConfigurations = productConfigurations;
}
public void addProductConfiguration(ProductConfiguration productConfiguration) {
productConfiguration.setConfigurations(this);
productConfigurations.add(productConfiguration);
}
}
@@ -1,36 +0,0 @@
package org.tests.inheritance.order;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OrderColumn;
import java.util.ArrayList;
import java.util.List;
@Entity
public class OrderMasterInheritance {
@Id
Integer id;
@OneToMany(cascade = CascadeType.ALL)
@OrderColumn(name = "sort_order")
List<OrderedParent> referenced = new ArrayList<>();
public Integer getId() {
return id;
}
public void setId(final Integer id) {
this.id = id;
}
public List<OrderedParent> getReferenced() {
return referenced;
}
public void setReferenced(final List<OrderedParent> referenced) {
this.referenced = referenced;
}
}
@@ -1,17 +0,0 @@
package org.tests.inheritance.order;
import javax.persistence.Entity;
@Entity
public class OrderedA extends OrderedParent {
String orderedAName;
public String getOrderedAName() {
return orderedAName;
}
public void setOrderedAName(final String orderedAName) {
this.orderedAName = orderedAName;
}
}
@@ -1,17 +0,0 @@
package org.tests.inheritance.order;
import javax.persistence.Entity;
@Entity
public class OrderedB extends OrderedParent {
String orderedBName;
public String getOrderedBName() {
return orderedBName;
}
public void setOrderedBName(final String orderedBName) {
this.orderedBName = orderedBName;
}
}
@@ -1,31 +0,0 @@
package org.tests.inheritance.order;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
@Entity
@Inheritance
public abstract class OrderedParent {
@Id
Integer id;
String commonName;
public Integer getId() {
return id;
}
public void setId(final Integer id) {
this.id = id;
}
public String getCommonName() {
return commonName;
}
public void setCommonName(final String commonName) {
this.commonName = commonName;
}
}
@@ -1,16 +0,0 @@
package org.tests.model.aggregation;
import javax.persistence.Column;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Example meta annotation for <code>@Column</code>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Column(precision = 9, scale = 3)
public @interface Decimal93 {
}
@@ -1,71 +0,0 @@
package org.tests.model.basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.List;
@Entity(name = "Person")
@Table(name = "PERSONS")
public class Person implements Serializable {
private static final long serialVersionUID = 495045977245770183L;
@Id
@GeneratedValue(strategy = javax.persistence.GenerationType.AUTO)
@SequenceGenerator(name = "PERSONS_SEQ", initialValue = 1000, allocationSize = 40)
@Column(name = "ID", unique = true, nullable = false)
private Long id;
@Column(name = "SURNAME", nullable = false, unique = false, columnDefinition = "varchar(64)")
private String surname;
@Column(name = "NAME", nullable = false, unique = false, columnDefinition = "varchar(64)")
private String name;
@OneToMany(targetEntity = Phone.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "person")
private List<Phone> phones;
public Person() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Phone> getPhones() {
return phones;
}
public void setPhones(List<Phone> phones) {
this.phones = phones;
}
}

Some files were not shown because too many files have changed in this diff Show More