mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-19 23:02:24 +00:00
merged
This commit is contained in:
commit
72d8a73aa7
387 files changed
+3716
-2671
No files matched your search
+20
-12
@@ -135,6 +135,26 @@
|
||||
</dependency>
|
||||
|
||||
<!-- Test scope -->
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-h2</artifactId>
|
||||
<version>13.2.1-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-postgres</artifactId>
|
||||
<version>13.2.1-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-sqlserver</artifactId>
|
||||
<version>13.2.1-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
@@ -222,18 +242,6 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>io.repaint.maven</groupId>
|
||||
<artifactId>tiles-maven-plugin</artifactId>
|
||||
<version>2.24</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<tiles>
|
||||
<tile>io.avaje.tile:moditech-module:1.0</tile>
|
||||
</tiles>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
@@ -167,7 +167,7 @@ public final class BindParams implements Serializable {
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void setParameter(int position, Object value) {
|
||||
assert value != null : "use setNullParameter";
|
||||
//TODO: Review - assert value != null : "use setNullParameter";
|
||||
Param p = getParam(position);
|
||||
if (value instanceof Collection) {
|
||||
// use of postgres ANY with positioned parameter
|
||||
@@ -219,7 +219,7 @@ public final class BindParams implements Serializable {
|
||||
* Set a named In parameter that is not null.
|
||||
*/
|
||||
public Param setParameter(String name, Object value) {
|
||||
assert value != null : "use setNullParameter";
|
||||
// TODO: Review - assert value != null : "use setNullParameter";
|
||||
Param p = getParam(name);
|
||||
p.setInValue(value);
|
||||
return p;
|
||||
|
||||
@@ -2,14 +2,7 @@ package io.ebeaninternal.server.cache;
|
||||
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* List of changes to be applied to L2 cache.
|
||||
|
||||
+1
-6
@@ -3,12 +3,7 @@ package io.ebeaninternal.server.cache;
|
||||
import io.ebean.annotation.Cache;
|
||||
import io.ebean.annotation.CacheBeanTuning;
|
||||
import io.ebean.annotation.CacheQueryTuning;
|
||||
import io.ebean.cache.QueryCacheEntryValidate;
|
||||
import io.ebean.cache.ServerCache;
|
||||
import io.ebean.cache.ServerCacheConfig;
|
||||
import io.ebean.cache.ServerCacheFactory;
|
||||
import io.ebean.cache.ServerCacheOptions;
|
||||
import io.ebean.cache.ServerCacheType;
|
||||
import io.ebean.cache.*;
|
||||
import io.ebean.config.CurrentTenantProvider;
|
||||
import io.ebean.meta.MetricVisitor;
|
||||
import io.ebean.util.AnnotationUtil;
|
||||
|
||||
+10
-25
@@ -3,7 +3,6 @@ package io.ebeaninternal.server.cache;
|
||||
import io.ebean.BackgroundExecutor;
|
||||
import io.ebean.cache.ServerCache;
|
||||
import io.ebean.cache.ServerCacheStatistics;
|
||||
import io.ebean.cache.TenantAwareKey;
|
||||
import io.ebean.meta.MetricVisitor;
|
||||
import io.ebean.metric.CountMetric;
|
||||
import io.ebean.metric.MetricFactory;
|
||||
@@ -12,11 +11,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@@ -52,14 +47,12 @@ public class DefaultServerCache implements ServerCache {
|
||||
private final int trimFrequency;
|
||||
private final int maxIdleSecs;
|
||||
private final int maxSecsToLive;
|
||||
private final TenantAwareKey tenantAwareKey;
|
||||
|
||||
public DefaultServerCache(DefaultServerCacheConfig config) {
|
||||
this.name = config.getName();
|
||||
this.shortName = config.getShortName();
|
||||
this.map = config.getMap();
|
||||
this.maxSize = config.getMaxSize();
|
||||
this.tenantAwareKey = new TenantAwareKey(config.getTenantProvider());
|
||||
this.maxIdleSecs = config.getMaxIdleSecs();
|
||||
this.maxSecsToLive = config.getMaxSecsToLive();
|
||||
this.trimFrequency = config.determineTrimFrequency();
|
||||
@@ -92,7 +85,7 @@ public class DefaultServerCache implements ServerCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerCacheStatistics getStatistics(boolean reset) {
|
||||
public ServerCacheStatistics statistics(boolean reset) {
|
||||
ServerCacheStatistics cacheStats = new ServerCacheStatistics();
|
||||
cacheStats.setCacheName(name);
|
||||
cacheStats.setMaxSize(maxSize);
|
||||
@@ -121,7 +114,7 @@ public class DefaultServerCache implements ServerCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHitRatio() {
|
||||
public int hitRatio() {
|
||||
long mc = missCount.get(false);
|
||||
long hc = hitCount.get(false);
|
||||
long totalCount = hc + mc;
|
||||
@@ -152,19 +145,12 @@ public class DefaultServerCache implements ServerCache {
|
||||
map.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the tenant aware key.
|
||||
*/
|
||||
protected Object key(Object id) {
|
||||
return tenantAwareKey.key(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a value from the cache.
|
||||
*/
|
||||
@Override
|
||||
public Object get(Object id) {
|
||||
CacheEntry entry = getCacheEntry(id);
|
||||
public Object get(Object key) {
|
||||
CacheEntry entry = getCacheEntry(key);
|
||||
if (entry == null) {
|
||||
missCount.increment();
|
||||
return null;
|
||||
@@ -184,8 +170,8 @@ public class DefaultServerCache implements ServerCache {
|
||||
/**
|
||||
* Get the cache entry - override for query cache to validate dependent tables.
|
||||
*/
|
||||
protected CacheEntry getCacheEntry(Object id) {
|
||||
final SoftReference<CacheEntry> ref = map.get(key(id));
|
||||
protected CacheEntry getCacheEntry(Object key) {
|
||||
final SoftReference<CacheEntry> ref = map.get(key);
|
||||
return ref != null ? ref.get() : null;
|
||||
}
|
||||
|
||||
@@ -198,8 +184,7 @@ public class DefaultServerCache implements ServerCache {
|
||||
* Put a value into the cache.
|
||||
*/
|
||||
@Override
|
||||
public void put(Object id, Object value) {
|
||||
Object key = key(id);
|
||||
public void put(Object key, Object value) {
|
||||
map.put(key, new SoftReference<>(new CacheEntry(key, value)));
|
||||
putCount.increment();
|
||||
}
|
||||
@@ -208,8 +193,8 @@ public class DefaultServerCache implements ServerCache {
|
||||
* Remove an entry from the cache.
|
||||
*/
|
||||
@Override
|
||||
public void remove(Object id) {
|
||||
SoftReference<CacheEntry> entry = map.remove(key(id));
|
||||
public void remove(Object key) {
|
||||
SoftReference<CacheEntry> entry = map.remove(key);
|
||||
if (entry != null && entry.get() != null) {
|
||||
removeCount.increment();
|
||||
}
|
||||
|
||||
-5
@@ -3,7 +3,6 @@ package io.ebeaninternal.server.cache;
|
||||
import io.ebean.cache.QueryCacheEntryValidate;
|
||||
import io.ebean.cache.ServerCacheConfig;
|
||||
import io.ebean.cache.ServerCacheOptions;
|
||||
import io.ebean.config.CurrentTenantProvider;
|
||||
import io.ebeaninternal.server.cache.DefaultServerCache.CacheEntry;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
@@ -34,10 +33,6 @@ public final class DefaultServerCacheConfig {
|
||||
this.maxSize = options.getMaxSize();
|
||||
}
|
||||
|
||||
public CurrentTenantProvider getTenantProvider() {
|
||||
return config.getTenantProvider();
|
||||
}
|
||||
|
||||
public QueryCacheEntryValidate getQueryCacheEntryValidate() {
|
||||
return config.getQueryCacheEntryValidate();
|
||||
}
|
||||
|
||||
+2
-6
@@ -1,11 +1,7 @@
|
||||
package io.ebeaninternal.server.cache;
|
||||
|
||||
import io.ebean.BackgroundExecutor;
|
||||
import io.ebean.cache.ServerCache;
|
||||
import io.ebean.cache.ServerCacheConfig;
|
||||
import io.ebean.cache.ServerCacheFactory;
|
||||
import io.ebean.cache.ServerCacheNotification;
|
||||
import io.ebean.cache.ServerCacheNotify;
|
||||
import io.ebean.cache.*;
|
||||
|
||||
|
||||
/**
|
||||
@@ -41,7 +37,7 @@ final class DefaultServerCacheFactory implements ServerCacheFactory {
|
||||
if (executor != null) {
|
||||
cache.periodicTrim(executor);
|
||||
}
|
||||
return cache;
|
||||
return config.tenantAware(cache);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-5
@@ -10,11 +10,7 @@ import io.ebeaninternal.server.deploy.DCacheRegion;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Manages the bean and query caches.
|
||||
|
||||
+1
-2
@@ -27,8 +27,7 @@ public class DefaultServerQueryCache extends DefaultServerCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CacheEntry getCacheEntry(Object id) {
|
||||
Object key = key(id);
|
||||
protected CacheEntry getCacheEntry(Object key) {
|
||||
final SoftReference<CacheEntry> ref = map.get(key);
|
||||
CacheEntry entry = ref != null ? ref.get() : null;
|
||||
if (entry == null) {
|
||||
|
||||
+27
-159
@@ -2,36 +2,18 @@ package io.ebeaninternal.server.core;
|
||||
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.config.dbplatform.clickhouse.ClickHousePlatform;
|
||||
import io.ebean.config.dbplatform.cockroach.CockroachPlatform;
|
||||
import io.ebean.config.dbplatform.db2.DB2ForIPlatform;
|
||||
import io.ebean.config.dbplatform.db2.DB2LegacyPlatform;
|
||||
import io.ebean.config.dbplatform.db2.DB2LuwPlatform;
|
||||
import io.ebean.config.dbplatform.db2.DB2ZosPlatform;
|
||||
import io.ebean.config.dbplatform.h2.H2Platform;
|
||||
import io.ebean.config.dbplatform.hana.HanaPlatform;
|
||||
import io.ebean.config.dbplatform.hsqldb.HsqldbPlatform;
|
||||
import io.ebean.config.dbplatform.mariadb.MariaDbPlatform;
|
||||
import io.ebean.config.dbplatform.mysql.MySql55Platform;
|
||||
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
|
||||
import io.ebean.config.dbplatform.nuodb.NuoDbPlatform;
|
||||
import io.ebean.config.dbplatform.oracle.Oracle11Platform;
|
||||
import io.ebean.config.dbplatform.oracle.Oracle12Platform;
|
||||
import io.ebean.config.dbplatform.oracle.OraclePlatform;
|
||||
import io.ebean.config.dbplatform.postgres.Postgres9Platform;
|
||||
import io.ebean.config.dbplatform.postgres.PostgresPlatform;
|
||||
import io.ebean.config.dbplatform.sqlanywhere.SqlAnywherePlatform;
|
||||
import io.ebean.config.dbplatform.sqlite.SQLitePlatform;
|
||||
import io.ebean.config.dbplatform.sqlserver.SqlServer16Platform;
|
||||
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
|
||||
import io.ebean.config.dbplatform.yugabyte.YugabytePlaform;
|
||||
import io.ebean.config.dbplatform.DatabasePlatformProvider;
|
||||
import io.ebeaninternal.api.CoreLog;
|
||||
import io.ebeaninternal.api.DbOffline;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.*;
|
||||
import java.util.Locale;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* Create a DatabasePlatform from the configuration.
|
||||
@@ -41,6 +23,14 @@ import java.util.Locale;
|
||||
*/
|
||||
public class DatabasePlatformFactory {
|
||||
|
||||
private final List<DatabasePlatformProvider> providers = new ArrayList<>();
|
||||
|
||||
public DatabasePlatformFactory() {
|
||||
for (DatabasePlatformProvider platformProvider : ServiceLoader.load(DatabasePlatformProvider.class)) {
|
||||
providers.add(platformProvider);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the appropriate database specific platform.
|
||||
*/
|
||||
@@ -71,68 +61,10 @@ public class DatabasePlatformFactory {
|
||||
*/
|
||||
private DatabasePlatform byDatabaseName(String dbName) {
|
||||
dbName = dbName.toLowerCase();
|
||||
if (dbName.equals("h2")) {
|
||||
return new H2Platform();
|
||||
}
|
||||
if (dbName.equals("mariadb")) {
|
||||
return new MariaDbPlatform();
|
||||
}
|
||||
if (dbName.equals("mysql")) {
|
||||
return new MySqlPlatform();
|
||||
}
|
||||
if (dbName.equals("mysql55")) {
|
||||
return new MySql55Platform();
|
||||
}
|
||||
if (dbName.equals("postgres") || dbName.equals("postgres9")) {
|
||||
return new PostgresPlatform();
|
||||
}
|
||||
if (dbName.equals("oracle11") || dbName.equals("oracle10") || dbName.equals("oracle9")) {
|
||||
return new Oracle11Platform();
|
||||
}
|
||||
if (dbName.equals("oracle12")) {
|
||||
return new Oracle12Platform();
|
||||
}
|
||||
if (dbName.equals("oracle")) {
|
||||
return new OraclePlatform();
|
||||
}
|
||||
if (dbName.equals("sqlserver16")) {
|
||||
return new SqlServer16Platform();
|
||||
}
|
||||
if (dbName.equals("sqlserver17")) {
|
||||
return new SqlServer17Platform();
|
||||
}
|
||||
if (dbName.equals("sqlserver")) {
|
||||
throw new IllegalArgumentException("Please choose the more specific sqlserver16 or sqlserver17 platform. Refer to issue #1340 for details");
|
||||
}
|
||||
if (dbName.equals("sqlanywhere")) {
|
||||
return new SqlAnywherePlatform();
|
||||
}
|
||||
if (dbName.equals("db2")) {
|
||||
throw new IllegalArgumentException("Please choose the more specific db2luw/db2zos/db2fori platform. Refer to issue #2514 for details");
|
||||
}
|
||||
if (dbName.equals("db2legacy")) {
|
||||
return new DB2LegacyPlatform();
|
||||
}
|
||||
if (dbName.equals("db2zos")) {
|
||||
return new DB2ZosPlatform();
|
||||
}
|
||||
if (dbName.equals("db2fori")) {
|
||||
return new DB2ForIPlatform();
|
||||
}
|
||||
if (dbName.equals("db2luw")) {
|
||||
return new DB2LuwPlatform();
|
||||
}
|
||||
if (dbName.equals("clickhouse")) {
|
||||
return new ClickHousePlatform();
|
||||
}
|
||||
if (dbName.equals("nuodb")) {
|
||||
return new NuoDbPlatform();
|
||||
}
|
||||
if (dbName.equals("sqlite")) {
|
||||
return new SQLitePlatform();
|
||||
}
|
||||
if (dbName.equals("hana")) {
|
||||
return new HanaPlatform();
|
||||
for (DatabasePlatformProvider provider : providers) {
|
||||
if (provider.match(dbName)) {
|
||||
return provider.create(dbName);
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("database platform " + dbName + " is not known?");
|
||||
}
|
||||
@@ -156,79 +88,15 @@ public class DatabasePlatformFactory {
|
||||
final int majorVersion = metaData.getDatabaseMajorVersion();
|
||||
final int minorVersion = metaData.getDatabaseMinorVersion();
|
||||
CoreLog.log.debug("platform for productName[{}] version[{}.{}]", dbProductName, majorVersion, minorVersion);
|
||||
|
||||
if (dbProductName.contains("oracle")) {
|
||||
return oracleVersion(majorVersion);
|
||||
} else if (dbProductName.contains("microsoft")) {
|
||||
throw new IllegalArgumentException("For SqlServer please explicitly choose either sqlserver16 or sqlserver17 as the platform via DatabaseConfig.setDatabasePlatformName. Refer to issue #1340 for more details");
|
||||
} else if (dbProductName.contains("h2")) {
|
||||
return new H2Platform();
|
||||
} else if (dbProductName.contains("hsql database engine")) {
|
||||
return new HsqldbPlatform();
|
||||
} else if (dbProductName.contains("postgres")) {
|
||||
String productVersion = metaData.getDatabaseProductVersion().toLowerCase(Locale.ENGLISH);
|
||||
return readPostgres(connection, majorVersion, productVersion);
|
||||
} else if (dbProductName.contains("mariadb")) {
|
||||
return new MariaDbPlatform();
|
||||
} else if (dbProductName.contains("mysql")) {
|
||||
return mysqlVersion(majorVersion, minorVersion);
|
||||
} else if (dbProductName.contains("nuo")) {
|
||||
return new NuoDbPlatform();
|
||||
} else if (dbProductName.contains("sqlite")) {
|
||||
return new SQLitePlatform();
|
||||
} else if (dbProductName.contains("db2")) {
|
||||
throw new IllegalArgumentException("For DB2 please explicitly choose either db2legacy/db2luw/db2zos/db2fori platform. Refer to issue #2514 for details");
|
||||
} else if (dbProductName.contains("sql anywhere")) {
|
||||
return new SqlAnywherePlatform();
|
||||
} else if (dbProductName.contains("hdb")) {
|
||||
return new HanaPlatform();
|
||||
} else if (dbProductName.contains("clickhouse")) {
|
||||
return new ClickHousePlatform();
|
||||
}
|
||||
|
||||
// use the standard one
|
||||
return new DatabasePlatform();
|
||||
}
|
||||
|
||||
private DatabasePlatform oracleVersion(int majorVersion) {
|
||||
if (majorVersion < 12) {
|
||||
return new Oracle11Platform();
|
||||
}
|
||||
if (majorVersion < 13) {
|
||||
return new Oracle12Platform();
|
||||
}
|
||||
return new OraclePlatform();
|
||||
}
|
||||
|
||||
private DatabasePlatform mysqlVersion(int majorVersion, int minorVersion) {
|
||||
if (majorVersion <= 5 && minorVersion <= 5) {
|
||||
return new MySql55Platform();
|
||||
}
|
||||
return new MySqlPlatform();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a select version() query as it could be Postgres or CockroachDB.
|
||||
*/
|
||||
private static DatabasePlatform readPostgres(Connection connection, int majorVersion, String productVersion) {
|
||||
if (productVersion.contains("-yb-")) {
|
||||
return new YugabytePlaform();
|
||||
}
|
||||
try (PreparedStatement statement = connection.prepareStatement("select version() as \"version\"")) {
|
||||
try (ResultSet resultSet = statement.executeQuery()) {
|
||||
if (resultSet.next()) {
|
||||
productVersion = resultSet.getString("version").toLowerCase();
|
||||
if (productVersion.contains("cockroach")) {
|
||||
return new CockroachPlatform();
|
||||
}
|
||||
}
|
||||
for (DatabasePlatformProvider provider : providers) {
|
||||
if (provider.matchByProductName(dbProductName)) {
|
||||
return provider.create(majorVersion, minorVersion, metaData, connection);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
CoreLog.log.warn("Error running detection query on Postgres", e);
|
||||
}
|
||||
if (majorVersion <= 9) {
|
||||
return new Postgres9Platform();
|
||||
}
|
||||
return new PostgresPlatform();
|
||||
throw new IllegalStateException("Unable to determine the appropriate ebean platform given database product name [" + dbProductName
|
||||
+ "] and ebean platform providers " + providers + ". With ebean 13+ we now have separate platforms (ebean-postgres, ebean-mysql etc)"
|
||||
+ " and should use database specific platform dependency like ebean-postgres. Note that we can use ebean-platform-all to include"
|
||||
+ " all the platforms.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,6 @@ 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.event.ShutdownManager;
|
||||
import io.ebean.service.SpiContainer;
|
||||
import io.ebeaninternal.api.CoreLog;
|
||||
@@ -24,6 +23,7 @@ import io.ebeaninternal.server.executor.DefaultBackgroundExecutor;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
@@ -86,7 +86,7 @@ public final class DefaultContainer implements SpiContainer {
|
||||
|
||||
boolean online = true;
|
||||
if (config.isDocStoreOnly()) {
|
||||
config.setDatabasePlatform(new H2Platform());
|
||||
config.setDatabasePlatform(new DatabasePlatform());
|
||||
} else {
|
||||
TenantMode tenantMode = config.getTenantMode();
|
||||
if (TenantMode.DB != tenantMode) {
|
||||
@@ -141,9 +141,21 @@ public final class DefaultContainer implements SpiContainer {
|
||||
}
|
||||
if (config.isAutoLoadModuleInfo()) {
|
||||
// auto register entity classes
|
||||
boolean found = false;
|
||||
for (ModuleInfoLoader loader : ServiceLoader.load(ModuleInfoLoader.class)) {
|
||||
config.addAll(loader.classesFor(config.getName(), config.isDefaultServer()));
|
||||
found = true;
|
||||
}
|
||||
if (!found) {
|
||||
checkMissingModulePathProvides();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkMissingModulePathProvides() {
|
||||
URL servicesFile = ClassLoader.getSystemResource("META-INF/services/io.ebean.config.ModuleInfoLoader");
|
||||
if (servicesFile != null) {
|
||||
log.error("module-info.java is probably missing 'provides io.ebean.config.ModuleInfoLoader with _Ebean$ModuleInfo' clause. ModuleInfoLoader exists but was not service loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -974,21 +974,11 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
return new DefaultRelationalQuery(this, sql.trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlQuery createSqlQuery(String sql) {
|
||||
return sqlQuery(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlUpdate sqlUpdate(String sql) {
|
||||
return new DefaultSqlUpdate(this, sql.trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlUpdate createSqlUpdate(String sql) {
|
||||
return sqlUpdate(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallableSql createCallableSql(String sql) {
|
||||
return new DefaultCallableSql(this, sql.trim());
|
||||
@@ -1372,11 +1362,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Stream<T> findLargeStream(Query<T> query, Transaction transaction) {
|
||||
return findStream(query, transaction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Stream<T> findStream(Query<T> query, Transaction transaction) {
|
||||
return toStream(findIterate(query, transaction));
|
||||
|
||||
@@ -261,16 +261,6 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlUpdate setParams(Object... values) {
|
||||
return setParameters(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlUpdate setNextParameter(Object value) {
|
||||
return setParameter(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlUpdate setParameters(Object... values) {
|
||||
for (Object value : values) {
|
||||
|
||||
+7
@@ -17,12 +17,14 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
final class MultiTenantDbCatalogSupplier implements DataSourceSupplier {
|
||||
|
||||
private final CurrentTenantProvider tenantProvider;
|
||||
private final DataSource dataSource;
|
||||
private final DataSource readOnlyDataSource;
|
||||
private final CatalogDataSource catalogDataSource;
|
||||
private final CatalogDataSource readOnly;
|
||||
|
||||
MultiTenantDbCatalogSupplier(CurrentTenantProvider tenantProvider, DataSource dataSource, DataSource readOnlyDataSource, TenantCatalogProvider catalogProvider) {
|
||||
this.tenantProvider = tenantProvider;
|
||||
this.dataSource = dataSource;
|
||||
this.readOnlyDataSource = readOnlyDataSource;
|
||||
this.catalogDataSource = new CatalogDataSource(dataSource, tenantProvider, catalogProvider);
|
||||
@@ -33,6 +35,11 @@ final class MultiTenantDbCatalogSupplier implements DataSourceSupplier {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object currentTenantId() {
|
||||
return tenantProvider.currentId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource getDataSource() {
|
||||
return catalogDataSource;
|
||||
|
||||
@@ -17,12 +17,14 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
final class MultiTenantDbSchemaSupplier implements DataSourceSupplier {
|
||||
|
||||
private final CurrentTenantProvider tenantProvider;
|
||||
private final DataSource dataSource;
|
||||
private final DataSource readOnlyDataSource;
|
||||
private final SchemaDataSource schemaDataSource;
|
||||
private final SchemaDataSource readOnly;
|
||||
|
||||
MultiTenantDbSchemaSupplier(CurrentTenantProvider tenantProvider, DataSource dataSource, DataSource readOnlyDataSource, TenantSchemaProvider schemaProvider) {
|
||||
this.tenantProvider = tenantProvider;
|
||||
this.dataSource = dataSource;
|
||||
this.readOnlyDataSource = readOnlyDataSource;
|
||||
this.schemaDataSource = new SchemaDataSource(dataSource, schemaProvider, tenantProvider);
|
||||
@@ -33,6 +35,11 @@ final class MultiTenantDbSchemaSupplier implements DataSourceSupplier {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object currentTenantId() {
|
||||
return tenantProvider.currentId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource getDataSource() {
|
||||
return schemaDataSource;
|
||||
|
||||
@@ -21,6 +21,11 @@ final class MultiTenantDbSupplier implements DataSourceSupplier {
|
||||
this.dataSourceProvider = dataSourceProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object currentTenantId() {
|
||||
return tenantProvider.currentId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource getReadOnlyDataSource() {
|
||||
// read only datasource not supported with DB per tenant at this stage
|
||||
|
||||
@@ -20,6 +20,11 @@ final class SimpleDataSourceProvider implements DataSourceSupplier {
|
||||
this.readOnlyDataSource = readOnlyDataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object currentTenantId() {
|
||||
return null; // not required here
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource getDataSource() {
|
||||
return dataSource;
|
||||
|
||||
@@ -2106,10 +2106,10 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
return getId((EntityBean) bean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBeanId(T bean) {
|
||||
return getId((EntityBean) bean);
|
||||
}
|
||||
// @Override
|
||||
// public Object beanId(T bean) {
|
||||
// return getId((EntityBean) bean);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Return the Id value for the bean with embeddedId beans converted into maps.
|
||||
@@ -2673,7 +2673,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
public PartitionMeta partitionMeta() {
|
||||
return partitionMeta;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the tablespace details of the bean.
|
||||
*/
|
||||
|
||||
+2
-2
@@ -58,13 +58,13 @@ class BeanDescriptorElementEmbeddedMap<T> extends BeanDescriptorElementEmbedded<
|
||||
}
|
||||
if (stringKey) {
|
||||
parser.nextToken();
|
||||
Object val = readJsonElement(readJson, null, null); // FIXME
|
||||
Object val = readJsonElement(readJson, null, null); // CHECKME: Update existing map entry here?
|
||||
add.addKeyValue(fieldName, val);
|
||||
} else {
|
||||
parser.nextFieldName();
|
||||
Object key = scalarTypeKey.jsonRead(parser);
|
||||
parser.nextFieldName();
|
||||
Object val = readJsonElement(readJson, null, null); // FIXME
|
||||
Object val = readJsonElement(readJson, null, null); // CHECKME: Update existing map entry here?
|
||||
add.addKeyValue(key, val);
|
||||
}
|
||||
} while (true);
|
||||
|
||||
@@ -102,7 +102,7 @@ final class BeanDescriptorJsonHelp<T> {
|
||||
String msg = "Error reading inheritance discriminator - expected [" + discColumn + "] but no json key?";
|
||||
throw new JsonParseException(newParser, msg, parser.getCurrentLocation());
|
||||
}
|
||||
|
||||
|
||||
BeanDescriptor<T> inheritDesc = (BeanDescriptor<T>) inheritInfo.readType(discNode.asText()).desc();
|
||||
return inheritDesc.jsonReadObject(newReader, path, target);
|
||||
}
|
||||
|
||||
@@ -575,7 +575,29 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> BeanManager<T> beanManager(Class<T> entityType) {
|
||||
return (BeanManager<T>) beanManager(entityType.getName());
|
||||
BeanManager<T> mgr = (BeanManager<T>) beanManager(entityType.getName());
|
||||
if (mgr == null) {
|
||||
errorBeanNotRegistered(entityType);
|
||||
}
|
||||
return mgr;
|
||||
}
|
||||
|
||||
private <T> void errorBeanNotRegistered(Class<T> entityType) {
|
||||
if (beanManagerMap.isEmpty()) {
|
||||
throw new PersistenceException(errNothingRegistered());
|
||||
} else {
|
||||
throw new PersistenceException(errNotRegistered(entityType));
|
||||
}
|
||||
}
|
||||
|
||||
private <T> String errNothingRegistered() {
|
||||
return "There are no registered entities. If using query beans, that generates _Ebean$ModuleInfo.java into " +
|
||||
"generated sources and is service loaded. If using module-info.java, then probably missing 'provides io.ebean.config.ModuleInfoLoader with _Ebean$ModuleInfo' clause.";
|
||||
}
|
||||
|
||||
private String errNotRegistered(Class<?> beanClass) {
|
||||
return "The type [" + beanClass + "] is not a registered entity?"
|
||||
+ " If you don't explicitly list the entity classes to use Ebean will search for them in the classpath.";
|
||||
}
|
||||
|
||||
private BeanManager<?> beanManager(String beanClassName) {
|
||||
|
||||
@@ -1016,7 +1016,8 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
BeanCollection<?> collection = createEmpty(parentBean);
|
||||
BeanCollectionAdd add = beanCollectionAdd(collection);
|
||||
do {
|
||||
EntityBean detailBean = (EntityBean) targetDescriptor.jsonRead(readJson, name, null); // FIXME
|
||||
// CHECKME: Update existing list entry here?
|
||||
EntityBean detailBean = (EntityBean) targetDescriptor.jsonRead(readJson, name, null);
|
||||
if (detailBean == null) {
|
||||
// read the entire array
|
||||
break;
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package io.ebeaninternal.server.deploy.meta;
|
||||
import io.ebean.annotation.Cache;
|
||||
import io.ebean.annotation.DocStore;
|
||||
import io.ebean.annotation.DocStoreMode;
|
||||
import io.ebean.annotation.EntityOverride;
|
||||
import io.ebean.annotation.ext.EntityOverride;
|
||||
import io.ebean.annotation.Identity;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.TableName;
|
||||
|
||||
+1
-5
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.deploy.meta;
|
||||
|
||||
import io.ebean.annotation.CreatedTimestamp;
|
||||
import io.ebean.annotation.DocCode;
|
||||
import io.ebean.annotation.DocProperty;
|
||||
import io.ebean.annotation.DocSortable;
|
||||
@@ -8,7 +7,6 @@ import io.ebean.annotation.Formula;
|
||||
import io.ebean.annotation.MutationDetection;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.annotation.SoftDelete;
|
||||
import io.ebean.annotation.UpdatedTimestamp;
|
||||
import io.ebean.annotation.WhenCreated;
|
||||
import io.ebean.annotation.WhenModified;
|
||||
import io.ebean.annotation.Where;
|
||||
@@ -233,9 +231,7 @@ public class DeployBeanProperty implements DeployBeanPropertyMeta {
|
||||
return (AnnotationUtil.has(field, WhenCreated.class)
|
||||
|| AnnotationUtil.has(field, WhenModified.class)
|
||||
|| AnnotationUtil.has(field, WhoModified.class)
|
||||
|| AnnotationUtil.has(field, WhoCreated.class)
|
||||
|| AnnotationUtil.has(field, UpdatedTimestamp.class)
|
||||
|| AnnotationUtil.has(field, CreatedTimestamp.class));
|
||||
|| AnnotationUtil.has(field, WhoCreated.class));
|
||||
}
|
||||
|
||||
public String getFullBeanName() {
|
||||
|
||||
@@ -6,8 +6,8 @@ import io.ebean.annotation.DbPartition;
|
||||
import io.ebean.annotation.DocStore;
|
||||
import io.ebean.annotation.Draftable;
|
||||
import io.ebean.annotation.DraftableElement;
|
||||
import io.ebean.annotation.EntityImplements;
|
||||
import io.ebean.annotation.EntityOverride;
|
||||
import io.ebean.annotation.ext.EntityImplements;
|
||||
import io.ebean.annotation.ext.EntityOverride;
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.Identity;
|
||||
import io.ebean.annotation.Index;
|
||||
|
||||
+4
-52
@@ -1,38 +1,7 @@
|
||||
package io.ebeaninternal.server.deploy.parse;
|
||||
|
||||
import io.ebean.annotation.Aggregation;
|
||||
import io.ebean.annotation.CreatedTimestamp;
|
||||
import io.ebean.annotation.DbArray;
|
||||
import io.ebean.annotation.DbComment;
|
||||
import io.ebean.annotation.DbDefault;
|
||||
import io.ebean.annotation.DbJson;
|
||||
import io.ebean.annotation.DbJsonB;
|
||||
import io.ebean.annotation.DbMap;
|
||||
import io.ebean.annotation.DbMigration;
|
||||
import io.ebean.annotation.DocCode;
|
||||
import io.ebean.annotation.DocEmbedded;
|
||||
import io.ebean.annotation.DocProperty;
|
||||
import io.ebean.annotation.DocSortable;
|
||||
import io.ebean.annotation.Draft;
|
||||
import io.ebean.annotation.DraftDirty;
|
||||
import io.ebean.annotation.DraftOnly;
|
||||
import io.ebean.annotation.DraftReset;
|
||||
import io.ebean.annotation.Encrypted;
|
||||
import io.ebean.annotation.Expose;
|
||||
import io.ebean.annotation.Formula;
|
||||
import io.ebean.annotation.HistoryExclude;
|
||||
import io.ebean.annotation.Identity;
|
||||
import io.ebean.annotation.Index;
|
||||
import io.ebean.annotation.JsonIgnore;
|
||||
import io.ebean.annotation.Length;
|
||||
import io.ebean.annotation.SoftDelete;
|
||||
import io.ebean.annotation.TenantId;
|
||||
import io.ebean.annotation.UnmappedJson;
|
||||
import io.ebean.annotation.UpdatedTimestamp;
|
||||
import io.ebean.annotation.WhenCreated;
|
||||
import io.ebean.annotation.WhenModified;
|
||||
import io.ebean.annotation.WhoCreated;
|
||||
import io.ebean.annotation.WhoModified;
|
||||
import io.ebean.annotation.*;
|
||||
import io.ebean.config.EncryptDeploy;
|
||||
import io.ebean.config.EncryptDeploy.Mode;
|
||||
import io.ebean.config.dbplatform.DbEncrypt;
|
||||
@@ -51,24 +20,7 @@ import io.ebeaninternal.server.type.ScalarTypeBytesBase;
|
||||
import io.ebeaninternal.server.type.ScalarTypeBytesEncrypted;
|
||||
import io.ebeaninternal.server.type.ScalarTypeEncryptedWrapper;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
import javax.persistence.Version;
|
||||
import javax.persistence.*;
|
||||
import java.sql.Types;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -339,10 +291,10 @@ final class AnnotationFields extends AnnotationParser {
|
||||
}
|
||||
|
||||
private void initWhen(DeployBeanProperty prop) {
|
||||
if (has(prop, WhenCreated.class) || has(prop, CreatedTimestamp.class)) {
|
||||
if (has(prop, WhenCreated.class)) {
|
||||
generatedPropFactory.setInsertTimestamp(prop);
|
||||
}
|
||||
if (has(prop, WhenModified.class) || has(prop, UpdatedTimestamp.class)) {
|
||||
if (has(prop, WhenModified.class)) {
|
||||
generatedPropFactory.setUpdateTimestamp(prop);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1196,11 +1196,6 @@ public final class DefaultPersister implements Persister {
|
||||
return request;
|
||||
}
|
||||
|
||||
private String errNotRegistered(Class<?> beanClass) {
|
||||
return "The type [" + beanClass + "] is not a registered entity?"
|
||||
+ " If you don't explicitly list the entity classes to use Ebean will search for them in the classpath.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the BeanDescriptor for a bean that is being persisted.
|
||||
* <p>
|
||||
@@ -1210,10 +1205,6 @@ public final class DefaultPersister implements Persister {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> BeanManager<T> beanManager(Class<?> cls) {
|
||||
BeanManager<T> mgr = (BeanManager<T>) beanDescriptorManager.beanManager(cls);
|
||||
if (mgr == null) {
|
||||
throw new PersistenceException(errNotRegistered(cls));
|
||||
}
|
||||
return mgr;
|
||||
return (BeanManager<T>) beanDescriptorManager.beanManager(cls);
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,6 @@ final class DCountMetric implements CountMetric {
|
||||
|
||||
@Override
|
||||
public void visit(MetricVisitor visitor) {
|
||||
|
||||
long val = visitor.reset() ? count.sumThenReset() : count.sum();
|
||||
if (val > 0) {
|
||||
visitor.visitCount(new DCountMetricStats(name, val));
|
||||
|
||||
@@ -251,11 +251,6 @@ final class DefaultFetchGroupQuery<T> implements SpiFetchGroupQuery<T>, SpiQuery
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<T> findLargeStream() {
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findEach(Consumer<T> consumer) {
|
||||
throw new RuntimeException("EB102: Only select() and fetch() clause is allowed on FetchGroup");
|
||||
|
||||
@@ -1456,11 +1456,6 @@ public final class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<
|
||||
return server.findStream(this, transaction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<T> findLargeStream() {
|
||||
return server.findLargeStream(this, transaction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Version<T>> findVersions() {
|
||||
this.temporalMode = TemporalMode.VERSIONS;
|
||||
|
||||
+20
-37
@@ -10,7 +10,6 @@ import io.ebeaninternal.api.BindParams;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.api.SpiSqlQuery;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
@@ -56,36 +55,6 @@ public final class DefaultRelationalQuery extends AbstractQuery implements SpiSq
|
||||
return server.findList(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal findSingleDecimal() {
|
||||
return server.findSingleAttribute(this, BigDecimal.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long findSingleLong() {
|
||||
return server.findSingleAttribute(this, Long.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T findSingleAttribute(Class<T> cls) {
|
||||
return server.findSingleAttribute(this, cls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> findSingleAttributeList(Class<T> cls) {
|
||||
return server.findSingleAttributeList(this, cls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T findOne(RowMapper<T> mapper) {
|
||||
return server.findOneMapper(this, mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> findList(RowMapper<T> mapper) {
|
||||
return server.findListMapper(this, mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findEachRow(RowConsumer consumer) {
|
||||
server.findEachRow(this, consumer);
|
||||
@@ -101,12 +70,6 @@ public final class DefaultRelationalQuery extends AbstractQuery implements SpiSq
|
||||
return Optional.ofNullable(findOne());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public DefaultRelationalQuery setParams(Object... values) {
|
||||
return setParameters(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultRelationalQuery setParameters(Object... values) {
|
||||
bindParams.setNextParameters(values);
|
||||
@@ -119,6 +82,18 @@ public final class DefaultRelationalQuery extends AbstractQuery implements SpiSq
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlQuery setNullParameter(int position, int jdbcType) {
|
||||
bindParams.setNullParameter(position, jdbcType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlQuery setNullParameter(String name, int jdbcType) {
|
||||
bindParams.setNullParameter(name, jdbcType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultRelationalQuery setParameter(int position, Object value) {
|
||||
bindParams.setParameter(position, value);
|
||||
@@ -225,6 +200,14 @@ public final class DefaultRelationalQuery extends AbstractQuery implements SpiSq
|
||||
return new Mapper(mapper);
|
||||
}
|
||||
|
||||
private <T> T findSingleAttribute(Class<T> cls) {
|
||||
return server.findSingleAttribute(this, cls);
|
||||
}
|
||||
|
||||
private <T> List<T> findSingleAttributeList(Class<T> cls) {
|
||||
return server.findSingleAttributeList(this, cls);
|
||||
}
|
||||
|
||||
private class Scalar<T> implements SqlQuery.TypeQuery<T> {
|
||||
|
||||
private final Class<T> type;
|
||||
|
||||
@@ -224,7 +224,8 @@ public final class DJsonContext implements SpiJsonContext {
|
||||
|
||||
List<T> list = new ArrayList<>();
|
||||
do {
|
||||
T bean = desc.jsonRead(readJson, null, null); // FIXME: Should we update the list
|
||||
// CHECKME: Should we update the list
|
||||
T bean = desc.jsonRead(readJson, null, null);
|
||||
if (bean == null) {
|
||||
break;
|
||||
} else {
|
||||
|
||||
+5
-2
@@ -16,7 +16,6 @@ public interface DataSourceSupplier {
|
||||
* Return the DataSource to use for the current request.
|
||||
* <p>
|
||||
* This should take into account multi-tenancy and the current tenantId.
|
||||
* </p>
|
||||
*/
|
||||
DataSource getDataSource();
|
||||
|
||||
@@ -25,10 +24,14 @@ public interface DataSourceSupplier {
|
||||
* <p>
|
||||
* This can return null meaning that no read only DataSource (with autoCommit)
|
||||
* is available for use so normal transactions with explicit commit should be used.
|
||||
* </p>
|
||||
*/
|
||||
DataSource getReadOnlyDataSource();
|
||||
|
||||
/**
|
||||
* Obtain the current TenantId *IF* it is required for the DataSource.
|
||||
*/
|
||||
Object currentTenantId();
|
||||
|
||||
/**
|
||||
* Return a connection from the DataSource taking into account a tenantId for multi-tenant lazy loading.
|
||||
*
|
||||
|
||||
+2
-2
@@ -27,8 +27,8 @@ final class TransactionFactoryTenantWithRead extends TransactionFactoryTenant {
|
||||
Connection connection = null;
|
||||
try {
|
||||
if (tenantId == null) {
|
||||
// tenantId not set (by lazy loading) so get current tenantId
|
||||
tenantId = tenantProvider.currentId();
|
||||
// obtain the tenantId if the DataSource requires it
|
||||
tenantId = dataSourceSupplier.currentTenantId();
|
||||
}
|
||||
connection = dataSourceSupplier.getReadOnlyConnection(tenantId);
|
||||
return new ImplicitReadOnlyTransaction(manager, connection, tenantId);
|
||||
|
||||
@@ -54,14 +54,13 @@ public interface DocStoreBeanAdapter<T> extends BeanDocType<T> {
|
||||
/**
|
||||
* Return the index type for this bean type.
|
||||
*/
|
||||
@Override
|
||||
String getIndexType();
|
||||
String indexType();
|
||||
|
||||
/**
|
||||
* Return the index name for this bean type.
|
||||
*/
|
||||
@Override
|
||||
String getIndexName();
|
||||
String indexName();
|
||||
|
||||
/**
|
||||
* Process a delete by id of a given document.
|
||||
|
||||
+4
-15
@@ -102,7 +102,6 @@ public abstract class DocStoreBeanBaseAdapter<T> implements DocStoreBeanAdapter<
|
||||
private boolean registerPaths;
|
||||
|
||||
public DocStoreBeanBaseAdapter(BeanDescriptor<T> desc, DeployBeanDescriptor<T> deploy) {
|
||||
|
||||
this.desc = desc;
|
||||
this.server = desc.ebeanServer();
|
||||
this.mapped = deploy.isDocStoreMapped();
|
||||
@@ -123,7 +122,6 @@ public abstract class DocStoreBeanBaseAdapter<T> implements DocStoreBeanAdapter<
|
||||
|
||||
@Override
|
||||
public DocumentMapping createDocMapping() {
|
||||
|
||||
if (documentMapping != null) {
|
||||
return documentMapping;
|
||||
}
|
||||
@@ -143,12 +141,12 @@ public abstract class DocStoreBeanBaseAdapter<T> implements DocStoreBeanAdapter<
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndexType() {
|
||||
public String indexType() {
|
||||
return indexType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndexName() {
|
||||
public String indexName() {
|
||||
return indexName;
|
||||
}
|
||||
|
||||
@@ -159,7 +157,6 @@ public abstract class DocStoreBeanBaseAdapter<T> implements DocStoreBeanAdapter<
|
||||
|
||||
@Override
|
||||
public String rawProperty(String property) {
|
||||
|
||||
String rawProperty = sortableMap.get(property);
|
||||
return rawProperty == null ? property : rawProperty;
|
||||
}
|
||||
@@ -192,7 +189,6 @@ public abstract class DocStoreBeanBaseAdapter<T> implements DocStoreBeanAdapter<
|
||||
*/
|
||||
@Override
|
||||
public void registerInvalidationPath(String queueId, String path, Set<String> properties) {
|
||||
|
||||
if (!mapped) {
|
||||
if (update == DocStoreMode.IGNORE) {
|
||||
// bean type not mapped but is included as nested document
|
||||
@@ -207,7 +203,6 @@ public abstract class DocStoreBeanBaseAdapter<T> implements DocStoreBeanAdapter<
|
||||
* Return the DsInvalidationListener based on the properties, path.
|
||||
*/
|
||||
protected DocStoreEmbeddedInvalidation getEmbeddedInvalidation(String queueId, String path, Set<String> properties) {
|
||||
|
||||
if (properties.contains("*")) {
|
||||
return new DocStoreEmbeddedInvalidation(queueId, path);
|
||||
} else {
|
||||
@@ -245,19 +240,15 @@ public abstract class DocStoreBeanBaseAdapter<T> implements DocStoreBeanAdapter<
|
||||
* This can add derived/embedded/nested parts to the document.
|
||||
*/
|
||||
protected DocStructure derivePathProperties(PathProperties pathProps) {
|
||||
|
||||
boolean includeByDefault = (pathProps == null);
|
||||
if (pathProps == null) {
|
||||
pathProps = new PathProperties();
|
||||
}
|
||||
|
||||
return getDocStructure(pathProps, includeByDefault);
|
||||
}
|
||||
|
||||
protected DocStructure getDocStructure(PathProperties pathProps, final boolean includeByDefault) {
|
||||
|
||||
final DocStructure docStructure = new DocStructure(pathProps);
|
||||
|
||||
BeanProperty[] properties = desc.propertiesNonTransient();
|
||||
for (BeanProperty property : properties) {
|
||||
property.docStoreInclude(includeByDefault, docStructure);
|
||||
@@ -271,17 +262,16 @@ public abstract class DocStoreBeanBaseAdapter<T> implements DocStoreBeanAdapter<
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return docStructure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchPath getEmbedded(String path) {
|
||||
public FetchPath embedded(String path) {
|
||||
return docStructure.getEmbedded(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchPath getEmbeddedManyRoot(String path) {
|
||||
public FetchPath embeddedManyRoot(String path) {
|
||||
return docStructure.getEmbeddedManyRoot(path);
|
||||
}
|
||||
|
||||
@@ -297,7 +287,6 @@ public abstract class DocStoreBeanBaseAdapter<T> implements DocStoreBeanAdapter<
|
||||
|
||||
@Override
|
||||
public DocStoreMode getMode(PersistRequest.Type persistType, DocStoreMode txnMode) {
|
||||
|
||||
if (txnMode == null) {
|
||||
return getMode(persistType);
|
||||
} else if (txnMode == DocStoreMode.IGNORE) {
|
||||
|
||||
+31
-14
@@ -6,29 +6,29 @@ module io.ebean.core {
|
||||
uses io.ebean.config.DatabaseConfigProvider;
|
||||
uses io.ebean.config.ServerConfigProvider;
|
||||
uses io.ebean.config.ModuleInfoLoader;
|
||||
uses io.ebean.config.dbplatform.DatabasePlatformProvider;
|
||||
uses io.ebean.datasource.DataSourceAlertFactory;
|
||||
uses io.ebean.core.type.ExtraTypeFactory;
|
||||
uses io.ebeanservice.docstore.api.DocStoreFactory;
|
||||
uses io.ebean.migration.auto.AutoMigrationRunner;
|
||||
uses io.avaje.classpath.scanner.ClassPathScannerFactory;
|
||||
uses io.avaje.classpath.scanner.ClassPathScannerFactory;
|
||||
uses io.ebeaninternal.api.SpiLoggerFactory;
|
||||
uses io.ebeaninternal.api.GeoTypeProvider;
|
||||
uses io.ebeaninternal.api.SpiDdlGeneratorProvider;
|
||||
uses io.ebeaninternal.xmapping.api.XmapService;
|
||||
uses io.ebeaninternal.server.autotune.AutoTuneServiceProvider;
|
||||
uses io.ebeaninternal.server.cluster.ClusterBroadcastFactory;
|
||||
|
||||
requires transitive io.ebean.api;
|
||||
requires transitive io.ebean.migration.auto;
|
||||
requires transitive io.ebean.xmapping.api;
|
||||
requires transitive io.ebean.core.type;
|
||||
requires transitive io.ebean.ddl.runner;
|
||||
requires transitive org.antlr.antlr4.runtime;
|
||||
requires org.antlr.antlr4.runtime;
|
||||
requires io.avaje.classpath.scanner.api;
|
||||
requires io.avaje.classpath.scanner;
|
||||
requires io.ebean.types;
|
||||
requires org.slf4j;
|
||||
|
||||
requires static io.avaje.jsr305x;
|
||||
requires static com.fasterxml.jackson.annotation;
|
||||
requires static com.fasterxml.jackson.core;
|
||||
requires static com.fasterxml.jackson.databind;
|
||||
requires static jakarta.validation;
|
||||
@@ -40,18 +40,35 @@ module io.ebean.core {
|
||||
|
||||
exports io.ebeaninternal.server.cache;
|
||||
|
||||
exports io.ebeaninternal.api to io.ebean.ddl.generator, io.ebean.querybean, io.ebean.autotune, io.ebean.postgis, io.ebean.test;
|
||||
exports io.ebeaninternal.server.deploy to io.ebean.autotune, io.ebean.ddl.generator;
|
||||
exports io.ebeaninternal.server.deploy.id to io.ebean.ddl.generator;
|
||||
exports io.ebeaninternal.server.deploy.meta to io.ebean.ddl.generator;
|
||||
exports io.ebeaninternal.server.deploy.visitor to io.ebean.ddl.generator;
|
||||
exports io.ebeanservice.docstore.api;
|
||||
exports io.ebeanservice.docstore.api.support to io.ebean.elastic, io.ebean.test;
|
||||
exports io.ebeanservice.docstore.api.mapping to io.ebean.elastic;
|
||||
|
||||
exports io.ebeaninternal.server.el to io.ebean.autotune;
|
||||
exports io.ebeaninternal.api to io.ebean.ddl.generator, io.ebean.querybean, io.ebean.autotune, io.ebean.postgis, io.ebean.test, io.ebean.elastic, io.ebean.spring.txn;
|
||||
exports io.ebeaninternal.api.json to io.ebean.test;
|
||||
exports io.ebeaninternal.json to io.ebean.test;
|
||||
exports io.ebeaninternal.server.autotune to io.ebean.autotune;
|
||||
exports io.ebeaninternal.server.querydefn to io.ebean.autotune, io.ebean.querybean;
|
||||
exports io.ebeaninternal.server.type to io.ebean.postgis;
|
||||
exports io.ebeaninternal.server.core to io.ebean.test, io.ebean.elastic;
|
||||
exports io.ebeaninternal.server.core.bootup to io.ebean.test;
|
||||
exports io.ebeaninternal.server.core.timezone to io.ebean.test;
|
||||
exports io.ebeaninternal.server.cluster to io.ebean.test, io.ebean.k8scache;
|
||||
exports io.ebeaninternal.server.deploy to io.ebean.autotune, io.ebean.ddl.generator, io.ebean.test, io.ebean.elastic;
|
||||
exports io.ebeaninternal.server.deploy.id to io.ebean.ddl.generator;
|
||||
exports io.ebeaninternal.server.deploy.meta to io.ebean.ddl.generator, io.ebean.test, io.ebean.elastic;
|
||||
exports io.ebeaninternal.server.deploy.visitor to io.ebean.ddl.generator;
|
||||
exports io.ebeaninternal.server.el to io.ebean.autotune, io.ebean.test;
|
||||
exports io.ebeaninternal.server.expression to io.ebean.querybean, io.ebean.test, io.ebean.elastic;
|
||||
exports io.ebeaninternal.server.expression.platform to io.ebean.test;
|
||||
exports io.ebeaninternal.server.grammer to io.ebean.test;
|
||||
exports io.ebeaninternal.server.idgen to io.ebean.test;
|
||||
exports io.ebeaninternal.server.persist to io.ebean.test, io.ebean.elastic;
|
||||
exports io.ebeaninternal.server.query to io.ebean.test;
|
||||
exports io.ebeaninternal.server.querydefn to io.ebean.autotune, io.ebean.querybean, io.ebean.test, io.ebean.elastic;
|
||||
exports io.ebeaninternal.server.rawsql to io.ebean.test;
|
||||
exports io.ebeaninternal.server.text.json to io.ebean.test, io.ebean.elastic;
|
||||
exports io.ebeaninternal.server.type to io.ebean.postgis, io.ebean.test;
|
||||
exports io.ebeaninternal.server.transaction to io.ebean.test, io.ebean.elastic, io.ebean.spring.txn, io.ebean.k8scache;
|
||||
exports io.ebeaninternal.server.util to io.ebean.querybean;
|
||||
exports io.ebeaninternal.server.expression to io.ebean.querybean;
|
||||
|
||||
provides io.ebean.metric.MetricFactory with io.ebeaninternal.server.profile.DMetricFactory;
|
||||
provides io.ebean.service.SpiContainerFactory with io.ebeaninternal.server.DContainerFactory;
|
||||
@@ -5469,14 +5469,14 @@ create table c_user_history(
|
||||
);
|
||||
create view c_user_with_history as select * from c_user union all select * from c_user_history;
|
||||
|
||||
create trigger hembi_bean_history_upd before update,delete on hembi_bean for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
|
||||
create trigger hx_link_history_upd before update,delete on hx_link for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
|
||||
create trigger hi_link_history_upd before update,delete on hi_link for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
|
||||
create trigger hi_link_doc_history_upd before update,delete on hi_link_doc for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
|
||||
create trigger hi_tone_history_upd before update,delete on hi_tone for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
|
||||
create trigger hi_tthree_history_upd before update,delete on hi_tthree for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
|
||||
create trigger hi_ttwo_history_upd before update,delete on hi_ttwo for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
|
||||
create trigger hsd_setting_history_upd before update,delete on hsd_setting for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
|
||||
create trigger hsd_user_history_upd before update,delete on hsd_user for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
|
||||
create trigger link_history_upd before update,delete on link for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
|
||||
create trigger c_user_history_upd before update,delete on c_user for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
|
||||
create trigger hembi_bean_history_upd before update,delete on hembi_bean for each row call "io.ebean.platform.h2.H2HistoryTrigger";
|
||||
create trigger hx_link_history_upd before update,delete on hx_link for each row call "io.ebean.platform.h2.H2HistoryTrigger";
|
||||
create trigger hi_link_history_upd before update,delete on hi_link for each row call "io.ebean.platform.h2.H2HistoryTrigger";
|
||||
create trigger hi_link_doc_history_upd before update,delete on hi_link_doc for each row call "io.ebean.platform.h2.H2HistoryTrigger";
|
||||
create trigger hi_tone_history_upd before update,delete on hi_tone for each row call "io.ebean.platform.h2.H2HistoryTrigger";
|
||||
create trigger hi_tthree_history_upd before update,delete on hi_tthree for each row call "io.ebean.platform.h2.H2HistoryTrigger";
|
||||
create trigger hi_ttwo_history_upd before update,delete on hi_ttwo for each row call "io.ebean.platform.h2.H2HistoryTrigger";
|
||||
create trigger hsd_setting_history_upd before update,delete on hsd_setting for each row call "io.ebean.platform.h2.H2HistoryTrigger";
|
||||
create trigger hsd_user_history_upd before update,delete on hsd_user for each row call "io.ebean.platform.h2.H2HistoryTrigger";
|
||||
create trigger link_history_upd before update,delete on link for each row call "io.ebean.platform.h2.H2HistoryTrigger";
|
||||
create trigger c_user_history_upd before update,delete on c_user for each row call "io.ebean.platform.h2.H2HistoryTrigger";
|
||||
+14
-27
@@ -1,5 +1,6 @@
|
||||
package io.ebeaninternal.server.cache;
|
||||
|
||||
import io.ebean.cache.ServerCache;
|
||||
import io.ebean.cache.ServerCacheFactory;
|
||||
import io.ebean.cache.ServerCacheOptions;
|
||||
import io.ebean.cache.ServerCacheType;
|
||||
@@ -12,7 +13,7 @@ import org.tests.model.basic.Customer;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class DefaultCacheHolderTest {
|
||||
class DefaultCacheHolderTest {
|
||||
|
||||
private final ThreadLocal<String> tenantId = new ThreadLocal<>();
|
||||
|
||||
@@ -25,42 +26,30 @@ public class DefaultCacheHolderTest {
|
||||
.with(cacheFactory, new TableModState());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getCache_normal() {
|
||||
|
||||
void getCache_normal() {
|
||||
DefaultCacheHolder holder = new DefaultCacheHolder(options());
|
||||
|
||||
DefaultServerCache cache = cache(holder, Customer.class);
|
||||
assertThat(cache.getName()).isEqualTo("org.tests.model.basic.Customer_B");
|
||||
assertThat(cache.getShortName()).isEqualTo("Customer_B");
|
||||
|
||||
DefaultServerCache cache1 = cache(holder, Customer.class);
|
||||
ServerCache cache = cache(holder, Customer.class);
|
||||
ServerCache cache1 = cache(holder, Customer.class);
|
||||
assertThat(cache1).isSameAs(cache);
|
||||
|
||||
DefaultServerCache cache2 = cache(holder, Contact.class);
|
||||
ServerCache cache2 = cache(holder, Contact.class);
|
||||
assertThat(cache1).isNotSameAs(cache2);
|
||||
assertThat(cache2.getName()).isEqualTo("org.tests.model.basic.Contact_B");
|
||||
assertThat(cache2.getShortName()).isEqualTo("Contact_B");
|
||||
|
||||
}
|
||||
|
||||
private DefaultServerCache cache(DefaultCacheHolder holder, Class<?> type) {
|
||||
return (DefaultServerCache) holder.getCache(type, ServerCacheType.BEAN);
|
||||
private ServerCache cache(DefaultCacheHolder holder, Class<?> type) {
|
||||
return holder.getCache(type, ServerCacheType.BEAN);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCache_multiTenant() throws Exception {
|
||||
|
||||
void getCache_multiTenant() throws Exception {
|
||||
CacheManagerOptions builder = options().with(tenantId::get);
|
||||
|
||||
DefaultCacheHolder holder = new DefaultCacheHolder(builder);
|
||||
|
||||
tenantId.set("ten_1");
|
||||
DefaultServerCache cache = cache(holder, Customer.class);
|
||||
assertThat(cache.getName()).isEqualTo("org.tests.model.basic.Customer_B");
|
||||
assertThat(cache.getShortName()).isEqualTo("Customer_B");
|
||||
|
||||
ServerCache cache = cache(holder, Customer.class);
|
||||
cache.put("1", "value-for-tenant1");
|
||||
cache.put("2", "an other value-for-tenant1");
|
||||
|
||||
@@ -109,10 +98,9 @@ public class DefaultCacheHolderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clearAll() {
|
||||
|
||||
void clearAll() {
|
||||
DefaultCacheHolder holder = new DefaultCacheHolder(options());
|
||||
DefaultServerCache cache = cache(holder, Customer.class);
|
||||
ServerCache cache = cache(holder, Customer.class);
|
||||
cache.put("foo", "foo");
|
||||
assertThat(cache.size()).isEqualTo(1);
|
||||
holder.clearAll();
|
||||
@@ -121,12 +109,11 @@ public class DefaultCacheHolderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clearAll_multiTenant() {
|
||||
|
||||
void clearAll_multiTenant() {
|
||||
CacheManagerOptions options = options().with(tenantId::get);
|
||||
|
||||
DefaultCacheHolder holder = new DefaultCacheHolder(options);
|
||||
DefaultServerCache cache = cache(holder, Customer.class);
|
||||
ServerCache cache = cache(holder, Customer.class);
|
||||
cache.put("foo", "foo");
|
||||
assertThat(cache.size()).isEqualTo(1);
|
||||
|
||||
|
||||
+41
-47
@@ -1,5 +1,6 @@
|
||||
package io.ebeaninternal.server.cache;
|
||||
|
||||
import io.ebean.cache.ServerCache;
|
||||
import io.ebean.config.ContainerConfig;
|
||||
import io.ebean.config.CurrentTenantProvider;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
@@ -11,7 +12,7 @@ import org.tests.model.basic.Customer;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class DefaultServerCacheManagerTest {
|
||||
class DefaultServerCacheManagerTest {
|
||||
|
||||
private final ThreadLocal<String> tenantId = new ThreadLocal<>();
|
||||
|
||||
@@ -29,7 +30,7 @@ public class DefaultServerCacheManagerTest {
|
||||
|
||||
private final DefaultServerCacheManager multiTenantManager;
|
||||
|
||||
public DefaultServerCacheManagerTest(){
|
||||
DefaultServerCacheManagerTest(){
|
||||
CacheManagerOptions builder = new CacheManagerOptions(clusterManager, new DatabaseConfig(), true);
|
||||
builder.with(new TdTenPro());
|
||||
this.multiTenantManager = new DefaultServerCacheManager(builder);
|
||||
@@ -37,86 +38,79 @@ public class DefaultServerCacheManagerTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void getCache_normal() {
|
||||
void getCache_normal() {
|
||||
ServerCache cache = cache(manager, Customer.class);
|
||||
DefaultServerCache dsc = cache.unwrap(DefaultServerCache.class);
|
||||
assertThat(dsc.getName()).isEqualTo("org.tests.model.basic.Customer_B");
|
||||
assertThat(dsc.getShortName()).isEqualTo("Customer_B");
|
||||
|
||||
DefaultServerCache cache = cache(manager, Customer.class);
|
||||
assertThat(cache.getName()).isEqualTo("org.tests.model.basic.Customer_B");
|
||||
assertThat(cache.getShortName()).isEqualTo("Customer_B");
|
||||
|
||||
DefaultServerCache cache1 = cache(manager, Customer.class);
|
||||
ServerCache cache1 = cache(manager, Customer.class);
|
||||
assertThat(cache1).isSameAs(cache);
|
||||
|
||||
DefaultServerCache cache2 = cache(manager, Contact.class);
|
||||
ServerCache cache2 = cache(manager, Contact.class);
|
||||
assertThat(cache1).isNotSameAs(cache2);
|
||||
assertThat(cache2.getName()).isEqualTo("org.tests.model.basic.Contact_B");
|
||||
assertThat(cache2.getShortName()).isEqualTo("Contact_B");
|
||||
DefaultServerCache dsc2 = cache2.unwrap(DefaultServerCache.class);
|
||||
assertThat(dsc2.getName()).isEqualTo("org.tests.model.basic.Contact_B");
|
||||
assertThat(dsc2.getShortName()).isEqualTo("Contact_B");
|
||||
|
||||
|
||||
DefaultServerCache natKeyCache = (DefaultServerCache) manager.getNaturalKeyCache(Customer.class);
|
||||
assertThat(natKeyCache.getName()).isEqualTo("org.tests.model.basic.Customer_N");
|
||||
assertThat(natKeyCache.getShortName()).isEqualTo("Customer_N");
|
||||
ServerCache natKeyCache = manager.getNaturalKeyCache(Customer.class);
|
||||
DefaultServerCache dscNatKey = natKeyCache.unwrap(DefaultServerCache.class);
|
||||
assertThat(dscNatKey.getName()).isEqualTo("org.tests.model.basic.Customer_N");
|
||||
assertThat(dscNatKey.getShortName()).isEqualTo("Customer_N");
|
||||
|
||||
DefaultServerCache queryCache = (DefaultServerCache) manager.getQueryCache(Customer.class);
|
||||
assertThat(queryCache.getName()).isEqualTo("org.tests.model.basic.Customer_Q");
|
||||
assertThat(queryCache.getShortName()).isEqualTo("Customer_Q");
|
||||
ServerCache queryCache = manager.getQueryCache(Customer.class);
|
||||
DefaultServerCache dscQueryCache = queryCache.unwrap(DefaultServerCache.class);
|
||||
assertThat(dscQueryCache.getName()).isEqualTo("org.tests.model.basic.Customer_Q");
|
||||
assertThat(dscQueryCache.getShortName()).isEqualTo("Customer_Q");
|
||||
|
||||
DefaultServerCache collCache = (DefaultServerCache) manager.getCollectionIdsCache(Customer.class, "contacts");
|
||||
assertThat(collCache.getName()).isEqualTo("org.tests.model.basic.Customer.contacts_C");
|
||||
assertThat(collCache.getShortName()).isEqualTo("Customer.contacts_C");
|
||||
ServerCache collCache = manager.getCollectionIdsCache(Customer.class, "contacts");
|
||||
DefaultServerCache dscCollCache = collCache.unwrap(DefaultServerCache.class);
|
||||
assertThat(dscCollCache.getName()).isEqualTo("org.tests.model.basic.Customer.contacts_C");
|
||||
assertThat(dscCollCache.getShortName()).isEqualTo("Customer.contacts_C");
|
||||
|
||||
cache.clearCount.reset();
|
||||
collCache.clearCount.reset();
|
||||
queryCache.clearCount.reset();
|
||||
natKeyCache.clearCount.reset();
|
||||
cache.statistics(true);
|
||||
collCache.statistics(true);
|
||||
queryCache.statistics(true);
|
||||
natKeyCache.statistics(true);
|
||||
|
||||
manager.clear(Customer.class);
|
||||
|
||||
assertThat(cache.clearCount.get(true)).isEqualTo(1);
|
||||
assertThat(natKeyCache.clearCount.get(true)).isEqualTo(1);
|
||||
assertThat(queryCache.clearCount.get(true)).isEqualTo(1);
|
||||
assertThat(collCache.clearCount.get(true)).isEqualTo(1);
|
||||
assertThat(cache.statistics(true).getClearCount()).isEqualTo(1);
|
||||
assertThat(natKeyCache.statistics(true).getClearCount()).isEqualTo(1);
|
||||
assertThat(queryCache.statistics(true).getClearCount()).isEqualTo(1);
|
||||
assertThat(collCache.statistics(true).getClearCount()).isEqualTo(1);
|
||||
}
|
||||
|
||||
private DefaultServerCache cache(DefaultServerCacheManager manager, Class<?> beanType) {
|
||||
return (DefaultServerCache) manager.getBeanCache(beanType);
|
||||
private ServerCache cache(DefaultServerCacheManager manager, Class<?> beanType) {
|
||||
return manager.getBeanCache(beanType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCache_multiTenant() {
|
||||
|
||||
void getCache_multiTenant() {
|
||||
tenantId.set("ten1");
|
||||
DefaultServerCache cache = cache(multiTenantManager, Customer.class);
|
||||
assertThat(cache.getName()).isEqualTo("org.tests.model.basic.Customer_B");
|
||||
ServerCache cache = cache(multiTenantManager, Customer.class);
|
||||
cache.put("1", "tenant1");
|
||||
|
||||
tenantId.set("ten2");
|
||||
|
||||
assertThat(cache.get("1")).isNull();
|
||||
|
||||
tenantId.set("ten1");
|
||||
|
||||
assertThat(cache.get("1")).isNotNull();
|
||||
|
||||
assertThat(cache.get("1")).isEqualTo("tenant1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCache_singleTenant() {
|
||||
|
||||
void getCache_singleTenant() {
|
||||
ServerCache cache = cache(manager, Customer.class);
|
||||
tenantId.set("ten1");
|
||||
DefaultServerCache cache = cache(manager, Customer.class);
|
||||
assertThat(cache.getName()).isEqualTo("org.tests.model.basic.Customer_B");
|
||||
|
||||
cache.put("1", "tenant1");
|
||||
|
||||
tenantId.set("ten2");
|
||||
|
||||
assertThat(cache.get("1")).isEqualTo("tenant1");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isLocalL2Caching() {
|
||||
|
||||
void isLocalL2Caching() {
|
||||
assertTrue(manager.isLocalL2Caching());
|
||||
assertTrue(multiTenantManager.isLocalL2Caching());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.ebean.bean.BeanCollection;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.common.BeanList;
|
||||
@@ -9,7 +8,6 @@ import org.tests.model.basic.Contact;
|
||||
import org.tests.model.basic.Customer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package io.ebeaninternal.server.deploy.parse;
|
||||
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
|
||||
import io.ebean.platform.sqlserver.SqlServer17Platform;
|
||||
import io.ebeaninternal.server.core.bootup.BootupClasses;
|
||||
import io.ebeaninternal.server.deploy.generatedproperty.GeneratedPropertyFactory;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
||||
|
||||
@@ -3,11 +3,8 @@ package io.ebeaninternal.server.querydefn;
|
||||
|
||||
import io.ebean.*;
|
||||
import io.ebeaninternal.api.BindValuesKey;
|
||||
import io.ebeaninternal.api.SpiQuery;
|
||||
import io.ebeaninternal.server.core.DefaultServer;
|
||||
import io.ebeaninternal.server.core.OrmQueryRequest;
|
||||
import io.ebeaninternal.server.core.OrmQueryRequestTestHelper;
|
||||
import io.ebeaninternal.server.deploy.BaseTest;
|
||||
import io.ebeaninternal.server.expression.BaseExpressionTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.Customer;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.dbplatform.postgres.PostgresPlatform;
|
||||
import io.ebean.platform.postgres.PostgresPlatform;
|
||||
import io.ebean.core.type.ScalarType;
|
||||
import io.ebeaninternal.server.core.bootup.BootupClasses;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.dbplatform.h2.H2Platform;
|
||||
import io.ebean.platform.h2.H2Platform;
|
||||
import io.ebean.core.type.DataReader;
|
||||
import io.ebean.core.type.ScalarType;
|
||||
import io.ebeaninternal.server.core.bootup.BootupClasses;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Contact {
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
List<ContactNote> notes;
|
||||
|
||||
@CreatedTimestamp
|
||||
@WhenCreated
|
||||
Timestamp cretime;
|
||||
|
||||
@Version
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Product implements Serializable {
|
||||
|
||||
String name;
|
||||
|
||||
@CreatedTimestamp
|
||||
@WhenCreated
|
||||
Timestamp cretime;
|
||||
|
||||
@Version
|
||||
|
||||
Reference in new issue
Block a user