Compare commits

..
Author SHA1 Message Date
Rob Bygrave e29e032693 [maven-release-plugin] prepare release ebean-parent-12.11.4 2021-09-09 21:57:43 +12:00
Rob Bygrave 9fc2ec044d #2362 - ENH: Add lock(bean) method as convenience for DB pessimistic locking 2021-09-09 18:18:16 +12:00
Rob Bygrave b739326fca #2361 - Update test-java16 tests - use record style accessors with entity beans 2021-09-09 12:13:34 +12:00
Rob Bygrave 88fd4f5569 #2361 - Update test-java16 test dependencies 2021-09-09 12:04:11 +12:00
Rob Bygrave 4cca3bfa98 #2361 - Tidy test dependencies bump tiles-maven-plugin 2021-09-09 11:44:27 +12:00
Rob Bygrave 8f8d031d91 #2361 - Tidy tests dependencies in ebean-core 2021-09-09 11:39:17 +12:00
Rob Bygrave 7a327cb644 #2361 - Tidy tests only, organise imports 2021-09-09 11:29:05 +12:00
Rob Bygrave 1696caadd4 #2361 - Tidy tests only, move to LoggedSql (ebean-test) 2021-09-09 11:25:04 +12:00
Rob BygraveandGitHub e5dceda4b9 Merge pull request #2361 from ebean-orm/feature/move-tests-to-ebean-test
Refactor move tests from ebean-core to ebean-test
2021-09-09 10:59:42 +12:00
rbygrave eab56d323b Refactor move tests from ebean-core to ebean-test 2021-09-08 22:49:23 +12:00
rbygrave 0b00a14fd3 Refactor tidy tests - remove unused test Main and test MainMemoryLeak 2021-09-08 21:48:53 +12:00
rbygrave c1d57c6b10 Refactor tidy tests 2021-09-08 21:47:52 +12:00
rbygrave 1049435f86 Tidy up ddl-generator BaseTestCase 2021-09-08 17:31:14 +12:00
rbygrave cee879d2f3 #2359 - Rename internal methods - BeanDescriptorManager 2021-09-08 15:34:23 +12:00
rbygrave 93ff2ef2e4 #2359 - Rename internal methods - SpiEbeanServer 2021-09-08 15:25:18 +12:00
rbygrave d389ac680f #2359 - Rename internal methods - BeanDescriptor 2021-09-08 15:17:17 +12:00
rbygrave d582e63c25 #2359 - Rename internal methods - STreeProperty 2021-09-08 14:41:12 +12:00
rbygrave cb9295658c #2359 - Rename internal methods - ElPropertyValue 2021-09-08 14:32:49 +12:00
rbygrave dbc1ab7a57 #2359 - Rename methods and tidy in cache API 2021-09-08 14:25:10 +12:00
rbygrave bb9532f42e #2359 - Rename Transaction.getConnection() method to connection() with deprecation 2021-09-08 14:17:30 +12:00
rbygrave 632f04c76b #2359 - Rename plugin api methods with deprecation - Property 2021-09-08 14:04:31 +12:00
rbygrave bc02eeac57 #2359 - Rename plugin api methods with deprecation - BeanType 2021-09-08 13:13:29 +12:00
rbygrave d6dc147497 #2359 - Rename plugin api methods with deprecation - BeanDocType 2021-09-08 10:59:20 +12:00
rbygrave a15e1ae0a7 #2359 - Rename plugin api methods with deprecation - QueryPlanMetric 2021-09-08 10:53:32 +12:00
rbygrave 8b98335e2e #2359 - Rename plugin api methods with deprecation - BeanDocType 2021-09-08 10:42:51 +12:00
rbygrave 01e07dd2be #2358 - Rename BeanState methods with deprecation 2021-09-08 10:30:18 +12:00
rbygrave 3ac8d6e1d3 #2357 - Modify ddl-generator CurrentModel away from deprecated methods 2021-09-07 21:45:23 +12:00
rbygrave 66143280fa #2357 - Update tests to move away from deprecated methods 2021-09-07 21:44:07 +12:00
rbygrave e95442d8ec #2357 - Update tests to use reference() 2021-09-07 18:13:03 +12:00
rbygrave aafde53b81 #2357 - Update tests to use beanState() 2021-09-07 18:11:51 +12:00
rbygrave 0887480865 #2357 - Update tests to use Database from EbeanServer 2021-09-07 18:10:36 +12:00
rbygrave 4ff8df9538 Tidy tests for ServerConfig -> DatabaseConfig 2021-09-07 17:33:06 +12:00
rbygrave ddb63c1488 Update tests for MariaDB 2021-09-07 16:30:39 +12:00
rbygrave aab2dff49c MySQL Ignore tests that use Hash/Source JSON dirty detection
MySQL JSON type will not preserve ordering of keys. No way to return a consistent JSON result with this type hence Hash/Source do not work
2021-09-07 16:04:07 +12:00
rbygrave d017b2ef39 MySQL Ignore tests that use Hash/Source JSON dirty detection
MySQL JSON type will not preserve ordering of keys. No way to return a consistent JSON result with this type hence Hash/Source do not work
2021-09-07 15:08:28 +12:00
rbygrave 70a967a3a7 Junit5 bump - ebean-core 2021-09-07 13:23:27 +12:00
rbygrave 796edae614 Junit5 bump - tidy ebean-test 2021-09-06 21:37:14 +12:00
rbygrave 50bb7086ac Junit5 bump - tidy ebean-test 2021-09-06 21:01:50 +12:00
rbygrave af8cf9c6c7 Junit5 bump - querybean-generator 2021-09-06 20:57:48 +12:00
rbygrave 6227b081cf Junit5 bump - ebean-test 2021-09-06 20:55:09 +12:00
rbygrave 42645f7236 Junit5 bump - ebean-redis 2021-09-06 20:51:58 +12:00
rbygrave eae8bbac82 Junit5 bump - ebean-querybean 2021-09-06 18:05:11 +12:00
rbygrave 43451c5342 Junit5 bump - ebean-postgis 2021-09-06 17:59:01 +12:00
rbygrave a6f27ca19f Junit5 bump - ebean-externalmapping-xml 2021-09-06 17:53:17 +12:00
rbygrave a7462e86c8 Junit5 bump - ebean-ddl-generator, autotune and api 2021-09-06 17:49:23 +12:00
rbygrave 0ddcfec70d Junit5 bump - ebean-ddl-generator, autotune and api 2021-09-06 17:49:06 +12:00
rbygrave bf70470b9a Junit5 bump - remove parent junit dependency 2021-09-06 16:55:11 +12:00
rbygrave 23c5bd65cf [maven-release-plugin] prepare for next development iteration 2021-09-05 10:54:24 +12:00
rbygrave 30aa05a243 [maven-release-plugin] prepare release ebean-parent-12.11.3 2021-09-05 10:54:17 +12:00
rbygrave 4ce70e401d No functional change - Simplify BeanDescriptor.isIdLoaded() 2021-09-04 22:24:59 +12:00
rbygrave a2f49a544c #2355 - Rename methods in SpiServer with deprecation 2021-09-04 22:01:16 +12:00
rbygrave 4d4065c54b #2355 - Rename methods in SpiServer with deprecation 2021-09-04 21:55:23 +12:00
rbygrave d072dd52cf #2355 - Rename methods in SpiServer with deprecation 2021-09-03 20:17:12 +12:00
rbygrave 25b9b37ac0 #2354 - Refactor internals - refactor rename methods in BeanRequest etc 2021-09-03 19:53:36 +12:00
rbygrave 5ea5b55882 #2353 Refactor rename internal methods for BeanRequest 2021-09-03 19:04:48 +12:00
rbygrave b69c00b01e #2353 - Rename BeanPersistRequest methods with deprecation 2021-09-03 18:01:27 +12:00
rbygrave aa53742a07 #2352 - Rename ServerCache methods with deprecation 2021-09-03 17:24:33 +12:00
rbygrave 7c2a77081b #2351 - Rename Database.getReference() to reference() with deprecation 2021-09-03 10:50:29 +12:00
rbygrave 57c0bceb63 #2351 - Rename Database.getReference() to reference() with deprecation 2021-09-03 10:47:56 +12:00
rbygrave 8cb43788dc #2350 - Rename Database.getBeanState() to beanState() with deprecation 2021-09-03 09:55:48 +12:00
rbygrave 921ee9f8a1 #2345 - Rename Database.getExpressionFactory() to expressionFactory with deprecation 2021-09-03 09:46:04 +12:00
rbygrave 058e16d1a8 #2349 - Rename Database.getBeanId() to beanId() with deprecation 2021-09-03 09:32:47 +12:00
rbygrave a5f9beabdf #2349 - Rename Database.getBeanId() to beanId() with deprecation 2021-09-03 09:31:16 +12:00
Rob Bygrave 0ed6ccf499 #2348 - Rename Database.getServerCacheManager() to cacheManager() with deprecation 2021-09-02 23:14:33 +12:00
Rob Bygrave fe67abce83 #2347 - Rename Database.getPlatform() to platform() with deprecation 2021-09-02 23:04:57 +12:00
Rob Bygrave 7fba9adc43 #2346 - Rename Database.getMetaInfoManager() to metaInfo() with deprecation 2021-09-02 22:58:09 +12:00
Rob Bygrave 4557bdfa6f #2345 - Rename Database.getExpressionFactory() to expressionFactory with deprecation 2021-09-02 22:55:47 +12:00
Rob Bygrave 7a7dbae313 #2342 - Rename Database.getName() to Database.name() with deprecation 2021-09-02 22:52:34 +12:00
Rob Bygrave 12c5e9ea5d #2344 - Rename Database.getDataSource() to dataSource() with deprecation 2021-09-02 22:48:09 +12:00
Rob Bygrave 239a444d4c #2343 - Rename Database.getAutoTune() to autoTune() with deprecation 2021-09-02 22:44:31 +12:00
Rob Bygrave f770b66f42 #2342 - Rename Database.getName() to Database.name() with deprecation 2021-09-02 22:41:51 +12:00
Rob Bygrave 6311d0bf4e No effective change - javadoc for ServerCache 2021-09-02 22:36:02 +12:00
Rob Bygrave 491d6a5461 #2341 - Refactor internal api LoadBeanBuffer LoadBeanRequest etc 2021-09-02 22:09:34 +12:00
Rob Bygrave b142319da0 Refactor tidy methods in LoadBeanRequest, LoadManyRequest, LoadRequest and DefaultBeanLoader 2021-09-02 21:50:43 +12:00
Rob Bygrave ac21fcb5cf Simplify load description in LoadBeanRequest and LoadManyRequest 2021-09-02 19:28:24 +12:00
Rob Bygrave 455914fb52 Use cast built into BeanDescriptor.beanId() rather than cast + getId() 2021-09-02 19:25:02 +12:00
Rob Bygrave 2419c6ab34 #2335 ReadOnly propagation test requiring cache clear 2021-09-02 19:23:40 +12:00
Rob BygraveandGitHub 8a0403ef6b Merge pull request #2340 from ebean-orm/feature/2335
#2335 -  L2 cache be triggered by in ?
2021-09-02 19:08:36 +12:00
rbygrave e0afeea6c4 #2335 - Modify test - Put back readOnly assert (#2340) 2021-09-02 19:03:54 +12:00
Rob BygraveandGitHub dd8b4f6416 Merge pull request #2338 from FOCONIS/delete-id-request-getbeantype
NEW: DeleteIdRequest can return beanType
2021-09-02 17:46:11 +12:00
rbygrave 97482c3372 No effective change - tidy DefaultCallableSql 2021-09-02 17:45:30 +12:00
rbygrave d2e36fc1d2 No effective change - tidy DefaultSqlUpdate raw types 2021-09-02 17:34:45 +12:00
rbygrave 99acd6d64f Tidy test only - static imports for QCustomerByteArrayTest 2021-09-02 17:28:04 +12:00
rbygrave 6fe6b8ba64 #2335 - L2 cache be triggered by in ? 2021-09-02 17:10:56 +12:00
Rob BygraveandGitHub c2b947d2e6 Merge pull request #2337 from Ryszard-Trojnacki/master
Query bean PByteArray type for byte[]
2021-09-02 15:05:20 +12:00
Rob BygraveandGitHub 7d6b25ff59 Merge pull request #2339 from FOCONIS/master12
No effective code change: Add missing @Override annotation
2021-09-02 15:02:03 +12:00
rbygrave d9cef737e3 #2335 Initial test work 2021-09-02 11:57:59 +12:00
rob 2f18e97a44 Allow format() for types UUID to handle string input 2021-09-02 11:52:26 +12:00
rob bf3c1629f7 Allow format() for types Integer and Long to handle string input 2021-09-02 11:44:51 +12:00
rob 1062adede4 No effective change - change setUseCache(false) to setBeanCacheMode(CacheMode.OFF) 2021-09-02 10:26:14 +12:00
rob 47c9a434bb Test tidy - remove @Cache from Order model 2021-09-02 10:15:33 +12:00
Roland Praml b2bfca7ec6 no effective code change: Add missing @Override annotation and removed duplicate methods in interfaces 2021-09-01 09:58:27 +02:00
Roland Praml 5d84f10110 NEW DeleteIdRequest can return beantype. Also provide alternative for deprecated 'getEbeanServer' 2021-09-01 09:44:31 +02:00
Ryszard Trojnacki 847ce5db88 Added PByteArray query bean type for byte[] column type. 2021-08-31 11:34:35 +02:00
Ryszard TrojnackiandGitHub afdfbd6173 Merge branch 'ebean-orm:master' into master 2021-08-31 09:46:26 +02:00
rbygrave c0007d3c1a [maven-release-plugin] prepare for next development iteration 2021-08-31 17:21:59 +12:00
Ryszard TrojnackiandGitHub 40a4546ac6 Merge pull request #4 from ebean-orm/master
Update to head
2020-11-28 13:16:05 +01:00
2065 changed files with 15492 additions and 14458 deletions
+8 -1
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.11.2</version>
<version>12.11.4</version>
</parent>
<name>ebean api</name>
@@ -104,6 +104,13 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
+131
View File
@@ -0,0 +1,131 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.11.4-SNAPSHOT</version>
</parent>
<name>ebean api</name>
<description>ebean api</description>
<artifactId>ebean-api</artifactId>
<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.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-config</artifactId>
<version>1.3</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>7.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-types</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource-api</artifactId>
<version>${ebean-datasource.version}</version>
</dependency>
<!-- Jackson core used internally by Ebean -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
<!-- provided scope for JsonNode support -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.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>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</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>
@@ -79,11 +79,11 @@ public abstract class BeanFinder<I,T> {
/**
* Creates an entity reference for this ID.
* <p>
* Equivalent to {@link Database#getReference(Class, Object)}
* Equivalent to {@link Database#reference(Class, Object)}
*/
@Nonnull
public T ref(I id) {
return db().getReference(type, id);
return db().reference(type, id);
}
/**
@@ -57,7 +57,7 @@ public interface BeanState {
*
* // set loaded state on the email property to false so that
* // the email property is not included in a stateless update
* DB.getBeanState(user).setPropertyLoaded("email", false);
* DB.beanState(user).setPropertyLoaded("email", false);
*
* user.update();
*
@@ -72,25 +72,47 @@ public interface BeanState {
* bean.
* <p>
* Accessing another property will cause lazy loading to occur.
* </p>
*/
Set<String> getLoadedProps();
Set<String> loadedProps();
/**
* Deprecated migrate to loadedProps().
*/
@Deprecated
default Set<String> getLoadedProps() {
return loadedProps();
}
/**
* Return the set of changed properties.
*/
Set<String> getChangedProps();
Set<String> changedProps();
/**
* Deprecated migrate to changedProps().
*/
@Deprecated
default Set<String> getChangedProps() {
return changedProps();
}
/**
* Return a map of the updated properties and their new and old values.
*/
Map<String, ValuePair> getDirtyValues();
Map<String, ValuePair> dirtyValues();
/**
* Deprecated migrate to dirtyValues().
*/
@Deprecated
default Map<String, ValuePair> getDirtyValues() {
return dirtyValues();
}
/**
* Return true if the bean is readOnly.
* <p>
* If a setter is called on a readOnly bean it will throw an exception.
* </p>
*/
boolean isReadOnly();
@@ -114,13 +136,29 @@ public interface BeanState {
void resetForInsert();
/**
* Returns a map with load erros.
* Returns a map with load errors.
*/
@Nullable
Map<String, Exception> getLoadErrors();
Map<String, Exception> loadErrors();
/**
* Deprecated migrate to loadErrors().
*/
@Deprecated
default Map<String, Exception> getLoadErrors() {
return loadErrors();
}
/**
* Return the sort order value for an order column.
*/
int getSortOrder();
int sortOrder();
/**
* Deprecated migrate to sortOrder().
*/
@Deprecated
default int getSortOrder() {
return sortOrder();
}
}
+71 -10
View File
@@ -126,8 +126,16 @@ public final class DB {
* an expression that uses OR like Expression e = Expr.or(..., ...);
* </p>
*/
public static ExpressionFactory expressionFactory() {
return getDefault().expressionFactory();
}
/**
* Deprecated migrate to expressionFactory().
*/
@Deprecated
public static ExpressionFactory getExpressionFactory() {
return getDefault().getExpressionFactory();
return expressionFactory();
}
/**
@@ -650,8 +658,16 @@ public final class DB {
* @param beanType the type of entity bean
* @param id the id value
*/
public static <T> T reference(Class<T> beanType, Object id) {
return getDefault().reference(beanType, id);
}
/**
* Deprecated migrate to beanId().
*/
@Deprecated
public static <T> T getReference(Class<T> beanType, Object id) {
return getDefault().getReference(beanType, id);
return reference(beanType, id);
}
/**
@@ -660,14 +676,12 @@ public final class DB {
* <ul>
* <li>asc - ascending order (which is the default)</li>
* <li>desc - Descending order</li>
* <li>nullsHigh - Treat null values as high/large values (which is the
* default)</li>
* <li>nullsHigh - Treat null values as high/large values (which is the default)</li>
* <li>nullsLow- Treat null values as low/very small values</li>
* </ul>
* <p>
* If you leave off any keywords the defaults are ascending order and treating
* nulls as high values.
* </p>
* <p>
* Note that the sorting uses a Comparator and Collections.sort(); and does
* not invoke a DB query.
@@ -1231,30 +1245,77 @@ public final class DB {
* This will return null if the bean is not an enhanced entity bean.
* </p>
*/
public static BeanState beanState(Object bean) {
return getDefault().beanState(bean);
}
/**
* Deprecated migrate to beanState().
*/
@Deprecated
public static BeanState getBeanState(Object bean) {
return getDefault().getBeanState(bean);
return beanState(bean);
}
/**
* Return the value of the Id property for a given bean.
*/
public static Object beanId(Object bean) {
return getDefault().beanId(bean);
}
/**
* Deprecated migrate to beanId().
*/
@Deprecated
public static Object getBeanId(Object bean) {
return getDefault().getBeanId(bean);
return beanId(bean);
}
/**
* Load and lock the bean using {@code select for update}.
* <p>
* This should be executed inside a transaction.
* <p>
* The bean needs to have an ID property set and can be a reference bean (only has ID)
* or partially or fully populated bean. This will load all the properties of the bean
* from the database using {@code select for update}.
*
* @param bean The entity bean that we wish to obtain a database lock on.
*/
public static void lock(Object bean) {
getDefault().lock(bean);
}
/**
* Deprecated migrate to cacheManager().
*/
@Deprecated
public static ServerCacheManager getServerCacheManager() {
return getDefault().cacheManager();
}
/**
* Return the manager of the level 2 cache ("L2" cache).
*/
public static ServerCacheManager getServerCacheManager() {
return getDefault().getServerCacheManager();
public static ServerCacheManager cacheManager() {
return getDefault().cacheManager();
}
/**
* Return the BackgroundExecutor service for asynchronous processing of
* queries.
*/
public static BackgroundExecutor backgroundExecutor() {
return getDefault().backgroundExecutor();
}
/**
* Deprecated migrate to backgroundExecutor().
*/
@Deprecated
public static BackgroundExecutor getBackgroundExecutor() {
return getDefault().getBackgroundExecutor();
return backgroundExecutor();
}
/**
+140 -14
View File
@@ -120,34 +120,82 @@ public interface Database {
/**
* Return AutoTune which is used to control the AutoTune service at runtime.
*/
AutoTune getAutoTune();
AutoTune autoTune();
/**
* Deprecated migrate to autoTune().
*/
@Deprecated
default AutoTune getAutoTune() {
return autoTune();
}
/**
* Return the associated DataSource for this Database instance.
*/
DataSource getDataSource();
DataSource dataSource();
/**
* Deprecated migrate to dataSource().
*/
@Deprecated
default DataSource getDataSource() {
return dataSource();
}
/**
* Return the associated read only DataSource for this Database instance (can be null).
*/
DataSource getReadOnlyDataSource();
DataSource readOnlyDataSource();
/**
* Deprecated migrate to readOnlyDataSource().
*/
@Deprecated
default DataSource getReadOnlyDataSource() {
return readOnlyDataSource();
}
/**
* Return the name. This is used with {@link DB#byName(String)} to get a
* Database that was registered with the DB singleton.
*/
String getName();
String name();
/**
* Deprecated migrate to name().
*/
@Deprecated
default String getName() {
return name();
}
/**
* Return the ExpressionFactory for this database.
*/
ExpressionFactory getExpressionFactory();
ExpressionFactory expressionFactory();
/**
* Deprecated migrate to expressionFactory().
*/
@Deprecated
default ExpressionFactory getExpressionFactory() {
return expressionFactory();
}
/**
* Return the MetaInfoManager which is used to get meta data from the Database
* such as query execution statistics.
*/
MetaInfoManager getMetaInfoManager();
MetaInfoManager metaInfo();
/**
* Deprecated migrate to metaInfo().
*/
@Deprecated
default MetaInfoManager getMetaInfoManager() {
return metaInfo();
}
/**
* Return the platform used for this database instance.
@@ -166,12 +214,28 @@ public interface Database {
*
* @return platform for this database instance
*/
Platform getPlatform();
Platform platform();
/**
* Deprecated migrate to platform().
*/
@Deprecated
default Platform getPlatform() {
return platform();
}
/**
* Return the extended API intended for use by plugins.
*/
SpiServer getPluginApi();
SpiServer pluginApi();
/**
* Deprecated migrate to pluginApi().
*/
@Deprecated
default SpiServer getPluginApi() {
return pluginApi();
}
/**
* Return the BeanState for a given entity bean.
@@ -179,12 +243,28 @@ public interface Database {
* This will return null if the bean is not an enhanced entity bean.
* </p>
*/
BeanState getBeanState(Object bean);
BeanState beanState(Object bean);
/**
* Deprecated migrate to beanState().
*/
@Deprecated
default BeanState getBeanState(Object bean) {
return beanState(bean);
}
/**
* Return the value of the Id property for a given bean.
*/
Object getBeanId(Object bean);
Object beanId(Object bean);
/**
* Deprecated migrate to beanId().
*/
@Deprecated
default Object getBeanId(Object bean) {
return beanId(bean);
}
/**
* Set the Id value onto the bean converting the type of the id value if necessary.
@@ -196,7 +276,15 @@ public interface Database {
* @param bean The entity bean to set the id value on.
* @param id The id value to set.
*/
Object setBeanId(Object bean, Object id);
Object beanId(Object bean, Object id);
/**
* Deprecated migrate to beanId().
*/
@Deprecated
default Object setBeanId(Object bean, Object id) {
return beanId(bean, id);
}
/**
* Return a map of the differences between two objects of the same type.
@@ -862,7 +950,15 @@ public interface Database {
* @param id the id value
*/
@Nonnull
<T> T getReference(Class<T> beanType, Object id);
<T> T reference(Class<T> beanType, Object id);
/**
* Deprecated migrate to reference().
*/
@Deprecated
default <T> T getReference(Class<T> beanType, Object id) {
return reference(beanType, id);
}
/**
* Return the extended API for Database.
@@ -1431,13 +1527,29 @@ public interface Database {
/**
* Return the manager of the server cache ("L2" cache).
*/
ServerCacheManager getServerCacheManager();
ServerCacheManager cacheManager();
/**
* Deprecated migrate to cacheManager().
*/
@Deprecated
default ServerCacheManager getServerCacheManager() {
return cacheManager();
}
/**
* Return the BackgroundExecutor service for asynchronous processing of
* queries.
*/
BackgroundExecutor getBackgroundExecutor();
BackgroundExecutor backgroundExecutor();
/**
* Deprecated migrate to backgroundExecutor().
*/
@Deprecated
default BackgroundExecutor getBackgroundExecutor() {
return backgroundExecutor();
}
/**
* Return the JsonContext for reading/writing JSON.
@@ -1602,6 +1714,20 @@ public interface Database {
*/
<T> Set<String> validateQuery(Query<T> query);
/**
* Load and lock the bean using {@code select for update}.
* <p>
* This should be executed inside a transaction and results in the bean being loaded or
* refreshed from the database and a database row lock held via {@code select for update}.
* <p>
* The bean needs to have an ID property set and can be a reference bean (only has ID)
* or partially or fully populated bean. This will load all the properties of the bean
* from the database using {@code select for update} obtaining a database row lock (using WAIT).
*
* @param bean The entity bean that we wish to obtain a database lock on.
*/
void lock(Object bean);
/**
* Truncate all the given tables.
*/
@@ -115,7 +115,7 @@ final class DbContext {
* Register a server so we can get it by its name.
*/
void register(Database server, boolean isDefault) {
registerWithName(server.getName(), server, isDefault);
registerWithName(server.name(), server, isDefault);
}
private void registerWithName(String name, Database server, boolean isDefault) {
+5 -5
View File
@@ -103,7 +103,7 @@ public final class Ebean {
* </p>
*/
public static ExpressionFactory getExpressionFactory() {
return getDefault().getExpressionFactory();
return getDefault().expressionFactory();
}
/**
@@ -642,7 +642,7 @@ public final class Ebean {
* @param id the id value
*/
public static <T> T getReference(Class<T> beanType, Object id) {
return getDefault().getReference(beanType, id);
return getDefault().reference(beanType, id);
}
/**
@@ -1201,14 +1201,14 @@ public final class Ebean {
* </p>
*/
public static BeanState getBeanState(Object bean) {
return getDefault().getBeanState(bean);
return getDefault().beanState(bean);
}
/**
* Return the manager of the server cache ("L2" cache).
*/
public static ServerCacheManager getServerCacheManager() {
return getDefault().getServerCacheManager();
return getDefault().cacheManager();
}
/**
@@ -1216,7 +1216,7 @@ public final class Ebean {
* queries.
*/
public static BackgroundExecutor getBackgroundExecutor() {
return getDefault().getBackgroundExecutor();
return getDefault().backgroundExecutor();
}
/**
+40 -45
View File
@@ -16,7 +16,7 @@ import java.util.Map;
* This provides a convenient way to create expressions for the default
* database.
* <p>
* See also {@link DB#getExpressionFactory()}
* See also {@link DB#expressionFactory()}
* </p>
* <p>
* Creates standard common expressions for using in a Query Where or Having
@@ -34,14 +34,14 @@ public class Expr {
* Equal To - property equal to the given value.
*/
public static Expression eq(String propertyName, Object value) {
return DB.getExpressionFactory().eq(propertyName, value);
return DB.expressionFactory().eq(propertyName, value);
}
/**
* Not Equal To - property not equal to the given value.
*/
public static Expression ne(String propertyName, Object value) {
return DB.getExpressionFactory().ne(propertyName, value);
return DB.expressionFactory().ne(propertyName, value);
}
/**
@@ -49,7 +49,7 @@ public class Expr {
* using a lower() function to make it case insensitive).
*/
public static Expression ieq(String propertyName, String value) {
return DB.getExpressionFactory().ieq(propertyName, value);
return DB.expressionFactory().ieq(propertyName, value);
}
/**
@@ -59,28 +59,28 @@ public class Expr {
* </p>
*/
public static Expression inRange(String propertyName, Object value1, Object value2) {
return DB.getExpressionFactory().inRange(propertyName, value1, value2);
return DB.expressionFactory().inRange(propertyName, value1, value2);
}
/**
* Between - property between the two given values.
*/
public static Expression between(String propertyName, Object value1, Object value2) {
return DB.getExpressionFactory().between(propertyName, value1, value2);
return DB.expressionFactory().between(propertyName, value1, value2);
}
/**
* Between - value between two given properties.
*/
public static Expression between(String lowProperty, String highProperty, Object value) {
return DB.getExpressionFactory().betweenProperties(lowProperty, highProperty, value);
return DB.expressionFactory().betweenProperties(lowProperty, highProperty, value);
}
/**
* Greater Than - property greater than the given value.
*/
public static Expression gt(String propertyName, Object value) {
return DB.getExpressionFactory().gt(propertyName, value);
return DB.expressionFactory().gt(propertyName, value);
}
/**
@@ -88,42 +88,42 @@ public class Expr {
* value.
*/
public static Expression ge(String propertyName, Object value) {
return DB.getExpressionFactory().ge(propertyName, value);
return DB.expressionFactory().ge(propertyName, value);
}
/**
* Less Than - property less than the given value.
*/
public static Expression lt(String propertyName, Object value) {
return DB.getExpressionFactory().lt(propertyName, value);
return DB.expressionFactory().lt(propertyName, value);
}
/**
* Less Than or Equal to - property less than or equal to the given value.
*/
public static Expression le(String propertyName, Object value) {
return DB.getExpressionFactory().le(propertyName, value);
return DB.expressionFactory().le(propertyName, value);
}
/**
* Is Null - property is null.
*/
public static Expression isNull(String propertyName) {
return DB.getExpressionFactory().isNull(propertyName);
return DB.expressionFactory().isNull(propertyName);
}
/**
* Is Not Null - property is not null.
*/
public static Expression isNotNull(String propertyName) {
return DB.getExpressionFactory().isNotNull(propertyName);
return DB.expressionFactory().isNotNull(propertyName);
}
/**
* Case insensitive {@link #exampleLike(Object)}
*/
public static ExampleExpression iexampleLike(Object example) {
return DB.getExpressionFactory().iexampleLike(example);
return DB.expressionFactory().iexampleLike(example);
}
/**
@@ -131,14 +131,14 @@ public class Expr {
* LikeType.RAW (you need to add you own wildcards % and _).
*/
public static ExampleExpression exampleLike(Object example) {
return DB.getExpressionFactory().exampleLike(example);
return DB.expressionFactory().exampleLike(example);
}
/**
* Create the query by Example expression specifying more options.
*/
public static ExampleExpression exampleLike(Object example, boolean caseInsensitive, LikeType likeType) {
return DB.getExpressionFactory().exampleLike(example, caseInsensitive, likeType);
return DB.expressionFactory().exampleLike(example, caseInsensitive, likeType);
}
/**
@@ -146,7 +146,7 @@ public class Expr {
* characters % (percentage) and _ (underscore).
*/
public static Expression like(String propertyName, String value) {
return DB.getExpressionFactory().like(propertyName, value);
return DB.expressionFactory().like(propertyName, value);
}
/**
@@ -155,14 +155,14 @@ public class Expr {
* a lower() function to make the expression case insensitive.
*/
public static Expression ilike(String propertyName, String value) {
return DB.getExpressionFactory().ilike(propertyName, value);
return DB.expressionFactory().ilike(propertyName, value);
}
/**
* Starts With - property like value%.
*/
public static Expression startsWith(String propertyName, String value) {
return DB.getExpressionFactory().startsWith(propertyName, value);
return DB.expressionFactory().startsWith(propertyName, value);
}
/**
@@ -170,14 +170,14 @@ public class Expr {
* lower() function to make the expression case insensitive.
*/
public static Expression istartsWith(String propertyName, String value) {
return DB.getExpressionFactory().istartsWith(propertyName, value);
return DB.expressionFactory().istartsWith(propertyName, value);
}
/**
* Ends With - property like %value.
*/
public static Expression endsWith(String propertyName, String value) {
return DB.getExpressionFactory().endsWith(propertyName, value);
return DB.expressionFactory().endsWith(propertyName, value);
}
/**
@@ -185,14 +185,14 @@ public class Expr {
* function to make the expression case insensitive.
*/
public static Expression iendsWith(String propertyName, String value) {
return DB.getExpressionFactory().iendsWith(propertyName, value);
return DB.expressionFactory().iendsWith(propertyName, value);
}
/**
* Contains - property like %value%.
*/
public static Expression contains(String propertyName, String value) {
return DB.getExpressionFactory().contains(propertyName, value);
return DB.expressionFactory().contains(propertyName, value);
}
/**
@@ -200,42 +200,42 @@ public class Expr {
* function to make the expression case insensitive.
*/
public static Expression icontains(String propertyName, String value) {
return DB.getExpressionFactory().icontains(propertyName, value);
return DB.expressionFactory().icontains(propertyName, value);
}
/**
* For collection properties that are empty (have not existing elements).
*/
public static Expression isEmpty(String propertyName) {
return DB.getExpressionFactory().isEmpty(propertyName);
return DB.expressionFactory().isEmpty(propertyName);
}
/**
* For collection properties that are not empty (have existing elements).
*/
public static Expression isNotEmpty(String propertyName) {
return DB.getExpressionFactory().isNotEmpty(propertyName);
return DB.expressionFactory().isNotEmpty(propertyName);
}
/**
* In - property has a value in the array of values.
*/
public static Expression in(String propertyName, Object[] values) {
return DB.getExpressionFactory().in(propertyName, values);
return DB.expressionFactory().in(propertyName, values);
}
/**
* In - using a subQuery.
*/
public static Expression in(String propertyName, Query<?> subQuery) {
return DB.getExpressionFactory().in(propertyName, subQuery);
return DB.expressionFactory().in(propertyName, subQuery);
}
/**
* In - property has a value in the collection of values.
*/
public static Expression in(String propertyName, Collection<?> values) {
return DB.getExpressionFactory().in(propertyName, values);
return DB.expressionFactory().in(propertyName, values);
}
/**
@@ -272,14 +272,14 @@ public class Expr {
* }</pre>
*/
public static Expression inOrEmpty(String propertyName, Collection<?> values) {
return DB.getExpressionFactory().inOrEmpty(propertyName, values);
return DB.expressionFactory().inOrEmpty(propertyName, values);
}
/**
* Id Equal to - ID property is equal to the value.
*/
public static Expression idEq(Object value) {
return DB.getExpressionFactory().idEq(value);
return DB.expressionFactory().idEq(value);
}
/**
@@ -292,7 +292,7 @@ public class Expr {
* @param propertyMap a map keyed by property names.
*/
public static Expression allEq(Map<String, Object> propertyMap) {
return DB.getExpressionFactory().allEq(propertyMap);
return DB.expressionFactory().allEq(propertyMap);
}
/**
@@ -303,7 +303,7 @@ public class Expr {
* </p>
*/
public static Expression raw(String raw, Object value) {
return DB.getExpressionFactory().raw(raw, value);
return DB.expressionFactory().raw(raw, value);
}
/**
@@ -314,53 +314,48 @@ public class Expr {
* </p>
*/
public static Expression raw(String raw, Object[] values) {
return DB.getExpressionFactory().raw(raw, values);
return DB.expressionFactory().raw(raw, values);
}
/**
* Add raw expression with no parameters.
*/
public static Expression raw(String raw) {
return DB.getExpressionFactory().raw(raw);
return DB.expressionFactory().raw(raw);
}
/**
* And - join two expressions with a logical and.
*/
public static Expression and(Expression expOne, Expression expTwo) {
return DB.getExpressionFactory().and(expOne, expTwo);
return DB.expressionFactory().and(expOne, expTwo);
}
/**
* Or - join two expressions with a logical or.
*/
public static Expression or(Expression expOne, Expression expTwo) {
return DB.getExpressionFactory().or(expOne, expTwo);
return DB.expressionFactory().or(expOne, expTwo);
}
/**
* Negate the expression (prefix it with NOT).
*/
public static Expression not(Expression exp) {
return DB.getExpressionFactory().not(exp);
return DB.expressionFactory().not(exp);
}
/**
* Return a list of expressions that will be joined by AND's.
*/
public static <T> Junction<T> conjunction(Query<T> query) {
return DB.getExpressionFactory().conjunction(query);
return DB.expressionFactory().conjunction(query);
}
/**
* Return a list of expressions that will be joined by OR's.
*/
public static <T> Junction<T> disjunction(Query<T> query) {
return DB.getExpressionFactory().disjunction(query);
return DB.expressionFactory().disjunction(query);
}
}
+2 -2
View File
@@ -137,11 +137,11 @@ public class Finder<I, T> {
/**
* Creates an entity reference for this ID.
* <p>
* Equivalent to {@link Database#getReference(Class, Object)}
* Equivalent to {@link Database#reference(Class, Object)}
*/
@Nonnull
public T ref(I id) {
return db().getReference(type, id);
return db().reference(type, id);
}
/**
@@ -538,7 +538,15 @@ public interface Transaction extends AutoCloseable {
* Examples of when a developer may wish to use the connection directly are:
* Savepoints, advanced CLOB BLOB use and advanced stored procedure calls.
*/
Connection getConnection();
Connection connection();
/**
* Deprecated migrate to connection().
*/
@Deprecated
default Connection getConnection() {
return connection();
}
/**
* Add table modification information to the TransactionEvent.
@@ -11,7 +11,7 @@ public interface BeanCollectionLoader {
/**
* Return the name of the associated Database.
*/
String getName();
String name();
/**
* Invoke the lazy loading for this bean collection.
@@ -843,7 +843,7 @@ public final class EntityBeanIntercept implements Serializable {
}
// For stand alone reference bean or after deserialisation lazy load
// using the ebeanServer. Synchronise only on the bean.
loadBeanInternal(loadProperty, database.getPluginApi().beanLoader());
loadBeanInternal(loadProperty, database.pluginApi().beanLoader());
return;
}
} finally {
@@ -20,7 +20,7 @@ public abstract class SingleBeanLoader implements BeanLoader {
@Override
public String getName() {
return database.getName();
return database.name();
}
@Override
@@ -39,7 +39,7 @@ public abstract class SingleBeanLoader implements BeanLoader {
@Override
public void loadBean(EntityBeanIntercept ebi) {
database.getPluginApi().loadBeanL2(ebi);
database.pluginApi().loadBeanL2(ebi);
}
}
@@ -53,7 +53,7 @@ public abstract class SingleBeanLoader implements BeanLoader {
@Override
public void loadBean(EntityBeanIntercept ebi) {
database.getPluginApi().loadBeanRef(ebi);
database.pluginApi().loadBeanRef(ebi);
}
}
@@ -67,7 +67,7 @@ public abstract class SingleBeanLoader implements BeanLoader {
@Override
public void loadBean(EntityBeanIntercept ebi) {
database.getPluginApi().loadBean(ebi);
database.pluginApi().loadBean(ebi);
}
}
}
@@ -13,9 +13,7 @@ import java.util.Set;
public class QueryCacheEntry {
private final Object value;
private final Set<String> dependentTables;
private final long timestamp;
/**
+19 -3
View File
@@ -10,17 +10,17 @@ import java.util.Set;
* Represents part of the "L2" server side cache.
* <p>
* This is used to cache beans or query results (bean collections).
* </p>
* <p>
* There are 2 ServerCache's for each bean type. One is used as the 'bean cache'
* which holds beans of a given type. The other is the 'query cache' holding
* query results for a given type.
* </p>
*/
public interface ServerCache {
/**
* Get values for many keys.
*/
default Map<Object, Object> getAll(Set<Object> keys) {
Map<Object, Object> map = new LinkedHashMap<>();
for (Object key : keys) {
Object value = get(key);
@@ -73,6 +73,14 @@ public interface ServerCache {
/**
* Return the hit ratio the cache is currently getting.
*/
default int hitRatio() {
return getHitRatio();
}
/**
* Deprecated migrate to hitRatio().
*/
@Deprecated
int getHitRatio();
/**
@@ -80,6 +88,14 @@ public interface ServerCache {
*
* @param reset if true the statistics are reset.
*/
default ServerCacheStatistics statistics(boolean reset) {
return getStatistics(reset);
}
/**
* Deprecated migrate to statistics().
*/
@Deprecated
ServerCacheStatistics getStatistics(boolean reset);
/**
@@ -21,7 +21,15 @@ public interface ServerCacheManager {
* rather than background processing.
* </p>
*/
boolean isLocalL2Caching();
boolean localL2Caching();
/**
* Deprecated migrate to localL2Caching().
*/
@Deprecated
default boolean isLocalL2Caching() {
return localL2Caching();
}
/**
* Return all the cache regions.
@@ -36,37 +44,78 @@ public interface ServerCacheManager {
*
* @param regions A region name or comma delimited list of region names.
*/
void setEnabledRegions(String regions);
void enabledRegions(String regions);
/**
* Deprecated migrate to enabledRegions().
*/
@Deprecated
default void setEnabledRegions(String regions) {
enabledRegions(regions);
}
/**
* Enable or disable all the cache regions.
*/
void setAllRegionsEnabled(boolean enabled);
void allRegionsEnabled(boolean enabled);
/**
* Return the cache region by name. Typically to enable or disable the region.
* Deprecated migrate to allRegionsEnabled().
*/
ServerCacheRegion getRegion(String name);
@Deprecated
default void setAllRegionsEnabled(boolean enabled) {
allRegionsEnabled(enabled);
}
/**
* Return the cache region by name. Typically, to enable or disable the region.
*/
ServerCacheRegion region(String name);
@Deprecated
default ServerCacheRegion getRegion(String name) {
return region(name);
}
/**
* Return the cache for mapping natural keys to id values.
*/
ServerCache getNaturalKeyCache(Class<?> beanType);
ServerCache naturalKeyCache(Class<?> beanType);
@Deprecated
default ServerCache getNaturalKeyCache(Class<?> beanType) {
return naturalKeyCache(beanType);
}
/**
* Return the cache for beans of a particular type.
*/
ServerCache getBeanCache(Class<?> beanType);
ServerCache beanCache(Class<?> beanType);
@Deprecated
default ServerCache getBeanCache(Class<?> beanType) {
return beanCache(beanType);
}
/**
* Return the cache for associated many properties of a bean type.
*/
ServerCache getCollectionIdsCache(Class<?> beanType, String propertyName);
ServerCache collectionIdsCache(Class<?> beanType, String propertyName);
@Deprecated
default ServerCache getCollectionIdsCache(Class<?> beanType, String propertyName) {
return collectionIdsCache(beanType, propertyName);
}
/**
* Return the cache for query results of a particular type of bean.
*/
ServerCache getQueryCache(Class<?> beanType);
ServerCache queryCache(Class<?> beanType);
@Deprecated
default ServerCache getQueryCache(Class<?> beanType) {
return queryCache(beanType);
}
/**
* This clears both the bean and query cache for a given type.
@@ -18,7 +18,6 @@ public class ServerCacheOptions {
* Construct with no set options.
*/
public ServerCacheOptions() {
}
/**
@@ -73,7 +72,6 @@ public class ServerCacheOptions {
* Return a copy of this object.
*/
public ServerCacheOptions copy() {
ServerCacheOptions copy = new ServerCacheOptions();
copy.maxSize = maxSize;
copy.maxIdleSecs = maxIdleSecs;
@@ -8,7 +8,15 @@ public interface ServerCacheRegion {
/**
* Return the region name.
*/
String getName();
String name();
/**
* Deprecated migrate to name().
*/
@Deprecated
default String getName() {
return name();
}
/**
* Return true if the cache region is enabled.
@@ -63,7 +63,7 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
*/
AbstractBeanCollection(BeanCollectionLoader loader, EntityBean ownerBean, String propertyName) {
this.loader = loader;
this.ebeanServerName = loader.getName();
this.ebeanServerName = loader.name();
this.ownerBean = ownerBean;
this.propertyName = propertyName;
this.readOnly = ownerBean != null && ownerBean._ebean_getIntercept().isReadOnly();
@@ -111,7 +111,7 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
public void setLoader(BeanCollectionLoader loader) {
this.registeredWithLoadContext = true;
this.loader = loader;
this.ebeanServerName = loader.getName();
this.ebeanServerName = loader.name();
}
@Override
@@ -61,7 +61,7 @@ public class SimpleSequenceIdGenerator implements PlatformIdGenerator {
PreparedStatement pstmt = null;
ResultSet rset = null;
try {
c = useTxnConnection ? t.getConnection() : dataSource.getConnection();
c = useTxnConnection ? t.connection() : dataSource.getConnection();
pstmt = c.prepareStatement(sql);
rset = pstmt.executeQuery();
if (rset.next()) {
@@ -1,5 +1,6 @@
package io.ebean.event;
import io.ebean.Database;
import io.ebean.EbeanServer;
import io.ebean.Transaction;
@@ -9,18 +10,62 @@ import io.ebean.Transaction;
public interface BeanDeleteIdRequest {
/**
* Return the server processing the request.
* Deprecated migrate to database().
*/
@Deprecated
EbeanServer getEbeanServer();
/**
* Deprecated migrate to database().
*/
@Deprecated
default Database getDatabase() {
return getEbeanServer();
}
/**
* Return the DB processing the request.
*/
default Database database() {
return getEbeanServer();
}
/**
* Return the Transaction associated with this request.
*/
Transaction getTransaction();
Transaction transaction();
/**
* Deprecated migrate to transaction().
*/
@Deprecated
default Transaction getTransaction() {
return transaction();
}
/**
* Returns the bean type of the bean being deleted.
*/
Class<?> beanType();
/**
* Deprecated migrate to beanType().
*/
@Deprecated
default Class<?> getBeanType() {
return beanType();
}
/**
* Returns the Id value of the bean being deleted.
*/
Object getId();
Object id();
/**
* Deprecated migrate to id().
*/
@Deprecated
default Object getId() {
return id();
}
}
@@ -1,5 +1,6 @@
package io.ebean.event;
import io.ebean.Database;
import io.ebean.EbeanServer;
import io.ebean.Transaction;
import io.ebean.ValuePair;
@@ -17,20 +18,44 @@ import java.util.Set;
public interface BeanPersistRequest<T> {
/**
* Return the server processing the request.
* Return the DB processing the request.
*/
default Database database() {
return getEbeanServer();
}
/**
* Deprecated migrate to database().
*/
@Deprecated
EbeanServer getEbeanServer();
/**
* Return the Transaction associated with this request.
*/
Transaction getTransaction();
Transaction transaction();
/**
* Deprecated migrate to transaction().
*/
@Deprecated
default Transaction getTransaction() {
return transaction();
}
/**
* For an update or delete of a partially populated bean this is the set of
* loaded properties and otherwise returns null.
*/
Set<String> getLoadedProperties();
Set<String> loadedProperties();
/**
* Deprecated migrate to loadedProperties().
*/
@Deprecated
default Set<String> getLoadedProperties() {
return loadedProperties();
}
/**
* For an update this is the set of properties that where updated.
@@ -39,12 +64,28 @@ public interface BeanPersistRequest<T> {
* should be preferred if it satisfies the requirement.
* </p>
*/
Set<String> getUpdatedProperties();
Set<String> updatedProperties();
/**
* Deprecated migrate to updatedProperties().
*/
@Deprecated
default Set<String> getUpdatedProperties() {
return updatedProperties();
}
/**
* Flags set for dirty properties (used by ElasticSearch integration).
*/
boolean[] getDirtyProperties();
boolean[] dirtyProperties();
/**
* Deprecated migrate to updatedProperties().
*/
@Deprecated
default boolean[] getDirtyProperties() {
return dirtyProperties();
}
/**
* Return true for an update request if at least one of dirty properties is contained
@@ -66,11 +107,27 @@ public interface BeanPersistRequest<T> {
/**
* Returns the bean being inserted updated or deleted.
*/
T getBean();
T bean();
/**
* Deprecated migrate to bean().
*/
@Deprecated
default T getBean() {
return bean();
}
/**
* Returns a map of the properties that have changed and their new and old values.
*/
Map<String, ValuePair> getUpdatedValues();
Map<String, ValuePair> updatedValues();
/**
* Deprecated migrate to updatedValues().
*/
@Deprecated
default Map<String, ValuePair> getUpdatedValues() {
return updatedValues();
}
}
@@ -1,5 +1,6 @@
package io.ebean.event;
import io.ebean.Database;
import io.ebean.EbeanServer;
import io.ebean.Query;
import io.ebean.Transaction;
@@ -10,19 +11,43 @@ import io.ebean.Transaction;
public interface BeanQueryRequest<T> {
/**
* Return the server processing the request.
* Return the DB processing the request.
*/
default Database database() {
return getEbeanServer();
}
/**
* Deprecated migrate to database().
*/
@Deprecated
EbeanServer getEbeanServer();
/**
* Return the Transaction associated with this request.
*/
Transaction getTransaction();
Transaction transaction();
/**
* Deprecated migrate to transaction().
*/
@Deprecated
default Transaction getTransaction() {
return transaction();
}
/**
* Returns the query.
*/
Query<T> getQuery();
Query<T> query();
/**
* Deprecated migrate to query().
*/
@Deprecated
default Query<T> getQuery() {
return query();
}
/**
* Return true if an Id IN expression should have the bind parameters padded.
@@ -8,7 +8,15 @@ public interface BulkTableEvent {
/**
* Return the name of the table that was involved.
*/
String getTableName();
String tableName();
/**
* Deprecated migrate to tableName().
*/
@Deprecated
default String getTableName() {
return tableName();
}
/**
* Return true if rows were inserted.
@@ -10,7 +10,15 @@ public interface QueryPlanMetric {
/**
* Return the underlying timed metric.
*/
TimedMetric getMetric();
TimedMetric metric();
/**
* Deprecated migrate to metric().
*/
@Deprecated
default TimedMetric getMetric() {
return metric();
}
/**
* Visit the underlying metric.
@@ -16,11 +16,27 @@ public interface BeanDocType<T> {
/**
* Return the doc store index type for this bean type.
*/
default String indexType() {
return getIndexType();
}
/**
* Deprecated migrate to indexType().
*/
@Deprecated
String getIndexType();
/**
* Return the doc store index name for this bean type.
*/
default String indexName() {
return getIndexName();
}
/**
* Deprecated migrate to indexName().
*/
@Deprecated
String getIndexName();
/**
@@ -32,12 +48,28 @@ public interface BeanDocType<T> {
/**
* Return the FetchPath for the embedded document.
*/
default FetchPath embedded(String path) {
return getEmbedded(path);
}
/**
* Deprecated migrate to embedded().
*/
@Deprecated
FetchPath getEmbedded(String path);
/**
* For embedded 'many' properties we need a FetchPath relative to the root which is used to
* build and replace the embedded list.
*/
default FetchPath embeddedManyRoot(String path) {
return getEmbeddedManyRoot(path);
}
/**
* Deprecated migrate to embeddedManyRoot().
*/
@Deprecated
FetchPath getEmbeddedManyRoot(String path);
/**
@@ -22,24 +22,56 @@ public interface BeanType<T> {
* Return the short name of the bean type.
*/
@Nonnull
String getName();
String name();
/**
* Deprecated migrate to name().
*/
@Deprecated
default String getName() {
return name();
}
/**
* Return the full name of the bean type.
*/
@Nonnull
String getFullName();
String fullName();
/**
* Deprecated migrate to fullName().
*/
@Deprecated
default String getFullName() {
return fullName();
}
/**
* Return the class type this BeanDescriptor describes.
*/
@Nonnull
Class<T> getBeanType();
Class<T> type();
/**
* Deprecated migrate to type().
*/
@Deprecated
default Class<T> getBeanType() {
return type();
}
/**
* Return the type bean for an OneToMany or ManyToOne or ManyToMany property.
*/
BeanType<?> getBeanTypeAtPath(String propertyName);
BeanType<?> beanTypeAtPath(String propertyName);
/**
* Deprecated migrate to beanTypeAtPath().
*/
@Deprecated
default BeanType<?> getBeanTypeAtPath(String propertyName) {
return beanTypeAtPath(propertyName);
}
/**
* Return all the properties for this bean type.
@@ -50,22 +82,54 @@ public interface BeanType<T> {
/**
* Return the Id property.
*/
Property getIdProperty();
Property idProperty();
/**
* Deprecated migrate to idProperty().
*/
@Deprecated
default Property getIdProperty() {
return idProperty();
}
/**
* Return the when modified property if there is one defined.
*/
Property getWhenModifiedProperty();
Property whenModifiedProperty();
/**
* Deprecated migrate to idProperty().
*/
@Deprecated
default Property getWhenModifiedProperty() {
return whenModifiedProperty();
}
/**
* Return the when created property if there is one defined.
*/
Property getWhenCreatedProperty();
Property whenCreatedProperty();
/**
* Deprecated migrate to idProperty().
*/
@Deprecated
default Property getWhenCreatedProperty() {
return whenCreatedProperty();
}
/**
* Return the Property to read values from a bean.
*/
Property getProperty(String propertyName);
Property property(String propertyName);
/**
* Deprecated migrate to property().
*/
@Deprecated
default Property getProperty(String propertyName) {
return property(propertyName);
}
/**
* Return the ExpressionPath for a given property path.
@@ -73,7 +137,15 @@ public interface BeanType<T> {
* This can return a property or nested property path.
* </p>
*/
ExpressionPath getExpressionPath(String path);
ExpressionPath expressionPath(String path);
/**
* Deprecated migrate to expressionPath().
*/
@Deprecated
default ExpressionPath getExpressionPath(String path) {
return expressionPath(path);
}
/**
* Return true if the property is a valid known property or path for the given bean type.
@@ -108,7 +180,15 @@ public interface BeanType<T> {
/**
* Return the base table this bean type maps to.
*/
String getBaseTable();
String baseTable();
/**
* Deprecated migrate to baseTable().
*/
@Deprecated
default String getBaseTable() {
return baseTable();
}
/**
* Create a new instance of the bean.
@@ -118,42 +198,99 @@ public interface BeanType<T> {
/**
* Return the bean id. This is the same as getBeanId() but without the generic type.
*/
Object beanId(Object bean);
Object id(Object bean);
/**
* Return the id value for the given bean.
* Deprecated migrate to id()
*/
@Deprecated
default Object beanId(Object bean) {
return id(bean);
}
/**
* Deprecated migrate to id()
*/
@Deprecated
Object getBeanId(T bean);
/**
* Set the id value to the bean.
*/
void setBeanId(T bean, Object idValue);
void setId(T bean, Object idValue);
/**
* Deprecated migrate to setId()
*/
@Deprecated
default void setBeanId(T bean, Object idValue) {
setId(bean, idValue);
}
/**
* Return the bean persist controller.
*/
BeanPersistController getPersistController();
BeanPersistController persistController();
/**
* Deprecated migrate to persistController()
*/
@Deprecated
default BeanPersistController getPersistController() {
return persistController();
}
/**
* Return the bean persist listener.
*/
BeanPersistListener getPersistListener();
BeanPersistListener persistListener();
/**
* Deprecated migrate to persistListener()
*/
@Deprecated
default BeanPersistListener getPersistListener() {
return persistListener();
}
/**
* Return the beanFinder. Usually null unless overriding the finder.
*/
BeanFindController getFindController();
BeanFindController findController();
/**
* Deprecated migrate to findController()
*/
@Deprecated
default BeanFindController getFindController() {
return findController();
}
/**
* Return the BeanQueryAdapter or null if none is defined.
*/
BeanQueryAdapter getQueryAdapter();
BeanQueryAdapter queryAdapter();
/**
* Deprecated migrate to queryAdapter()
*/
@Deprecated
default BeanQueryAdapter getQueryAdapter() {
return queryAdapter();
}
/**
* Return the identity generation type.
*/
IdType getIdType();
IdType idType();
/**
* Deprecated migrate to idType()
*/
@Deprecated
default IdType getIdType() {
return idType();
}
/**
* Return true if this bean type has doc store backing.
@@ -167,12 +304,28 @@ public interface BeanType<T> {
* for the document store.
* </p>
*/
DocMapping getDocMapping();
DocMapping docMapping();
/**
* Deprecated migrate to docMapping()
*/
@Deprecated
default DocMapping getDocMapping() {
return docMapping();
}
/**
* Return the doc store queueId for this bean type.
*/
String getDocStoreQueueId();
String docStoreQueueId();
/**
* Deprecated migrate to docStoreQueueId()
*/
@Deprecated
default String getDocStoreQueueId() {
return docStoreQueueId();
}
/**
* Return the doc store support for this bean type.\
@@ -203,12 +356,28 @@ public interface BeanType<T> {
/**
* Returns all direct children of this beantype
*/
List<BeanType<?>> getInheritanceChildren();
List<BeanType<?>> inheritanceChildren();
/**
* Returns the parent in inheritance hiearchy
* Deprecated migrate to inheritanceChildren()
*/
BeanType<?> getInheritanceParent();
@Deprecated
default List<BeanType<?>> getInheritanceChildren() {
return inheritanceChildren();
}
/**
* Returns the parent in inheritance hierarchy
*/
BeanType<?> inheritanceParent();
/**
* Deprecated migrate to inheritanceParent()
*/
@Deprecated
default BeanType<?> getInheritanceParent() {
return inheritanceParent();
}
/**
* Visit all children recursively
@@ -218,7 +387,15 @@ public interface BeanType<T> {
/**
* Return the discriminator column.
*/
String getDiscColumn();
String discColumn();
/**
* Deprecated migrate to discColumn()
*/
@Deprecated
default String getDiscColumn() {
return discColumn();
}
/**
* Create a bean given the discriminator value.
@@ -37,7 +37,15 @@ public interface ExpressionPath {
/**
* Return the default StringParser for the scalar property.
*/
StringParser getStringParser();
StringParser stringParser();
/**
* Deprecated migrate to stringParser().
*/
@Deprecated
default StringParser getStringParser() {
return stringParser();
}
/**
* For DateTime capable scalar types convert the long systemTimeMillis into
@@ -54,7 +62,15 @@ public interface ExpressionPath {
/**
* Return the underlying JDBC type or 0 if this is not a scalar type.
*/
int getJdbcType();
int jdbcType();
/**
* Deprecated migrate to jdbcType().
*/
@Deprecated
default int getJdbcType() {
return jdbcType();
}
/**
* Return true if this is an ManyToOne or OneToOne associated bean property.
@@ -67,20 +83,52 @@ public interface ExpressionPath {
* Typically used to produce id = ? expression strings.
* </p>
*/
String getAssocIdExpression(String propName, String bindOperator);
String assocIdExpression(String propName, String bindOperator);
/**
* Deprecated migrate to assocIdExpression().
*/
@Deprecated
default String getAssocIdExpression(String propName, String bindOperator) {
return assocIdExpression(propName, bindOperator);
}
/**
* Return the Id values for the given bean value.
*/
Object[] getAssocIdValues(EntityBean bean);
Object[] assocIdValues(EntityBean bean);
/**
* Deprecated migrate to assocIdValues().
*/
@Deprecated
default Object[] getAssocIdValues(EntityBean bean) {
return assocIdValues(bean);
}
/**
* Return the underlying bean property.
*/
Property getProperty();
Property property();
/**
* Deprecated migrate to property().
*/
@Deprecated
default Property getProperty() {
return property();
}
/**
* The ElPrefix plus name.
*/
String getElName();
String elName();
/**
* Deprecated migrate to elName().
*/
@Deprecated
default String getElName() {
return elName();
}
}
@@ -11,18 +11,42 @@ public interface Property {
* Return the name of the property.
*/
@Nonnull
String getName();
String name();
/**
* Deprecated migrate to name().
*/
@Deprecated
default String getName() {
return name();
}
/**
* Return the type of the property.
*/
@Nonnull
Class<?> getPropertyType();
Class<?> type();
/**
* Deprecated migrate to type().
*/
@Deprecated
default Class<?> getPropertyType() {
return type();
}
/**
* Return the value of the property on the given bean.
*/
Object getVal(Object bean);
Object value(Object bean);
/**
* Deprecated migrate to value().
*/
@Deprecated
default Object getVal(Object bean) {
return value(bean);
}
/**
* Return true if this is a OneToMany or ManyToMany property.
@@ -16,32 +16,80 @@ public interface SpiServer extends Database {
/**
* Return the DatabaseConfig.
*/
DatabaseConfig getServerConfig();
DatabaseConfig config();
/**
* Migrate to config().
*/
@Deprecated
default DatabaseConfig getServerConfig() {
return config();
}
/**
* Return the DatabasePlatform for this database.
*/
DatabasePlatform getDatabasePlatform();
DatabasePlatform databasePlatform();
/**
* Migrate to config().
*/
@Deprecated
default DatabasePlatform getDatabasePlatform() {
return databasePlatform();
}
/**
* Return all the bean types registered on this server instance.
*/
List<? extends BeanType<?>> getBeanTypes();
List<? extends BeanType<?>> beanTypes();
/**
* Migrate to beanTypes().
*/
@Deprecated
default List<? extends BeanType<?>> getBeanTypes() {
return beanTypes();
}
/**
* Return the bean type for a given entity bean class.
*/
<T> BeanType<T> getBeanType(Class<T> beanClass);
<T> BeanType<T> beanType(Class<T> beanClass);
/**
* Migrate to beanType().
*/
@Deprecated
default <T> BeanType<T> getBeanType(Class<T> beanClass) {
return beanType(beanClass);
}
/**
* Return the bean types mapped to the given base table.
*/
List<? extends BeanType<?>> getBeanTypes(String baseTableName);
List<? extends BeanType<?>> beanTypes(String baseTableName);
/**
* Migrate to beanTypes().
*/
@Deprecated
default List<? extends BeanType<?>> getBeanTypes(String baseTableName) {
return beanTypes(baseTableName);
}
/**
* Return the bean type for a given doc store queueId.
*/
BeanType<?> getBeanTypeForQueueId(String queueId);
BeanType<?> beanTypeForQueueId(String queueId);
/**
* Migrate to beanTypes().
*/
@Deprecated
default BeanType<?> getBeanTypeForQueueId(String queueId) {
return beanTypeForQueueId(queueId);
}
/**
* Return a BeanLoader.
@@ -1,6 +1,6 @@
package io.ebean.config.dbplatform;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.sql.Types;
import java.time.LocalDate;
+7 -7
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.11.2</version>
<version>12.11.4</version>
</parent>
<!-- <parent>-->
<!-- <groupId>org.avaje</groupId>-->
@@ -14,7 +14,7 @@
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>ebean-parent-12.11.2</tag>
<tag>ebean-parent-12.11.4</tag>
</scm>
<name>ebean autotune</name>
@@ -26,7 +26,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
<scope>provided</scope>
</dependency>
@@ -46,9 +46,9 @@
</dependency>
<dependency>
<groupId>org.avaje.composite</groupId>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.1</version>
<version>1.0</version>
<scope>test</scope>
</dependency>
@@ -59,12 +59,12 @@
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.19</version>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<tiles>
<!-- other tiles ... -->
<tile>io.ebean.tile:enhancement:12.6.0</tile>
<tile>io.ebean.tile:enhancement:12.11.3</tile>
</tiles>
</configuration>
</plugin>
+85
View File
@@ -0,0 +1,85 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.11.4-SNAPSHOT</version>
</parent>
<!-- <parent>-->
<!-- <groupId>org.avaje</groupId>-->
<!-- <artifactId>java8-oss</artifactId>-->
<!-- <version>2.2</version>-->
<!-- </parent>-->
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>ebean-parent-12.8.0</tag>
</scm>
<name>ebean autotune</name>
<description>ebean automatic query tuning module</description>
<artifactId>ebean-autotune</artifactId>
<dependencies>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.11.4-SNAPSHOT</version>
<scope>provided</scope>
</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>io.ebean</groupId>
<artifactId>ebean-datasource</artifactId>
<version>${ebean-datasource.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<tiles>
<!-- other tiles ... -->
<tile>io.ebean.tile:enhancement:12.11.3</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>
@@ -59,7 +59,7 @@ public class DefaultAutoTuneService implements AutoTuneService {
this.tuningFile = config.getQueryTuningFile();
this.profilingFile = config.getProfilingFile();
this.profilingUpdateFrequency = config.getProfilingUpdateFrequency();
this.serverName = server.getName();
this.serverName = server.name();
this.profileManager = new ProfileManager(config, server);
this.queryTuner = new BaseQueryTuner(config, server, profileManager);
this.skipGarbageCollectionOnShutdown = config.isSkipGarbageCollectionOnShutdown();
@@ -77,7 +77,7 @@ public class DefaultAutoTuneService implements AutoTuneService {
loadTuningFile();
if (isRuntimeTuningUpdates()) {
// periodically gather and update query tuning
server.getBackgroundExecutor().scheduleWithFixedDelay(new ProfilingUpdate(), profilingUpdateFrequency, profilingUpdateFrequency, TimeUnit.SECONDS);
server.backgroundExecutor().scheduleWithFixedDelay(new ProfilingUpdate(), profilingUpdateFrequency, profilingUpdateFrequency, TimeUnit.SECONDS);
}
}
}
@@ -111,7 +111,7 @@ public class ProfileManager implements ProfilingListener {
public AutoTuneCollection profilingCollection(boolean reset) {
AutoTuneCollection req = new AutoTuneCollection();
for (ProfileOrigin origin : profileMap.values()) {
BeanDescriptor<?> desc = server.getBeanDescriptorById(origin.getOrigin().getBeanType());
BeanDescriptor<?> desc = server.descriptorById(origin.getOrigin().getBeanType());
if (desc != null) {
origin.profilingCollection(desc, req, reset);
}
@@ -43,14 +43,14 @@ public class ProfileOriginNodeUsage {
try {
BeanDescriptor<?> desc = rootDesc;
if (path != null) {
ElPropertyValue elGetValue = rootDesc.getElGetValue(path);
ElPropertyValue elGetValue = rootDesc.elGetValue(path);
if (elGetValue == null) {
logger.warn("AutoTune: Can't find join for path[" + path + "] for " + rootDesc.getName());
logger.warn("AutoTune: Can't find join for path[" + path + "] for " + rootDesc.name());
return;
} else {
BeanProperty beanProperty = elGetValue.getBeanProperty();
BeanProperty beanProperty = elGetValue.beanProperty();
if (beanProperty instanceof BeanPropertyAssoc<?>) {
desc = ((BeanPropertyAssoc<?>) beanProperty).getTargetDescriptor();
desc = ((BeanPropertyAssoc<?>) beanProperty).targetDescriptor();
}
}
}
@@ -61,7 +61,7 @@ public class ProfileOriginNodeUsage {
for (String propName : aggregateUsed) {
BeanProperty beanProp = desc.findPropertyFromPath(propName);
if (beanProp == null) {
logger.warn("AutoTune: Can't find property[" + propName + "] for " + desc.getName());
logger.warn("AutoTune: Can't find property[" + propName + "] for " + desc.name());
} else {
if (beanProp.isId()) {
@@ -76,24 +76,24 @@ public class ProfileOriginNodeUsage {
// (which is the default for Lob's so typical).
} else {
addedToPath = true;
pathProps.addToPath(path, beanProp.getName());
pathProps.addToPath(path, beanProp.name());
}
}
}
}
if ((modified || addVersionProperty) && desc != null) {
BeanProperty versionProp = desc.getVersionProperty();
BeanProperty versionProp = desc.versionProperty();
if (versionProp != null) {
addedToPath = true;
pathProps.addToPath(path, versionProp.getName());
pathProps.addToPath(path, versionProp.name());
}
}
if (toOneIdProperty != null && !addedToPath) {
// add ToOne property to parent path
ElPropertyValue assocOne = rootDesc.getElGetValue(path);
pathProps.addToPath(SplitName.parent(path), assocOne.getName());
ElPropertyValue assocOne = rootDesc.elGetValue(path);
pathProps.addToPath(SplitName.parent(path), assocOne.name());
}
} finally {
lock.unlock();
@@ -1,7 +1,7 @@
package io.ebeaninternal.server.autotune.service;
import io.ebeaninternal.server.autotune.model.Autotune;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.InputStream;
@@ -5,7 +5,7 @@ import io.ebean.bean.ObjectGraphNode;
import io.ebean.bean.ObjectGraphOrigin;
import io.ebeaninternal.server.deploy.BeanDescriptor;
import io.ebeaninternal.server.querydefn.OrmQueryDetail;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.tests.autofetch.BaseTestCase;
import org.tests.model.basic.Order;
@@ -11,6 +11,6 @@ public class BaseTestCase {
}
protected <T> BeanDescriptor<T> getBeanDescriptor(Class<T> cls) {
return spiEbeanServer().getBeanDescriptor(cls);
return spiEbeanServer().descriptor(cls);
}
}
+15 -15
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.11.2</version>
<version>12.11.4</version>
</parent>
<name>ebean bom</name>
@@ -71,88 +71,88 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-xml</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-autotune</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>kotlin-querybean-generator</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgis</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-redis</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
</dependency>
</dependencies>
+162
View File
@@ -0,0 +1,162 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.11.4-SNAPSHOT</version>
</parent>
<name>ebean bom</name>
<description>ebean bill of materials pom</description>
<artifactId>ebean-bom</artifactId>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<!-- dependencies external to this ebean.git build -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-runner</artifactId>
<version>${ebean-ddl-runner.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration-auto</artifactId>
<version>${ebean-migration-auto.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration</artifactId>
<version>${ebean-migration.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource-api</artifactId>
<version>${ebean-datasource.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource</artifactId>
<version>${ebean-datasource.version}</version>
</dependency>
<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>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test-docker</artifactId>
<version>${ebean-test-docker.version}</version>
</dependency>
<!-- modules -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean</artifactId>
<version>12.11.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.11.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.11.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>12.11.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.11.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>12.11.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-xml</artifactId>
<version>12.11.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-autotune</artifactId>
<version>12.11.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>12.11.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>12.11.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>kotlin-querybean-generator</artifactId>
<version>12.11.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.11.4-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgis</artifactId>
<version>12.11.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-redis</artifactId>
<version>12.11.4-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
+2 -2
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.11.2</version>
<version>12.11.4</version>
</parent>
<artifactId>ebean-core-type</artifactId>
@@ -16,7 +16,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
</dependency>
<dependency>
+31
View File
@@ -0,0 +1,31 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.11.4-SNAPSHOT</version>
</parent>
<artifactId>ebean-core-type</artifactId>
<name>ebean core type</name>
<description>ebean scalar types api</description>
<dependencies>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.11.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
</dependencies>
</project>
+7 -136
View File
@@ -3,7 +3,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.11.2</version>
<version>12.11.4</version>
</parent>
<artifactId>ebean-core</artifactId>
@@ -15,23 +15,9 @@
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>ebean-parent-12.11.2</tag>
<tag>ebean-parent-12.11.4</tag>
</scm>
<profiles>
<profile>
<id>db2</id>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.ibm.db2/jcc -->
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>jcc</artifactId>
<version>11.5.5.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencies>
<dependency>
@@ -52,45 +38,22 @@
<version>1.1</version>
</dependency>
<!-- keep testing in core using ebean-ddl-generator & ebean-migration -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration</artifactId>
<version>12.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.11.0</version>
<scope>test</scope>
</dependency>
<!-- test scope for supporting ebean-ddl-generator -->
<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>12.11.2</version>
<version>12.11.4</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>12.11.2</version>
<version>12.11.4</version>
</dependency>
<dependency>
@@ -186,107 +149,15 @@
<scope>test</scope>
</dependency>
<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</groupId>
<artifactId>ebean-test-docker</artifactId>
<version>4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<scope>test</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.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>mod-uuid</artifactId>
<version>1.1</version>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
+246
View File
@@ -0,0 +1,246 @@
<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.11.4-SNAPSHOT</version>
</parent>
<artifactId>ebean-core</artifactId>
<packaging>jar</packaging>
<name>ebean core</name>
<description>ebean core module</description>
<url>https://ebean.io/</url>
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>ebean-parent-12.8.0</tag>
</scm>
<dependencies>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-runner</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>classpath-scanner</artifactId>
<version>6.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration-auto</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.11.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>12.11.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>12.11.4-SNAPSHOT</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>
<!-- 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>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>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.0.0</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.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
<!-- Provided scope for Postgres JSON/JSONB support -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.20</version>
<optional>true</optional>
</dependency>
<!-- Test scope -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource</artifactId>
<version>${ebean-datasource.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.ebean</groupId>
<artifactId>ebean-maven-plugin</artifactId>
<version>${ebean-maven-plugin.version}</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>
@@ -11,15 +11,15 @@ import java.util.List;
*/
public interface LoadBeanBuffer {
int getBatchSize();
int batchSize();
List<EntityBeanIntercept> getBatch();
List<EntityBeanIntercept> batch();
BeanDescriptor<?> getBeanDescriptor();
BeanDescriptor<?> descriptor();
PersistenceContext getPersistenceContext();
PersistenceContext persistenceContext();
String getFullPath();
String fullPath();
void configureQuery(SpiQuery<?> query, String lazyLoadProperty);
@@ -1,7 +1,8 @@
package io.ebeaninternal.api;
import io.ebean.bean.EntityBean;
import io.ebean.CacheMode;
import io.ebean.bean.EntityBeanIntercept;
import io.ebeaninternal.api.SpiQuery.Mode;
import io.ebeaninternal.server.core.OrmQueryRequest;
import io.ebeaninternal.server.deploy.BeanDescriptor;
@@ -19,77 +20,54 @@ public final class LoadBeanRequest extends LoadRequest {
private final LoadBeanBuffer loadBuffer;
private final String lazyLoadProperty;
private final boolean loadCache;
private boolean loadedFromCache;
private final boolean alreadyLoaded;
/**
* Construct for lazy load request.
*/
public LoadBeanRequest(LoadBeanBuffer LoadBuffer, EntityBeanIntercept ebi, boolean loadCache) {
this(LoadBuffer, null, true, ebi.getLazyLoadProperty(), loadCache);
this.loadedFromCache = ebi.isLoadedFromCache();
public LoadBeanRequest(LoadBeanBuffer loadBuffer, EntityBeanIntercept ebi, boolean loadCache) {
this(loadBuffer, null, true, ebi.getLazyLoadProperty(), ebi.isLoaded(), loadCache || ebi.isLoadedFromCache());
}
/**
* Construct for secondary query.
*/
public LoadBeanRequest(LoadBeanBuffer LoadBuffer, OrmQueryRequest<?> parentRequest) {
this(LoadBuffer, parentRequest, false, null, false);
public LoadBeanRequest(LoadBeanBuffer loadBuffer, OrmQueryRequest<?> parentRequest) {
this(loadBuffer, parentRequest, false, null, false, false);
}
private LoadBeanRequest(LoadBeanBuffer loadBuffer, OrmQueryRequest<?> parentRequest, boolean lazy,
String lazyLoadProperty, boolean loadCache) {
String lazyLoadProperty, boolean alreadyLoaded, boolean loadCache) {
super(parentRequest, lazy);
this.loadBuffer = loadBuffer;
this.batch = loadBuffer.getBatch();
this.batch = loadBuffer.batch();
this.lazyLoadProperty = lazyLoadProperty;
this.alreadyLoaded = alreadyLoaded;
this.loadCache = loadCache;
}
@Override
public Class<?> getBeanType() {
return loadBuffer.getBeanDescriptor().getBeanType();
public Class<?> beanType() {
return loadBuffer.descriptor().type();
}
/**
* Return true if the beans invoking lazy loading were previously loaded from cache.
*/
public boolean isLoadedFromCache() {
return loadedFromCache;
}
private boolean isLoadCache() {
return loadCache;
}
public String getDescription() {
return "path:" + loadBuffer.getFullPath() + " batch:" + batch.size();
public String description() {
return loadBuffer.fullPath();
}
/**
* Return the batch of beans to actually load.
*/
public List<EntityBeanIntercept> getBatch() {
public List<EntityBeanIntercept> batch() {
return batch;
}
/**
* Return the load context.
*/
private LoadBeanBuffer getLoadContext() {
return loadBuffer;
}
public int getBatchSize() {
return getLoadContext().getBatchSize();
}
/**
* Return the list of Id values for the beans in the lazy load buffer.
*/
public List<Object> getIdList() {
List<Object> idList = new ArrayList<>();
BeanDescriptor<?> desc = loadBuffer.getBeanDescriptor();
BeanDescriptor<?> desc = loadBuffer.descriptor();
for (EntityBeanIntercept ebi : batch) {
idList.add(desc.getId(ebi.getOwner()));
}
@@ -100,16 +78,21 @@ public final class LoadBeanRequest extends LoadRequest {
* Configure the query for lazy loading execution.
*/
public void configureQuery(SpiQuery<?> query, List<Object> idList) {
query.setMode(SpiQuery.Mode.LAZYLOAD_BEAN);
query.setPersistenceContext(loadBuffer.getPersistenceContext());
String mode = isLazy() ? "+lazy" : "+query";
query.setLoadDescription(mode, getDescription());
if (isLazy()) {
// cascade the batch size (if set) for further lazy loading
query.setLazyLoadBatchSize(getBatchSize());
query.setMode(Mode.LAZYLOAD_BEAN);
query.setPersistenceContext(loadBuffer.persistenceContext());
query.setLoadDescription(lazy ? "+lazy" : "+query", description());
if (lazy) {
query.setLazyLoadBatchSize(loadBuffer.batchSize());
if (alreadyLoaded) {
query.setBeanCacheMode(CacheMode.OFF);
}
} else {
query.setBeanCacheMode(CacheMode.OFF);
}
loadBuffer.configureQuery(query, lazyLoadProperty);
if (loadCache) {
query.setBeanCacheMode(CacheMode.PUT);
}
if (idList.size() == 1) {
query.where().idEq(idList.get(0));
} else {
@@ -122,13 +105,12 @@ public final class LoadBeanRequest extends LoadRequest {
*/
public void postLoad(List<?> list) {
Set<Object> loadedIds = new HashSet<>();
BeanDescriptor<?> desc = loadBuffer.getBeanDescriptor();
BeanDescriptor<?> desc = loadBuffer.descriptor();
// collect Ids and maybe load bean cache
for (Object bean : list) {
EntityBean loadedBean = (EntityBean) bean;
loadedIds.add(desc.getId(loadedBean));
loadedIds.add(desc.id(bean));
}
if (isLoadCache()) {
if (loadCache) {
desc.cacheBeanPutAll(list);
}
if (lazyLoadProperty != null) {
@@ -1,5 +1,6 @@
package io.ebeaninternal.api;
import io.ebean.CacheMode;
import io.ebean.bean.BeanCollection;
import io.ebean.bean.EntityBean;
import io.ebeaninternal.server.core.BindPadding;
@@ -47,96 +48,58 @@ public final class LoadManyRequest extends LoadRequest {
}
@Override
public Class<?> getBeanType() {
return loadContext.getBeanDescriptor().getBeanType();
public Class<?> beanType() {
return loadContext.getBeanDescriptor().type();
}
public String getDescription() {
return "path:" + loadContext.getFullPath() + " size:" + batch.size();
}
/**
* Return the batch of collections to actually load.
*/
public List<BeanCollection<?>> getBatch() {
return batch;
}
/**
* Return true if lazy loading should only load the id values.
* <p>
* This for use when lazy loading is invoked on methods such as clear() and removeAll() where it
* generally makes sense to only fetch the Id values as the other property information is not
* used.
*/
private boolean isOnlyIds() {
return onlyIds;
}
/**
* Return true if we should load the Collection ids into the cache.
*/
private boolean isLoadCache() {
return loadCache;
}
/**
* Return the batch size used for this load context.
*/
public int getBatchSize() {
return loadContext.getBatchSize();
public String description() {
return loadContext.getFullPath();
}
private List<Object> parentIdList(SpiEbeanServer server) {
List<Object> idList = new ArrayList<>();
BeanPropertyAssocMany<?> many = getMany();
BeanPropertyAssocMany<?> many = many();
for (BeanCollection<?> bc : batch) {
idList.add(many.getParentId(bc.getOwnerBean()));
idList.add(many.parentId(bc.getOwnerBean()));
bc.setLoader(server); // don't use the load buffer again
}
if (many.getTargetDescriptor().isPadInExpression()) {
if (many.targetDescriptor().isPadInExpression()) {
BindPadding.padIds(idList);
}
return idList;
}
private BeanPropertyAssocMany<?> getMany() {
private BeanPropertyAssocMany<?> many() {
return loadContext.getBeanProperty();
}
public SpiQuery<?> createQuery(SpiEbeanServer server) {
BeanPropertyAssocMany<?> many = getMany();
BeanPropertyAssocMany<?> many = many();
SpiQuery<?> query = many.newQuery(server);
String orderBy = many.getLazyFetchOrderBy();
String orderBy = many.lazyFetchOrderBy();
if (orderBy != null) {
query.order(orderBy);
}
String extraWhere = many.getExtraWhere();
String extraWhere = many.extraWhere();
if (extraWhere != null) {
// replace special ${ta} placeholder with the base table alias
// which is always t0 and add the extra where clause
query.where().raw(extraWhere.replace("${ta}", "t0").replace("${mta}", "int_"));
}
query.setLazyLoadForParents(many);
many.addWhereParentIdIn(query, parentIdList(server), loadContext.isUseDocStore());
query.setPersistenceContext(loadContext.getPersistenceContext());
String mode = isLazy() ? "+lazy" : "+query";
query.setLoadDescription(mode, getDescription());
if (isLazy()) {
// cascade the batch size (if set) for further lazy loading
query.setLazyLoadBatchSize(getBatchSize());
query.setLoadDescription(lazy ? "+lazy" : "+query", description());
if (lazy) {
query.setLazyLoadBatchSize(loadContext.getBatchSize());
} else {
query.setBeanCacheMode(CacheMode.OFF);
}
// potentially changes the joins and selected properties
// potentially changes the joins, selected properties, cache mode
loadContext.configureQuery(query);
if (isOnlyIds()) {
// override to just select the Id values
query.select(many.getTargetIdProperty());
if (onlyIds) {
// lazy loading invoked via clear() and removeAll()
query.select(many.targetIdProperty());
}
return query;
}
@@ -146,7 +109,7 @@ public final class LoadManyRequest extends LoadRequest {
*/
public void postLoad() {
BeanDescriptor<?> desc = loadContext.getBeanDescriptor();
BeanPropertyAssocMany<?> many = getMany();
BeanPropertyAssocMany<?> many = many();
// check for BeanCollection's that where never processed
// in the +query or +lazy load due to no rows (predicates)
for (BeanCollection<?> bc : batch) {
@@ -156,9 +119,8 @@ public final class LoadManyRequest extends LoadRequest {
Object parentId = desc.getId(ownerBean);
logger.debug("BeanCollection after lazy load was empty. type:" + ownerBean.getClass().getName() + " id:" + parentId + " owner:" + ownerBean);
}
} else if (isLoadCache() && many.isUseCache()) {
Object parentId = desc.getId(bc.getOwnerBean());
desc.cacheManyPropPut(many, bc, parentId);
} else if (loadCache && many.isUseCache()) {
desc.cacheManyPropPut(many, bc, desc.getId(bc.getOwnerBean()));
}
}
}
@@ -9,22 +9,19 @@ import io.ebeaninternal.server.core.OrmQueryRequest;
public abstract class LoadRequest {
protected final OrmQueryRequest<?> parentRequest;
protected final Transaction transaction;
protected final boolean lazy;
public LoadRequest(OrmQueryRequest<?> parentRequest, boolean lazy) {
LoadRequest(OrmQueryRequest<?> parentRequest, boolean lazy) {
this.parentRequest = parentRequest;
this.transaction = parentRequest == null ? null : parentRequest.getTransaction();
this.transaction = parentRequest == null ? null : parentRequest.transaction();
this.lazy = lazy;
}
/**
* Return the associated bean type for this load request.
*/
public abstract Class<?> getBeanType();
public abstract Class<?> beanType();
/**
* Return true if this is a lazy load and false if it is a secondary query.
@@ -39,7 +36,7 @@ public abstract class LoadRequest {
* Lazy loading queries run in their own transaction.
* </p>
*/
public Transaction getTransaction() {
public Transaction transaction() {
return transaction;
}
@@ -48,6 +45,6 @@ public abstract class LoadRequest {
* So one of - findIterate(), findEach(), findEachWhile() or findVisit().
*/
public boolean isParentFindIterate() {
return parentRequest != null && parentRequest.getQuery().getType() == SpiQuery.Type.ITERATE;
return parentRequest != null && parentRequest.query().getType() == SpiQuery.Type.ITERATE;
}
}
@@ -49,15 +49,15 @@ public final class ManyWhereJoins implements Serializable {
*/
public void add(ElPropertyDeploy elProp) {
String join = elProp.getElPrefix();
BeanProperty p = elProp.getBeanProperty();
String join = elProp.elPrefix();
BeanProperty p = elProp.beanProperty();
if (p instanceof BeanPropertyAssocMany<?>) {
join = addManyToJoin(join, p.getName());
join = addManyToJoin(join, p.name());
}
if (join != null) {
addJoin(join);
if (p != null) {
String secondaryTableJoinPrefix = p.getSecondaryTableJoinPrefix();
String secondaryTableJoinPrefix = p.secondaryTableJoinPrefix();
if (secondaryTableJoinPrefix != null) {
addJoin(join + "." + secondaryTableJoinPrefix);
}
@@ -8,6 +8,6 @@ public interface SpiBeanTypeManager {
/**
* Return the bean type for the given entity class.
*/
SpiBeanType getBeanType(Class<?> entityType);
SpiBeanType beanType(Class<?> entityType);
}
@@ -36,11 +36,6 @@ public interface SpiDtoQuery<T> extends DtoQuery<T>, SpiSqlBinding {
*/
boolean isRelaxedMode();
/**
* Return the label for the query.
*/
String getLabel();
/**
* Return the label with fallback to profile location label.
*/
@@ -8,6 +8,7 @@ import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.event.readaudit.ReadAuditLogger;
import io.ebean.event.readaudit.ReadAuditPrepare;
import io.ebean.meta.MetricVisitor;
import io.ebean.plugin.SpiServer;
import io.ebeaninternal.api.SpiQuery.Type;
import io.ebeaninternal.server.core.SpiResultSet;
import io.ebeaninternal.server.core.timezone.DataTimeZone;
@@ -23,7 +24,7 @@ import java.util.stream.Stream;
/**
* Service Provider extension to EbeanServer.
*/
public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollectionLoader {
public interface SpiEbeanServer extends SpiServer, ExtendedServer, EbeanServer, BeanCollectionLoader {
/**
* Return true if the L2 cache has been disabled.
@@ -50,16 +51,6 @@ public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollect
*/
Object currentTenantId();
/**
* Return the server configuration.
*/
DatabaseConfig getServerConfig();
/**
* Return the DatabasePlatform for this server.
*/
DatabasePlatform getDatabasePlatform();
/**
* Create an object to represent the current CallStack.
* <p>
@@ -72,7 +63,7 @@ public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollect
/**
* Return the PersistenceContextScope to use defined at query or server level.
*/
PersistenceContextScope getPersistenceContextScope(SpiQuery<?> query);
PersistenceContextScope persistenceContextScope(SpiQuery<?> query);
/**
* Clear the query execution statistics.
@@ -82,32 +73,32 @@ public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollect
/**
* Return the transaction manager.
*/
SpiTransactionManager getTransactionManager();
SpiTransactionManager transactionManager();
/**
* Return all the descriptors.
*/
List<BeanDescriptor<?>> getBeanDescriptors();
List<BeanDescriptor<?>> descriptors();
/**
* Return the BeanDescriptor for a given type of bean.
*/
<T> BeanDescriptor<T> getBeanDescriptor(Class<T> type);
<T> BeanDescriptor<T> descriptor(Class<T> type);
/**
* Return BeanDescriptor using it's unique id.
*/
BeanDescriptor<?> getBeanDescriptorById(String className);
BeanDescriptor<?> descriptorById(String className);
/**
* Return BeanDescriptor using it's unique doc store queueId.
*/
BeanDescriptor<?> getBeanDescriptorByQueueId(String queueId);
BeanDescriptor<?> descriptorByQueueId(String queueId);
/**
* Return BeanDescriptors mapped to this table.
*/
List<BeanDescriptor<?>> getBeanDescriptors(String tableName);
List<BeanDescriptor<?>> descriptors(String tableName);
/**
* Process committed changes from another framework.
@@ -179,7 +170,7 @@ public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollect
/**
* Return the default batch size for lazy loading.
*/
int getLazyLoadBatchSize();
int lazyLoadBatchSize();
/**
* Return true if the type is known as an Entity or Xml type or a List Set or
@@ -190,18 +181,18 @@ public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollect
/**
* Return the ReadAuditLogger to use for logging all read audit events.
*/
ReadAuditLogger getReadAuditLogger();
ReadAuditLogger readAuditLogger();
/**
* Return the ReadAuditPrepare used to populate the read audit events with
* user context information (user id, user ip address etc).
*/
ReadAuditPrepare getReadAuditPrepare();
ReadAuditPrepare readAuditPrepare();
/**
* Return the DataTimeZone to use when reading/writing timestamps via JDBC.
*/
DataTimeZone getDataTimeZone();
DataTimeZone dataTimeZone();
/**
* Check for slow query event.
@@ -44,8 +44,4 @@ public interface SpiExpressionList<T> extends ExpressionList<T>, SpiExpression {
// do nothing by default
}
/**
* Apply property prefix when filterMany expressions included in main query.
*/
void prefixProperty(String path);
}
@@ -318,8 +318,8 @@ public abstract class SpiTransactionProxy implements SpiTransaction {
}
@Override
public Connection getConnection() {
return transaction.getConnection();
public Connection connection() {
return transaction.connection();
}
@Override
@@ -39,7 +39,7 @@ public final class TransactionEventTable implements Serializable, BinaryWritable
}
public void add(TableIUD newTableIUD) {
TableIUD existingTableIUD = map.put(newTableIUD.getTableName(), newTableIUD);
TableIUD existingTableIUD = map.put(newTableIUD.tableName(), newTableIUD);
if (existingTableIUD != null) {
newTableIUD.add(existingTableIUD);
}
@@ -104,7 +104,7 @@ public final class TransactionEventTable implements Serializable, BinaryWritable
}
@Override
public String getTableName() {
public String tableName() {
return table;
}
@@ -63,7 +63,7 @@ public final class CacheChangeSet {
* Add an entry to clear a query cache.
*/
public void addInvalidate(BeanDescriptor<?> descriptor) {
touchedTables.add(descriptor.getBaseTable());
touchedTables.add(descriptor.baseTable());
}
/**
@@ -78,7 +78,7 @@ public final class CacheChangeSet {
*/
public void addClearQuery(BeanDescriptor<?> descriptor) {
queryCaches.add(descriptor);
touchedTables.add(descriptor.getBaseTable());
touchedTables.add(descriptor.baseTable());
}
/**
@@ -125,7 +125,7 @@ public final class CacheChangeSet {
entry.addId(id);
} else {
beanRemoveMap.put(desc, new CacheChangeBeanRemove(id, desc));
touchedTables.add(desc.getBaseTable());
touchedTables.add(desc.baseTable());
}
}
@@ -138,7 +138,7 @@ public final class CacheChangeSet {
entry.addIds(ids);
} else {
beanRemoveMap.put(desc, new CacheChangeBeanRemove(desc, ids));
touchedTables.add(desc.getBaseTable());
touchedTables.add(desc.baseTable());
}
}
@@ -146,7 +146,7 @@ public final class CacheChangeSet {
* Update a bean entry.
*/
public <T> void addBeanUpdate(BeanDescriptor<T> desc, String key, Map<String, Object> changes, boolean updateNaturalKey, long version) {
touchedTables.add(desc.getBaseTable());
touchedTables.add(desc.baseTable());
entries.add(new CacheChangeBeanUpdate(desc, key, changes, updateNaturalKey, version));
}
@@ -15,33 +15,33 @@ public final class CachedBeanDataFromBean {
EntityBeanIntercept ebi = bean._ebean_getIntercept();
Map<String, Object> data = new LinkedHashMap<>();
BeanProperty idProperty = desc.getIdProperty();
BeanProperty idProperty = desc.idProperty();
if (idProperty != null) {
int propertyIndex = idProperty.getPropertyIndex();
int propertyIndex = idProperty.propertyIndex();
if (ebi.isLoadedProperty(propertyIndex)) {
data.put(idProperty.getName(), idProperty.getCacheDataValue(bean));
data.put(idProperty.name(), idProperty.getCacheDataValue(bean));
}
}
// extract all the non-many properties
final boolean dirty = ebi.isDirty();
for (BeanProperty prop : desc.propertiesNonMany()) {
if (dirty && ebi.isDirtyProperty(prop.getPropertyIndex())) {
data.put(prop.getName(), prop.getCacheDataValueOrig(ebi));
} else if (ebi.isLoadedProperty(prop.getPropertyIndex())) {
data.put(prop.getName(), prop.getCacheDataValue(bean));
if (dirty && ebi.isDirtyProperty(prop.propertyIndex())) {
data.put(prop.name(), prop.getCacheDataValueOrig(ebi));
} else if (ebi.isLoadedProperty(prop.propertyIndex())) {
data.put(prop.name(), prop.getCacheDataValue(bean));
}
}
for (BeanPropertyAssocMany<?> prop : desc.propertiesMany()) {
if (prop.isElementCollection()) {
data.put(prop.getName(), prop.getCacheDataValue(bean));
data.put(prop.name(), prop.getCacheDataValue(bean));
}
}
long version = desc.getVersion(bean);
EntityBean sharableBean = createSharableBean(desc, bean, ebi);
return new CachedBeanData(sharableBean, desc.getDiscValue(), data, version);
return new CachedBeanData(sharableBean, desc.discValue(), data, version);
}
private static EntityBean createSharableBean(BeanDescriptor<?> desc, EntityBean bean, EntityBeanIntercept beanEbi) {
@@ -54,7 +54,7 @@ public final class CachedBeanDataFromBean {
// create a readOnly sharable instance by copying the data
EntityBean sharableBean = desc.createEntityBean();
BeanProperty idProp = desc.getIdProperty();
BeanProperty idProp = desc.idProperty();
if (idProp != null) {
Object v = idProp.getValue(bean);
idProp.setValue(sharableBean, v);
@@ -13,9 +13,9 @@ public final class CachedBeanDataToBean {
EntityBeanIntercept ebi = bean._ebean_getIntercept();
// any future lazy loading skips L2 bean cache
ebi.setLoadedFromCache(true);
BeanProperty idProperty = desc.getIdProperty();
if (desc.getInheritInfo() != null) {
desc = desc.getInheritInfo().readType(bean.getClass()).desc();
BeanProperty idProperty = desc.idProperty();
if (desc.inheritInfo() != null) {
desc = desc.inheritInfo().readType(bean.getClass()).desc();
}
if (idProperty != null) {
// load the id property
@@ -36,9 +36,9 @@ public final class CachedBeanDataToBean {
}
private static void loadProperty(EntityBean bean, CachedBeanData cacheBeanData, EntityBeanIntercept ebi, BeanProperty prop, PersistenceContext context) {
if (cacheBeanData.isLoaded(prop.getName())) {
if (!ebi.isLoadedProperty(prop.getPropertyIndex())) {
Object value = cacheBeanData.getData(prop.getName());
if (cacheBeanData.isLoaded(prop.name())) {
if (!ebi.isLoadedProperty(prop.propertyIndex())) {
Object value = cacheBeanData.getData(prop.name());
prop.setCacheDataValue(bean, value, context);
}
}
@@ -27,7 +27,7 @@ public final class DefaultCacheAdapter implements ServerCacheManager {
}
@Override
public boolean isLocalL2Caching() {
public boolean localL2Caching() {
return cacheManager.isLocalL2Caching();
}
@@ -37,37 +37,37 @@ public final class DefaultCacheAdapter implements ServerCacheManager {
}
@Override
public void setEnabledRegions(String regions) {
public void enabledRegions(String regions) {
cacheManager.setEnabledRegions(regions);
}
@Override
public ServerCacheRegion getRegion(String region) {
public ServerCacheRegion region(String region) {
return cacheManager.getRegion(region);
}
@Override
public void setAllRegionsEnabled(boolean enabled) {
public void allRegionsEnabled(boolean enabled) {
cacheManager.setAllRegionsEnabled(enabled);
}
@Override
public ServerCache getNaturalKeyCache(Class<?> beanType) {
public ServerCache naturalKeyCache(Class<?> beanType) {
return cacheManager.getNaturalKeyCache(beanType);
}
@Override
public ServerCache getBeanCache(Class<?> beanType) {
public ServerCache beanCache(Class<?> beanType) {
return cacheManager.getBeanCache(beanType);
}
@Override
public ServerCache getCollectionIdsCache(Class<?> beanType, String propertyName) {
public ServerCache collectionIdsCache(Class<?> beanType, String propertyName) {
return cacheManager.getCollectionIdsCache(beanType, propertyName);
}
@Override
public ServerCache getQueryCache(Class<?> beanType) {
public ServerCache queryCache(Class<?> beanType) {
return cacheManager.getQueryCache(beanType);
}
@@ -65,17 +65,17 @@ public final class DefaultServerCacheManager implements SpiCacheManager {
List<String> enabled = new ArrayList<>();
for (SpiCacheRegion region : regionMap.values()) {
if (enabledRegionNames.contains(region.getName())) {
enabled.add(region.getName());
if (enabledRegionNames.contains(region.name())) {
enabled.add(region.name());
if (!region.isEnabled()) {
region.setEnabled(true);
log.debug("Cache region[{}] enabled", region.getName());
log.debug("Cache region[{}] enabled", region.name());
}
} else {
disabled.add(region.getName());
disabled.add(region.name());
if (region.isEnabled()) {
region.setEnabled(false);
log.debug("Cache region[{}] disabled", region.getName());
log.debug("Cache region[{}] disabled", region.name());
}
}
}
@@ -46,7 +46,7 @@ public final class DefaultChangeLogListener implements ChangeLogListener, Plugin
@Override
public void configure(SpiServer server) {
jsonBuilder = new ChangeJsonBuilder();
Properties properties = server.getServerConfig().getProperties();
Properties properties = server.config().getProperties();
if (properties != null) {
String bufferSize = properties.getProperty("ebean.changeLog.bufferSize");
if (bufferSize != null) {
@@ -56,7 +56,7 @@ public class ClusterManager implements ServerLookup {
public void registerServer(EbeanServer server) {
lock.lock();
try {
serverMap.put(server.getName(), server);
serverMap.put(server.name(), server);
if (!started) {
startup();
}
@@ -121,7 +121,7 @@ public abstract class AbstractSqlQueryRequest implements CancelableQuery {
int firstRow = query.getFirstRow();
int maxRows = query.getMaxRows();
if (firstRow > 0 || maxRows > 0) {
return server.getDatabasePlatform().getBasicSqlLimiter().limit(sql, firstRow, maxRows);
return server.databasePlatform().getBasicSqlLimiter().limit(sql, firstRow, maxRows);
}
return sql;
}
@@ -14,21 +14,13 @@ public abstract class BeanRequest {
static final Logger log = LoggerFactory.getLogger(BeanRequest.class);
/**
* The server processing the request.
*/
protected final SpiEbeanServer ebeanServer;
/**
* The transaction this is part of.
*/
protected final SpiEbeanServer server;
protected SpiTransaction transaction;
protected boolean createdTransaction;
public BeanRequest(SpiEbeanServer ebeanServer, SpiTransaction t) {
this.ebeanServer = ebeanServer;
this.transaction = t;
public BeanRequest(SpiEbeanServer server, SpiTransaction transaction) {
this.server = server;
this.transaction = transaction;
}
/**
@@ -36,7 +28,6 @@ public abstract class BeanRequest {
* <p>
* A transaction may have been passed in or active in the thread local. If
* not then create one implicitly to handle the request.
* </p>
*
* @return True if a transaction was set (from current or created).
*/
@@ -44,10 +35,10 @@ public abstract class BeanRequest {
if (transaction != null) {
return false;
}
transaction = ebeanServer.currentServerTransaction();
transaction = server.currentServerTransaction();
if (transaction == null || !transaction.isActive()) {
// create an implicit transaction to execute this query
transaction = ebeanServer.beginServerTransaction();
transaction = server.beginServerTransaction();
createdTransaction = true;
}
return true;
@@ -58,7 +49,7 @@ public abstract class BeanRequest {
*/
public void commitTransIfRequired() {
if (createdTransaction) {
ebeanServer.commitTransaction();
server.commitTransaction();
}
}
@@ -68,7 +59,7 @@ public abstract class BeanRequest {
public void rollbackTransIfRequired() {
if (createdTransaction) {
try {
ebeanServer.endTransaction();
server.endTransaction();
} catch (Exception e) {
// Just log this and carry on. A previous exception has been
// thrown and if this rollback throws exception it likely means
@@ -83,7 +74,7 @@ public abstract class BeanRequest {
*/
public void clearTransIfRequired() {
if (createdTransaction) {
ebeanServer.clearServerTransaction();
server.clearServerTransaction();
}
}
@@ -92,45 +83,45 @@ public abstract class BeanRequest {
* BeanController and BeanFinder.
*/
public EbeanServer getEbeanServer() {
return ebeanServer;
return server;
}
public SpiEbeanServer getServer() {
return ebeanServer;
public SpiEbeanServer server() {
return server;
}
/**
* Return the Transaction associated with this request.
*/
public SpiTransaction getTransaction() {
public SpiTransaction transaction() {
return transaction;
}
/**
* Set the transaction to use for this request.
*/
public void setTransaction(SpiTransaction transaction) {
public void transaction(SpiTransaction transaction) {
this.transaction = transaction;
}
/**
* Return true if SQL should be logged for this transaction.
*/
public boolean isLogSql() {
public boolean logSql() {
return transaction.isLogSql();
}
/**
* Return true if SUMMARY information should be logged for this transaction.
*/
public boolean isLogSummary() {
public boolean logSummary() {
return transaction.isLogSummary();
}
/**
* Return the DataTimeZone to use.
*/
public DataTimeZone getDataTimeZone() {
return ebeanServer.getDataTimeZone();
public DataTimeZone dataTimeZone() {
return server.dataTimeZone();
}
}
@@ -26,7 +26,7 @@ final class DScriptRunner implements ScriptRunner {
DScriptRunner(SpiEbeanServer server) {
this.server = server;
this.platformName = this.server.getDatabasePlatform().getPlatform().base().name();
this.platformName = this.server.platform().base().name();
}
@Override
@@ -102,7 +102,7 @@ final class DScriptRunner implements ScriptRunner {
private Connection obtainConnection() {
try {
return server.getDataSource().getConnection();
return server.dataSource().getConnection();
} catch (SQLException e) {
throw new PersistenceException("Failed to obtain connection to run script", e);
}
@@ -35,19 +35,16 @@ final class DefaultBeanLoader {
DefaultBeanLoader(DefaultServer server) {
this.server = server;
this.onIterateUseExtraTxn = server.getDatabasePlatform().useExtraTransactionOnIterateSecondaryQueries();
this.onIterateUseExtraTxn = server.databasePlatform().useExtraTransactionOnIterateSecondaryQueries();
}
void loadMany(LoadManyRequest loadRequest) {
SpiQuery<?> query = loadRequest.createQuery(server);
executeQuery(loadRequest, query);
executeQuery(loadRequest, loadRequest.createQuery(server));
loadRequest.postLoad();
}
void loadMany(BeanCollection<?> bc, boolean onlyIds) {
EntityBean parentBean = bc.getOwnerBean();
String propertyName = bc.getPropertyName();
loadManyInternal(parentBean, propertyName, null, false, onlyIds);
loadManyInternal(bc.getOwnerBean(), bc.getPropertyName(), null, false, onlyIds);
}
void refreshMany(EntityBean parentBean, String propertyName) {
@@ -57,8 +54,8 @@ final class DefaultBeanLoader {
private void loadManyInternal(EntityBean parentBean, String propertyName, Transaction t, boolean refresh, boolean onlyIds) {
EntityBeanIntercept ebi = parentBean._ebean_getIntercept();
PersistenceContext pc = ebi.getPersistenceContext();
BeanDescriptor<?> parentDesc = server.getBeanDescriptor(parentBean.getClass());
BeanPropertyAssocMany<?> many = (BeanPropertyAssocMany<?>) parentDesc.getBeanProperty(propertyName);
BeanDescriptor<?> parentDesc = server.descriptor(parentBean.getClass());
BeanPropertyAssocMany<?> many = (BeanPropertyAssocMany<?>) parentDesc.beanProperty(propertyName);
BeanCollection<?> beanCollection = null;
ExpressionList<?> filterMany = null;
@@ -69,12 +66,10 @@ final class DefaultBeanLoader {
}
Object parentId = parentDesc.getId(parentBean);
if (pc == null) {
pc = new DefaultPersistenceContext();
parentDesc.contextPut(pc, parentId, parentBean);
}
boolean useManyIdCache = beanCollection != null && parentDesc.isManyPropCaching() && many.isUseCache();
if (useManyIdCache) {
Boolean readOnly = null;
@@ -86,8 +81,7 @@ final class DefaultBeanLoader {
}
}
SpiQuery<?> query = server.createQuery(parentDesc.getBeanType());
SpiQuery<?> query = server.createQuery(parentDesc.type());
if (refresh) {
// populate a new collection
BeanCollection<?> emptyCollection = many.createEmpty(parentBean);
@@ -97,23 +91,21 @@ final class DefaultBeanLoader {
query.setLoadDescription("+lazy", null);
}
query.select(parentDesc.getIdBinder().getIdProperty());
query.select(parentDesc.idBinder().getIdProperty());
if (onlyIds) {
query.fetch(many.getName(), many.getTargetIdProperty());
query.fetch(many.name(), many.targetIdProperty());
} else {
query.fetch(many.getName());
query.fetch(many.name());
}
if (filterMany != null) {
query.setFilterMany(many.getName(), filterMany);
query.setFilterMany(many.name(), filterMany);
}
query.where().idEq(parentId);
query.setUseCache(false);
query.setBeanCacheMode(CacheMode.OFF);
query.setMode(Mode.LAZYLOAD_MANY);
query.setLazyLoadManyPath(many.getName());
query.setLazyLoadManyPath(many.name());
query.setPersistenceContext(pc);
if (ebi.isReadOnly()) {
query.setReadOnly(true);
}
@@ -134,7 +126,7 @@ final class DefaultBeanLoader {
* Load a batch of beans for +query or +lazy loading.
*/
void loadBean(LoadBeanRequest loadRequest) {
List<EntityBeanIntercept> batch = loadRequest.getBatch();
List<EntityBeanIntercept> batch = loadRequest.batch();
if (batch.isEmpty()) {
throw new RuntimeException("Nothing in batch?");
}
@@ -145,12 +137,8 @@ final class DefaultBeanLoader {
return;
}
SpiQuery<?> query = server.createQuery(loadRequest.getBeanType());
SpiQuery<?> query = server.createQuery(loadRequest.beanType());
loadRequest.configureQuery(query, idList);
if (loadRequest.isLoadedFromCache()) {
query.setBeanCacheMode(CacheMode.PUT);
}
List<?> list = executeQuery(loadRequest, query);
loadRequest.postLoad(list);
}
@@ -168,7 +156,7 @@ final class DefaultBeanLoader {
extraTxn.end();
}
} else {
return server.findList(query, loadRequest.getTransaction());
return server.findList(query, loadRequest.transaction());
}
}
@@ -188,12 +176,11 @@ final class DefaultBeanLoader {
pc = null;
}
BeanDescriptor<?> desc = server.getBeanDescriptor(bean.getClass());
if (EntityType.EMBEDDED == desc.getEntityType()) {
BeanDescriptor<?> desc = server.descriptor(bean.getClass());
if (EntityType.EMBEDDED == desc.entityType()) {
// lazy loading on an embedded bean property
EntityBean embeddedOwner = (EntityBean) ebi.getEmbeddedOwner();
int ownerIndex = ebi.getEmbeddedOwnerIndex();
refreshBeanInternal(embeddedOwner, mode, ownerIndex);
refreshBeanInternal(embeddedOwner, mode, ebi.getEmbeddedOwnerIndex());
}
Object id = desc.getId(bean);
@@ -216,7 +203,7 @@ final class DefaultBeanLoader {
}
}
SpiQuery<?> query = server.createQuery(desc.getBeanType());
SpiQuery<?> query = server.createQuery(desc.type());
query.setLazyLoadProperty(ebi.getLazyLoadProperty());
if (draft) {
query.asDraft();
@@ -235,7 +222,7 @@ final class DefaultBeanLoader {
query.setId(id);
if (embeddedOwnerIndex > -1 || mode == Mode.REFRESH_BEAN) {
// make sure the query doesn't use the cache
query.setUseCache(false);
query.setBeanCacheMode(CacheMode.OFF);
}
if (ebi.isReadOnly()) {
query.setReadOnly(true);
@@ -249,8 +236,7 @@ final class DefaultBeanLoader {
Object dbBean = query.findOne();
if (dbBean == null) {
String msg = "Bean not found during lazy load or refresh." + " id[" + id + "] type[" + desc.getBeanType() + "]";
throw new EntityNotFoundException(msg);
throw new EntityNotFoundException("Bean not found during lazy load or refresh." + " id[" + id + "] type[" + desc.type() + "]");
}
desc.resetManyProperties(dbBean);
}
@@ -45,17 +45,17 @@ public final class DefaultBeanState implements BeanState {
}
@Override
public Set<String> getLoadedProps() {
public Set<String> loadedProps() {
return intercept.getLoadedPropertyNames();
}
@Override
public Set<String> getChangedProps() {
public Set<String> changedProps() {
return intercept.getDirtyPropertyNames();
}
@Override
public Map<String, ValuePair> getDirtyValues() {
public Map<String, ValuePair> dirtyValues() {
return intercept.getDirtyValues();
}
@@ -90,12 +90,12 @@ public final class DefaultBeanState implements BeanState {
}
@Override
public Map<String, Exception> getLoadErrors() {
public Map<String, Exception> loadErrors() {
return intercept.getLoadErrors();
}
@Override
public int getSortOrder() {
public int sortOrder() {
return intercept.getSortOrder();
}
}
@@ -1,7 +1,7 @@
package io.ebeaninternal.server.core;
import io.ebean.CallableSql;
import io.ebean.EbeanServer;
import io.ebean.Database;
import io.ebeaninternal.api.BindParams;
import io.ebeaninternal.api.BindParams.Param;
import io.ebeaninternal.api.SpiCallableSql;
@@ -9,39 +9,23 @@ import io.ebeaninternal.api.TransactionEventTable;
import java.io.Serializable;
import java.sql.CallableStatement;
import java.sql.SQLException;
public final class DefaultCallableSql implements Serializable, SpiCallableSql {
final class DefaultCallableSql implements Serializable, SpiCallableSql {
private static final long serialVersionUID = 8984272253185424701L;
private transient final EbeanServer server;
/**
* The callable sql.
*/
private String sql;
/**
* To display in the transaction log to help identify the procedure.
*/
private String label;
private int timeout;
/**
* Holds the table modification information. On commit this information is
* used to manage the cache etc.
*/
private final TransactionEventTable transactionEvent = new TransactionEventTable();
private final BindParams bindParameters = new BindParams();
private transient final Database server;
private String sql;
private String label;
private int timeout;
/**
* Create with callable sql.
*/
public DefaultCallableSql(EbeanServer server, String sql) {
DefaultCallableSql(Database server, String sql) {
this.server = server;
this.sql = sql;
}
@@ -108,13 +92,12 @@ public final class DefaultCallableSql implements Serializable, SpiCallableSql {
}
@Override
public boolean executeOverride(CallableStatement cstmt) throws SQLException {
public boolean executeOverride(CallableStatement statement) {
return false;
}
@Override
public CallableSql addModification(String tableName, boolean inserts, boolean updates, boolean deletes) {
transactionEvent.add(tableName, inserts, updates, deletes);
return this;
}
@@ -122,7 +105,7 @@ public final class DefaultCallableSql implements Serializable, SpiCallableSql {
/**
* Return the TransactionEvent which holds the table modification
* information for this CallableSql. This information is merged into the
* transaction after the transaction is commited.
* transaction after the transaction is committed.
*/
@Override
public TransactionEventTable getTransactionEventTable() {
@@ -15,7 +15,7 @@ final class DefaultQueryPlanListener implements QueryPlanListener {
@Override
public void process(QueryPlanCapture capture) {
// better to log this in JSON form?
String dbName = capture.getDatabase().getName();
String dbName = capture.getDatabase().name();
for (MetaQueryPlan plan : capture.getPlans()) {
log.info("queryPlan db:{} label:{} queryTimeMicros:{} loc:{} sql:{} bind:{} plan:{}",
dbName, plan.label(), plan.queryTimeMicros(), plan.profileLocation(),
@@ -129,16 +129,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.time.Clock;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.Spliterator;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
@@ -295,7 +286,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
@Override
public int getLazyLoadBatchSize() {
public int lazyLoadBatchSize() {
return lazyLoadBatchSize;
}
@@ -305,12 +296,12 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
@Override
public DatabaseConfig getServerConfig() {
public DatabaseConfig config() {
return config;
}
@Override
public DatabasePlatform getDatabasePlatform() {
public DatabasePlatform databasePlatform() {
return databasePlatform;
}
@@ -320,57 +311,57 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
@Override
public DataTimeZone getDataTimeZone() {
public DataTimeZone dataTimeZone() {
return dataTimeZone;
}
@Override
public MetaInfoManager getMetaInfoManager() {
public MetaInfoManager metaInfo() {
return metaInfoManager;
}
@Override
public Platform getPlatform() {
public Platform platform() {
return databasePlatform.getPlatform();
}
@Override
public SpiServer getPluginApi() {
public SpiServer pluginApi() {
return this;
}
@Override
public BackgroundExecutor getBackgroundExecutor() {
public BackgroundExecutor backgroundExecutor() {
return backgroundExecutor;
}
@Override
public ExpressionFactory getExpressionFactory() {
public ExpressionFactory expressionFactory() {
return expressionFactory;
}
@Override
public AutoTune getAutoTune() {
public AutoTune autoTune() {
return autoTuneService;
}
@Override
public DataSource getDataSource() {
public DataSource dataSource() {
return transactionManager.getDataSource();
}
@Override
public DataSource getReadOnlyDataSource() {
public DataSource readOnlyDataSource() {
return transactionManager.getReadOnlyDataSource();
}
@Override
public ReadAuditPrepare getReadAuditPrepare() {
public ReadAuditPrepare readAuditPrepare() {
return readAuditPrepare;
}
@Override
public ReadAuditLogger getReadAuditLogger() {
public ReadAuditLogger readAuditLogger() {
return readAuditLogger;
}
@@ -381,7 +372,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
if (encryptKeyManager != null) {
encryptKeyManager.initialise();
}
serverCacheManager.setEnabledRegions(config.getEnabledL2Regions());
serverCacheManager.enabledRegions(config.getEnabledL2Regions());
}
/**
@@ -499,7 +490,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
* Return the server name.
*/
@Override
public String getName() {
public String name() {
return serverName;
}
@@ -519,7 +510,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
@Override
public BeanState getBeanState(Object bean) {
public BeanState beanState(Object bean) {
if (bean instanceof EntityBean) {
return new DefaultBeanState((EntityBean) bean);
}
@@ -538,7 +529,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
@Override
public ServerCacheManager getServerCacheManager() {
public ServerCacheManager cacheManager() {
return serverCacheManager;
}
@@ -595,7 +586,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
if (a == null) {
return null;
}
BeanDescriptor<?> desc = getBeanDescriptor(a.getClass());
BeanDescriptor<?> desc = descriptor(a.getClass());
return DiffHelp.diff(a, b, desc);
}
@@ -628,14 +619,14 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
public void truncate(Class<?>... types) {
List<String> tableNames = new ArrayList<>();
for (Class<?> type : types) {
tableNames.add(getBeanDescriptor(type).getBaseTable());
tableNames.add(descriptor(type).baseTable());
}
truncate(tableNames.toArray(new String[0]));
}
@Override
public void truncate(String... tables) {
try (Connection connection = getDataSource().getConnection()) {
try (Connection connection = dataSource().getConnection()) {
for (String table : tables) {
executeSql(connection, databasePlatform.truncateStatement(table));
}
@@ -659,7 +650,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
*/
@Override
public void clearQueryStatistics() {
for (BeanDescriptor<?> desc : getBeanDescriptors()) {
for (BeanDescriptor<?> desc : descriptors()) {
desc.clearQueryStatistics();
}
}
@@ -674,7 +665,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
*/
@Override
public <T> T createEntityBean(Class<T> type) {
return getBeanDescriptor(type).createBean();
return descriptor(type).createBean();
}
/**
@@ -687,11 +678,11 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
*/
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public <T> T getReference(Class<T> type, Object id) {
public <T> T reference(Class<T> type, Object id) {
if (id == null) {
throw new NullPointerException("The id is null");
}
BeanDescriptor desc = getBeanDescriptor(type);
BeanDescriptor desc = descriptor(type);
id = desc.convertId(id);
PersistenceContext pc = null;
SpiTransaction t = transactionManager.getActive();
@@ -703,17 +694,17 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
}
InheritInfo inheritInfo = desc.getInheritInfo();
InheritInfo inheritInfo = desc.inheritInfo();
if (inheritInfo == null || inheritInfo.isConcrete()) {
return (T) desc.contextRef(pc, null, false, id);
}
BeanProperty idProp = desc.getIdProperty();
BeanProperty idProp = desc.idProperty();
if (idProp == null) {
throw new PersistenceException("No ID properties for this type? " + desc);
}
// we actually need to do a query because we don't know the type without the discriminator
// value, just select the id property and discriminator column (auto added)
return find(type).select(idProp.getName()).setId(id).findOne();
return find(type).select(idProp.name()).setId(id).findOne();
}
@Override
@@ -852,7 +843,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public Object nextId(Class<?> beanType) {
BeanDescriptor<?> desc = getBeanDescriptor(beanType);
BeanDescriptor<?> desc = descriptor(beanType);
return desc.nextId(null);
}
@@ -871,7 +862,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
// use first bean in the list as the correct type
Class<T> beanType = (Class<T>) list.get(0).getClass();
BeanDescriptor<T> beanDescriptor = getBeanDescriptor(beanType);
BeanDescriptor<T> beanDescriptor = descriptor(beanType);
if (beanDescriptor == null) {
throw new PersistenceException("BeanDescriptor not found, is [" + beanType + "] an entity bean?");
}
@@ -880,7 +871,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public <T> Set<String> validateQuery(Query<T> query) {
BeanDescriptor<T> beanDescriptor = getBeanDescriptor(query.getBeanType());
BeanDescriptor<T> beanDescriptor = descriptor(query.getBeanType());
if (beanDescriptor == null) {
throw new PersistenceException("BeanDescriptor not found, is [" + query.getBeanType() + "] an entity bean?");
}
@@ -889,7 +880,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public <T> Filter<T> filter(Class<T> beanType) {
BeanDescriptor<T> desc = getBeanDescriptor(beanType);
BeanDescriptor<T> desc = descriptor(beanType);
if (desc == null) {
String m = beanType.getName() + " is NOT an Entity Bean registered with this server?";
throw new PersistenceException(m);
@@ -899,7 +890,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public <T> CsvReader<T> createCsvReader(Class<T> beanType) {
BeanDescriptor<T> descriptor = getBeanDescriptor(beanType);
BeanDescriptor<T> descriptor = descriptor(beanType);
if (descriptor == null) {
throw new NullPointerException("BeanDescriptor for " + beanType.getName() + " not found");
}
@@ -923,13 +914,27 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public void merge(Object bean, MergeOptions options, Transaction transaction) {
BeanDescriptor<?> desc = getBeanDescriptor(bean.getClass());
BeanDescriptor<?> desc = descriptor(bean.getClass());
if (desc == null) {
throw new PersistenceException(bean.getClass().getName() + " is NOT an Entity Bean registered with this server?");
}
executeInTrans((txn) -> persister.merge(desc, checkEntityBean(bean), options, txn), transaction);
}
@Override
public void lock(Object bean) {
BeanDescriptor<?> desc = descriptor(bean.getClass());
if (desc == null) {
throw new PersistenceException(bean.getClass() + " is NOT an Entity Bean registered with this server?");
}
Object id = desc.id(bean);
Objects.requireNonNull(id, "Bean missing an @Id value which is required to lock");
new DefaultOrmQuery<>(desc, this, expressionFactory)
.setId(id)
.withLock(Query.LockType.DEFAULT, Query.LockWait.NOWAIT)
.findOne();
}
@Override
public <T> Query<T> find(Class<T> beanType) {
return createQuery(beanType);
@@ -937,7 +942,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public <T> Query<T> findNative(Class<T> beanType, String nativeSql) {
BeanDescriptor<T> desc = getBeanDescriptor(beanType);
BeanDescriptor<T> desc = descriptor(beanType);
if (desc == null) {
throw new PersistenceException(beanType.getName() + " is NOT an Entity Bean registered with this server?");
}
@@ -948,15 +953,15 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public <T> Query<T> createNamedQuery(Class<T> beanType, String namedQuery) {
BeanDescriptor<T> desc = getBeanDescriptor(beanType);
BeanDescriptor<T> desc = descriptor(beanType);
if (desc == null) {
throw new PersistenceException(beanType.getName() + " is NOT an Entity Bean registered with this server?");
}
String named = desc.getNamedQuery(namedQuery);
String named = desc.namedQuery(namedQuery);
if (named != null) {
return createQuery(beanType, named);
}
SpiRawSql rawSql = desc.getNamedRawSql(namedQuery);
SpiRawSql rawSql = desc.namedRawSql(namedQuery);
if (rawSql != null) {
DefaultOrmQuery<T> query = createQuery(beanType);
query.setRawSql(rawSql);
@@ -974,7 +979,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public <T> DefaultOrmQuery<T> createQuery(Class<T> beanType) {
BeanDescriptor<T> desc = getBeanDescriptor(beanType);
BeanDescriptor<T> desc = descriptor(beanType);
if (desc == null) {
throw new PersistenceException(beanType.getName() + " is NOT an Entity Bean registered with this server?");
}
@@ -983,12 +988,12 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public <T> Update<T> createUpdate(Class<T> beanType, String ormUpdate) {
BeanDescriptor<?> desc = getBeanDescriptor(beanType);
BeanDescriptor<?> desc = descriptor(beanType);
if (desc == null) {
String m = beanType.getName() + " is NOT an Entity Bean registered with this server?";
throw new PersistenceException(m);
}
return new DefaultOrmUpdate<>(beanType, this, desc.getBaseTable(), ormUpdate);
return new DefaultOrmUpdate<>(beanType, this, desc.baseTable(), ormUpdate);
}
@Override
@@ -1134,14 +1139,14 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
* Return true if transactions PersistenceContext should be used.
*/
private <T> boolean useTransactionPersistenceContext(SpiQuery<T> query) {
return PersistenceContextScope.TRANSACTION == getPersistenceContextScope(query);
return PersistenceContextScope.TRANSACTION == persistenceContextScope(query);
}
/**
* Return the PersistenceContextScope to use defined at query or server level.
*/
@Override
public PersistenceContextScope getPersistenceContextScope(SpiQuery<?> query) {
public PersistenceContextScope persistenceContextScope(SpiQuery<?> query) {
PersistenceContextScope scope = query.getPersistenceContextScope();
return (scope != null) ? scope : defaultPersistenceContextScope;
}
@@ -1227,7 +1232,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
request.resetBeanCacheAutoMode(false);
if ((t == null || !t.isSkipCache()) && request.getFromBeanCache()) {
// hit bean cache and got all results from cache
return request.getBeanCacheHitsAsMap();
return request.beanCacheHitsAsMap();
}
Object result = request.getFromQueryCache();
if (result != null) {
@@ -1312,7 +1317,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
SpiOrmQueryRequest<?> request = createQueryRequest(Type.ID_LIST, query, t);
Object result = request.getFromQueryCache();
if (result != null) {
if (Boolean.FALSE.equals(request.getQuery().isReadOnly())) {
if (Boolean.FALSE.equals(request.query().isReadOnly())) {
return new CopyOnFirstWriteList<>((List<A>) result);
} else {
return (List<A>) result;
@@ -1341,7 +1346,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
if (ids.isEmpty()) {
return 0;
} else {
return persister.deleteByIds(request.getBeanDescriptor(), ids, request.getTransaction(), false);
return persister.deleteByIds(request.descriptor(), ids, request.transaction(), false);
}
}
} finally {
@@ -1391,7 +1396,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
// FutureList query always run in it's own persistence content
spiQuery.setPersistenceContext(new DefaultPersistenceContext());
if (!spiQuery.isDisableReadAudit()) {
BeanDescriptor<T> desc = beanDescriptorManager.getBeanDescriptor(spiQuery.getBeanType());
BeanDescriptor<T> desc = beanDescriptorManager.descriptor(spiQuery.getBeanType());
desc.readAuditFutureList(spiQuery);
}
// Create a new transaction solely to execute the findList() at some future time
@@ -1504,7 +1509,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
request.resetBeanCacheAutoMode(findOne);
if ((t == null || !t.isSkipCache()) && request.getFromBeanCache()) {
// hit bean cache and got all results from cache
return request.getBeanCacheHits();
return request.beanCacheHits();
}
request.prepareQuery();
Object result = request.getFromQueryCache();
@@ -2048,26 +2053,26 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
* Return all the BeanDescriptors.
*/
@Override
public List<BeanDescriptor<?>> getBeanDescriptors() {
return beanDescriptorManager.getBeanDescriptorList();
public List<BeanDescriptor<?>> descriptors() {
return beanDescriptorManager.descriptorList();
}
/**
* Return the transaction manager.
*/
@Override
public SpiTransactionManager getTransactionManager() {
public SpiTransactionManager transactionManager() {
return transactionManager;
}
public void register(BeanPersistController controller) {
for (BeanDescriptor<?> desc : beanDescriptorManager.getBeanDescriptorList()) {
for (BeanDescriptor<?> desc : beanDescriptorManager.descriptorList()) {
desc.register(controller);
}
}
public void deregister(BeanPersistController c) {
for (BeanDescriptor<?> desc : beanDescriptorManager.getBeanDescriptorList()) {
for (BeanDescriptor<?> desc : beanDescriptorManager.descriptorList()) {
desc.deregister(c);
}
}
@@ -2075,13 +2080,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public boolean isSupportedType(java.lang.reflect.Type genericType) {
TypeInfo typeInfo = ParamTypeHelper.getTypeInfo(genericType);
return typeInfo != null && getBeanDescriptor(typeInfo.getBeanType()) != null;
return typeInfo != null && descriptor(typeInfo.getBeanType()) != null;
}
@Override
public Object setBeanId(Object bean, Object id) {
public Object beanId(Object bean, Object id) {
EntityBean eb = checkEntityBean(bean);
BeanDescriptor<?> desc = getBeanDescriptor(bean.getClass());
BeanDescriptor<?> desc = descriptor(bean.getClass());
if (desc == null) {
throw new PersistenceException(bean.getClass().getName() + " is NOT an Entity Bean registered with this server?");
}
@@ -2089,9 +2094,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
@Override
public Object getBeanId(Object bean) {
public Object beanId(Object bean) {
EntityBean eb = checkEntityBean(bean);
BeanDescriptor<?> desc = getBeanDescriptor(bean.getClass());
BeanDescriptor<?> desc = descriptor(bean.getClass());
if (desc == null) {
throw new PersistenceException(bean.getClass().getName() + " is NOT an Entity Bean registered with this server?");
}
@@ -2102,58 +2107,58 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
* Return the BeanDescriptor for a given type of bean.
*/
@Override
public <T> BeanDescriptor<T> getBeanDescriptor(Class<T> beanClass) {
return beanDescriptorManager.getBeanDescriptor(beanClass);
public <T> BeanDescriptor<T> descriptor(Class<T> beanClass) {
return beanDescriptorManager.descriptor(beanClass);
}
/**
* Return the BeanDescriptor's for a given table name.
*/
@Override
public List<BeanDescriptor<?>> getBeanDescriptors(String tableName) {
return beanDescriptorManager.getBeanDescriptors(tableName);
public List<BeanDescriptor<?>> descriptors(String tableName) {
return beanDescriptorManager.descriptors(tableName);
}
/**
* Return all the SPI BeanTypes.
*/
@Override
public List<? extends BeanType<?>> getBeanTypes() {
return getBeanDescriptors();
public List<? extends BeanType<?>> beanTypes() {
return descriptors();
}
/**
* Return the SPI bean types mapped to the given table.
*/
@Override
public List<? extends BeanType<?>> getBeanTypes(String tableName) {
return beanDescriptorManager.getBeanTypes(tableName);
public List<? extends BeanType<?>> beanTypes(String tableName) {
return beanDescriptorManager.beanTypes(tableName);
}
@Override
public BeanType<?> getBeanTypeForQueueId(String queueId) {
return getBeanDescriptorByQueueId(queueId);
public BeanType<?> beanTypeForQueueId(String queueId) {
return descriptorByQueueId(queueId);
}
@Override
public BeanDescriptor<?> getBeanDescriptorByQueueId(String queueId) {
return beanDescriptorManager.getBeanDescriptorByQueueId(queueId);
public BeanDescriptor<?> descriptorByQueueId(String queueId) {
return beanDescriptorManager.descriptorByQueueId(queueId);
}
/**
* Return the SPI bean types for the given bean class.
*/
@Override
public <T> BeanType<T> getBeanType(Class<T> beanType) {
return getBeanDescriptor(beanType);
public <T> BeanType<T> beanType(Class<T> beanType) {
return descriptor(beanType);
}
/**
* Return the BeanDescriptor using its class name.
*/
@Override
public BeanDescriptor<?> getBeanDescriptorById(String beanClassName) {
return beanDescriptorManager.getBeanDescriptorByClassName(beanClassName);
public BeanDescriptor<?> descriptorById(String beanClassName) {
return beanDescriptorManager.descriptorByClassName(beanClassName);
}
/**
@@ -2278,13 +2283,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public Set<Property> checkUniqueness(Object bean, Transaction transaction) {
EntityBean entityBean = checkEntityBean(bean);
BeanDescriptor<?> beanDesc = getBeanDescriptor(entityBean.getClass());
BeanProperty idProperty = beanDesc.getIdProperty();
BeanDescriptor<?> beanDesc = descriptor(entityBean.getClass());
BeanProperty idProperty = beanDesc.idProperty();
// if the ID of the Property is null we are unable to check uniqueness
if (idProperty == null) {
return Collections.emptySet();
}
Object id = idProperty.getVal(entityBean);
Object id = idProperty.value(entityBean);
if (entityBean._ebean_getIntercept().isNew() && id != null) {
// Primary Key is changeable only on new models - so skip check if we are not new
Query<?> query = new DefaultOrmQuery<>(beanDesc, this, expressionFactory);
@@ -2293,7 +2298,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
return Collections.singleton(idProperty);
}
}
for (BeanProperty[] props : beanDesc.getUniqueProps()) {
for (BeanProperty[] props : beanDesc.uniqueProps()) {
Set<Property> ret = checkUniqueness(entityBean, beanDesc, props, transaction);
if (ret != null) {
return ret;
@@ -2306,19 +2311,19 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
* Returns a set of properties if saving the bean will violate the unique constraints (defined by given properties).
*/
private Set<Property> checkUniqueness(EntityBean entityBean, BeanDescriptor<?> beanDesc, BeanProperty[] props, Transaction transaction) {
BeanProperty idProperty = beanDesc.getIdProperty();
BeanProperty idProperty = beanDesc.idProperty();
Query<?> query = new DefaultOrmQuery<>(beanDesc, this, expressionFactory);
ExpressionList<?> exprList = query.where();
if (!entityBean._ebean_getIntercept().isNew()) {
// if model is not new, exclude ourself.
exprList.ne(idProperty.getName(), idProperty.getVal(entityBean));
exprList.ne(idProperty.name(), idProperty.value(entityBean));
}
for (Property prop : props) {
Object value = prop.getVal(entityBean);
Object value = prop.value(entityBean);
if (value == null) {
return null;
}
exprList.eq(prop.getName(), value);
exprList.eq(prop.name(), value);
}
if (findCount(query, transaction) > 0) {
Set<Property> ret = new LinkedHashSet<>();
@@ -1,6 +1,6 @@
package io.ebeaninternal.server.core;
import io.ebean.Ebean;
import io.ebean.DB;
import io.ebean.SqlUpdate;
import io.ebean.Update;
import io.ebeaninternal.api.BindParams;
@@ -143,7 +143,7 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
return server.execute(this);
} else {
// Hopefully this doesn't catch anyone out...
return Ebean.execute(this);
return DB.getDefault().execute(this);
}
}
@@ -167,7 +167,6 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
return server.executeBatch(this, transaction);
}
@Override
public void addBatch() {
if (server == null) {
@@ -179,7 +178,6 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
throw new IllegalStateException("No current transaction? Must have a transaction to use addBatch()");
}
}
batched = true;
server.addBatch(this, transaction);
}
@@ -287,8 +285,7 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
return this;
}
private SqlUpdate setParamWithBindExpansion(int position, Collection values, String bindLiteral) {
private SqlUpdate setParamWithBindExpansion(int position, Collection<?> values, String bindLiteral) {
StringBuilder sqlExpand = new StringBuilder(values.size() * 2);
position = position + bindExpansion;
int offset = 0;
@@ -310,10 +307,9 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
String bindLiteral = "?" + position;
int pos = baseSql.indexOf(bindLiteral);
if (pos > -1) {
return setParamWithBindExpansion(position, (Collection) value, bindLiteral);
return setParamWithBindExpansion(position, (Collection<?>) value, bindLiteral);
}
}
bindParams.setParameter(bindExpansion + position, value);
return this;
}
@@ -66,7 +66,7 @@ public final class DtoQueryRequest<T> extends AbstractSqlQueryRequest {
@Override
protected void setResultSet(ResultSet resultSet, Object queryPlanKey) throws SQLException {
this.resultSet = resultSet;
this.dataReader = new RsetDataReader(server.getDataTimeZone(), resultSet);
this.dataReader = new RsetDataReader(server.dataTimeZone(), resultSet);
obtainPlan(queryPlanKey);
}
@@ -114,6 +114,7 @@ public final class DtoQueryRequest<T> extends AbstractSqlQueryRequest {
return queryEngine.findList(this);
}
@Override
public boolean next() throws SQLException {
query.checkCancelled();
return dataReader.next();
@@ -73,8 +73,8 @@ final class DumpMetrics {
void dump() {
out("-- Dumping metrics for " + server.getName() + " -- ");
ServerMetrics serverMetrics = server.getMetaInfoManager().collectMetrics();
out("-- Dumping metrics for " + server.name() + " -- ");
ServerMetrics serverMetrics = server.metaInfo().collectMetrics();
for (MetaTimedMetric metric : serverMetrics.timedMetrics()) {
log(metric);
@@ -24,7 +24,7 @@ final class DumpMetricsData {
}
List<MetricData> data() {
collect(database.getMetaInfoManager().collectMetrics());
collect(database.metaInfo().collectMetrics());
return list;
}
@@ -66,14 +66,14 @@ final class DumpMetricsJson implements ServerMetricsAsJson {
@Override
public String json() {
writer = new StringWriter();
collect(database.getMetaInfoManager().collectMetrics());
collect(database.metaInfo().collectMetrics());
return writer.toString();
}
@Override
public void write(Appendable buffer) {
writer = buffer;
collect(database.getMetaInfoManager().collectMetrics());
collect(database.metaInfo().collectMetrics());
}
private void collect(ServerMetrics serverMetrics) {
@@ -112,7 +112,7 @@ final class DumpMetricsJson implements ServerMetricsAsJson {
if (withHeader) {
objStart();
key("db");
val(database.getName());
val(database.name());
key("metrics");
listStart();
}
@@ -175,7 +175,7 @@ public final class InternalConfiguration {
this.dtoBeanManager = new DtoBeanManager(typeManager, xmlMap.readDtoMapping());
this.beanDescriptorManager = new BeanDescriptorManager(this);
Map<String, String> asOfTableMapping = beanDescriptorManager.deploy(xmlMap.xmlDeployment());
Map<String, String> draftTableMap = beanDescriptorManager.getDraftTableMap();
Map<String, String> draftTableMap = beanDescriptorManager.draftTableMap();
beanDescriptorManager.scheduleBackgroundTrim();
this.dataTimeZone = initDataTimeZone();
this.binder = getBinder(typeManager, databasePlatform, dataTimeZone);
@@ -60,42 +60,25 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
private static final Logger log = LoggerFactory.getLogger(OrmQueryRequest.class);
private final BeanDescriptor<T> beanDescriptor;
private final OrmQueryEngine queryEngine;
private final SpiQuery<T> query;
private final BeanFindController finder;
private final Boolean readOnly;
private LoadContext loadContext;
private PersistenceContext persistenceContext;
private JsonReadOptions jsonRead;
private HashQuery cacheKey;
private CQueryPlanKey queryPlanKey;
private SpiQuerySecondary secondaryQueries;
private List<T> cacheBeans;
private BeanPropertyAssocMany<?> manyProperty;
private boolean inlineCountDistinct;
private Set<String> dependentTables;
/**
* Create the InternalQueryRequest.
*/
public OrmQueryRequest(SpiEbeanServer server, OrmQueryEngine queryEngine, SpiQuery<T> query, SpiTransaction t) {
super(server, t);
this.beanDescriptor = query.getBeanDescriptor();
this.finder = beanDescriptor.getBeanFinder();
this.finder = beanDescriptor.beanFinder();
this.queryEngine = queryEngine;
this.query = query;
this.readOnly = query.isReadOnly();
@@ -145,8 +128,8 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
* Return the database platform like clause.
*/
@Override
public String getDBLikeClause(boolean rawLikeExpression) {
return ebeanServer.getDatabasePlatform().getLikeClause(rawLikeExpression);
public String dbLikeClause(boolean rawLikeExpression) {
return server.databasePlatform().getLikeClause(rawLikeExpression);
}
/**
@@ -154,7 +137,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
*/
@Override
public String escapeLikeString(String value) {
return ebeanServer.getDatabasePlatform().escapeLikeString(value);
return server.databasePlatform().escapeLikeString(value);
}
@Override
@@ -171,9 +154,8 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
* <p>
* If -1 is returned then NO secondary queries are registered and simple
* iteration is fine.
* </p>
*/
public int getSecondaryQueriesMinBatchSize() {
public int secondaryQueriesMinBatchSize() {
return loadContext.getSecondaryQueriesMinBatchSize();
}
@@ -188,14 +170,14 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
* Return the BeanDescriptor for the associated bean.
*/
@Override
public BeanDescriptor<T> getBeanDescriptor() {
public BeanDescriptor<T> descriptor() {
return beanDescriptor;
}
/**
* Return the graph context for this query.
*/
public LoadContext getGraphContext() {
public LoadContext loadContext() {
return loadContext;
}
@@ -208,7 +190,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
* Run BeanQueryAdapter preQuery() if needed.
*/
private void adapterPreQuery() {
BeanQueryAdapter queryAdapter = beanDescriptor.getQueryAdapter();
BeanQueryAdapter queryAdapter = beanDescriptor.queryAdapter();
if (queryAdapter != null) {
queryAdapter.preQuery(this);
}
@@ -244,7 +226,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
/**
* Return the PersistenceContext used for this request.
*/
public PersistenceContext getPersistenceContext() {
public PersistenceContext persistenceContext() {
return persistenceContext;
}
@@ -271,15 +253,15 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
if (transaction == null) {
if (query.getType().isUpdate()) {
// bulk update or delete query
transaction = ebeanServer.beginServerTransaction();
transaction = server.beginServerTransaction();
} else {
// create an implicit transaction to execute this query
// potentially using read-only DataSource with autoCommit
transaction = ebeanServer.createReadOnlyTransaction(query.getTenantId());
transaction = server.createReadOnlyTransaction(query.getTenantId());
}
createdTransaction = true;
}
persistenceContext = getPersistenceContext(query, transaction);
persistenceContext = persistenceContext(query, transaction);
loadContext = new DLoadContext(this, secondaryQueries);
}
@@ -305,7 +287,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
*/
@Override
public JsonReadOptions createJsonReadOptions() {
persistenceContext = getPersistenceContext(query, transaction);
persistenceContext = persistenceContext(query, transaction);
if (query.getPersistenceContext() == null) {
query.setPersistenceContext(persistenceContext);
}
@@ -336,14 +318,14 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
* Get the TransactionContext either explicitly set on the query or
* transaction scoped.
*/
private PersistenceContext getPersistenceContext(SpiQuery<?> query, SpiTransaction t) {
private PersistenceContext persistenceContext(SpiQuery<?> query, SpiTransaction t) {
// check if there is already a persistence context set which is the case
// when lazy loading or query joins are executed
PersistenceContext ctx = query.getPersistenceContext();
if (ctx != null) return ctx;
// determine the scope (from the query and then server)
PersistenceContextScope scope = ebeanServer.getPersistenceContextScope(query);
PersistenceContextScope scope = server.persistenceContextScope(query);
if (scope == PersistenceContextScope.QUERY || t == null) {
return new DefaultPersistenceContext();
}
@@ -365,7 +347,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
transaction.commit();
if (query.getType().isUpdate()) {
// for implicit update/delete queries clear the thread local
ebeanServer.clearServerTransaction();
server.clearServerTransaction();
}
}
}
@@ -486,9 +468,9 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
public <K> Map<K, T> findMap() {
String mapKey = query.getMapKey();
if (mapKey == null) {
BeanProperty idProp = beanDescriptor.getIdProperty();
BeanProperty idProp = beanDescriptor.idProperty();
if (idProp != null) {
query.setMapKey(idProp.getName());
query.setMapKey(idProp.name());
} else {
throw new PersistenceException("No mapKey specified for query");
}
@@ -504,12 +486,12 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
/**
* Return a bean specific finder if one has been set.
*/
public BeanFindController getBeanFinder() {
public BeanFindController finder() {
return finder;
}
@Override
public SpiQuery<T> getQuery() {
public SpiQuery<T> query() {
return query;
}
@@ -517,14 +499,14 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
* Determine and return the ToMany property that is included in the query.
*/
public BeanPropertyAssocMany<?> determineMany() {
manyProperty = beanDescriptor.getManyProperty(query);
manyProperty = beanDescriptor.manyProperty(query);
return manyProperty;
}
/**
* Return the many property that is fetched in the query or null if there is not one.
*/
public BeanPropertyAssocMany<?> getManyProperty() {
public BeanPropertyAssocMany<?> manyProperty() {
return manyProperty;
}
@@ -532,8 +514,8 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
* Return a queryPlan for the current query if one exists. Returns null if no
* query plan for this query exists.
*/
public CQueryPlan getQueryPlan() {
return beanDescriptor.getQueryPlan(queryPlanKey);
public CQueryPlan queryPlan() {
return beanDescriptor.queryPlan(queryPlanKey);
}
/**
@@ -542,9 +524,8 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
* This identifies the query plan for a given bean type. It effectively
* matches a SQL statement with ? bind variables. A query plan can be reused
* with just the bind variables changing.
* </p>
*/
public CQueryPlanKey getQueryPlanKey() {
public CQueryPlanKey queryPlanKey() {
return queryPlanKey;
}
@@ -552,7 +533,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
* Put the QueryPlan into the cache.
*/
public void putQueryPlan(CQueryPlan queryPlan) {
beanDescriptor.putQueryPlan(queryPlanKey, queryPlan);
beanDescriptor.queryPlan(queryPlanKey, queryPlan);
}
@Override
@@ -608,7 +589,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
}
@Override
public List<T> getBeanCacheHits() {
public List<T> beanCacheHits() {
OrderBy<T> orderBy = query.getOrderBy();
if (orderBy != null) {
beanDescriptor.sort(cacheBeans, orderBy.toStringFormat());
@@ -617,7 +598,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
}
@Override
public <K> Map<K, T> getBeanCacheHitsAsMap() {
public <K> Map<K, T> beanCacheHitsAsMap() {
OrderBy<T> orderBy = query.getOrderBy();
if (orderBy != null) {
beanDescriptor.sort(cacheBeans, orderBy.toStringFormat());
@@ -636,7 +617,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
}
private ElPropertyValue mapProperty() {
ElPropertyValue property = beanDescriptor.getElGetValue(query.getMapKey());
ElPropertyValue property = beanDescriptor.elGetValue(query.getMapKey());
if (property == null) {
throw new IllegalStateException("Unknown map key property "+query.getMapKey());
}
@@ -665,7 +646,6 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
if (!beanDescriptor.isNaturalKeyCaching()) {
return false;
}
NaturalKeyQueryData<T> data = query.naturalKey();
if (data != null) {
NaturalKeySet naturalKeySet = data.buildKeys();
@@ -688,30 +668,27 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
public Object getFromQueryCache() {
if (query.getUseQueryCache() == CacheMode.OFF
|| (transaction != null && transaction.isSkipCache())
|| ebeanServer.isDisableL2Cache()) {
|| server.isDisableL2Cache()) {
return null;
} else {
cacheKey = query.queryHash();
}
if (!query.getUseQueryCache().isGet()) {
return null;
}
Object cached = beanDescriptor.queryCacheGet(cacheKey);
if (cached != null && isAuditReads() && readAuditQueryType()) {
if (cached instanceof BeanCollection) {
// raw sql can't use L2 cache so normal queries only in here
Collection<T> actualDetails = ((BeanCollection<T>)cached).getActualDetails();
List<Object> ids = new ArrayList<>(actualDetails.size());
for (T bean : actualDetails) {
ids.add(beanDescriptor.getIdForJson(bean));
ids.add(beanDescriptor.idForJson(bean));
}
beanDescriptor.readAuditMany(queryPlanKey.getPartialKey(), "l2-query-cache", ids);
}
}
if (Boolean.FALSE.equals(query.isReadOnly())) {
// return shallow copies if readonly is explicitly set to false
if (cached instanceof BeanCollection) {
@@ -750,7 +727,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
}
/**
* Set an Query object that owns the PreparedStatement that can be cancelled.
* Set a Query object that owns the PreparedStatement that can be cancelled.
*/
public void setCancelableQuery(CancelableQuery cancelableQuery) {
query.setCancelableQuery(cancelableQuery);
@@ -766,16 +743,15 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
/**
* Return the batch size for lazy loading on this bean query request.
*/
public int getLazyLoadBatchSize() {
public int lazyLoadBatchSize() {
int batchSize = query.getLazyLoadBatchSize();
return (batchSize > 0) ? batchSize : ebeanServer.getLazyLoadBatchSize();
return (batchSize > 0) ? batchSize : server.lazyLoadBatchSize();
}
/**
* Return true if read auditing is on for this query request.
* <p>
* This means that read audit is on for this bean type and that query has not explicitly disabled it.
* </p>
*/
public boolean isAuditReads() {
return beanDescriptor.isReadAuditing() && !query.isDisableReadAudit();
@@ -784,8 +760,8 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
/**
* Return the base table alias for this query.
*/
public String getBaseTableAlias() {
return query.getAlias(beanDescriptor.getBaseTableAlias());
public String baseTableAlias() {
return query.getAlias(beanDescriptor.baseTableAlias());
}
/**
@@ -798,7 +774,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
/**
* Return the tenantId associated with this request.
*/
public Object getTenantId() {
public Object tenantId() {
return (transaction == null) ? null : transaction.getTenantId();
}
@@ -806,7 +782,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
* Check for slow query event.
*/
public void slowQueryCheck(long executionTimeMicros, int rowCount) {
ebeanServer.slowQueryCheck(executionTimeMicros, rowCount, query);
server.slowQueryCheck(executionTimeMicros, rowCount, query);
}
public void setInlineCountDistinct() {
@@ -830,6 +806,6 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
* Return true if no MaxRows or use LIMIT in SQL update.
*/
public boolean isInlineSqlUpdateLimit() {
return query.getMaxRows() < 1 || ebeanServer.getDatabasePlatform().isInlineSqlUpdateLimit();
return query.getMaxRows() < 1 || server.databasePlatform().isInlineSqlUpdateLimit();
}
}
@@ -35,13 +35,13 @@ public final class PersistDeferredRelationship {
*/
public void execute(SpiTransaction transaction) {
String sql = beanDescriptor.getUpdateImportedIdSql(importedId);
String sql = beanDescriptor.updateImportedIdSql(importedId);
SqlUpdate sqlUpdate = ebeanServer.sqlUpdate(sql);
// bind the set clause for the importedId
int pos = importedId.bind(1, sqlUpdate, assocBean);
// bind the where clause for the bean
Object[] idValues = beanDescriptor.getIdBinder().getIdValues(bean);
Object[] idValues = beanDescriptor.idBinder().getIdValues(bean);
for (int j = 0; j < idValues.length; j++) {
sqlUpdate.setParameter(pos + j, idValues[j]);
}
@@ -31,17 +31,10 @@ public abstract class PersistRequest extends BeanRequest implements BatchPostExe
}
}
boolean persistCascade;
/**
* One of INSERT, UPDATE, DELETE, UPDATESQL or CALLABLESQL.
*/
protected Type type;
boolean persistCascade;
final PersistExecute persistExecute;
protected String label;
protected long startNanos;
PersistRequest(SpiEbeanServer server, SpiTransaction t, PersistExecute persistExecute) {
@@ -95,12 +88,12 @@ public abstract class PersistRequest extends BeanRequest implements BatchPostExe
}
@Override
public boolean isLogSql() {
public boolean logSql() {
return transaction.isLogSql();
}
@Override
public boolean isLogSummary() {
public boolean logSummary() {
return transaction.isLogSummary();
}
@@ -149,10 +142,9 @@ public abstract class PersistRequest extends BeanRequest implements BatchPostExe
}
/**
* Return the type of this request. One of INSERT, UPDATE, DELETE, UPDATESQL
* or CALLABLESQL.
* Return the type of this request. One of INSERT, UPDATE, DELETE, UPDATESQL or CALLABLESQL.
*/
public Type getType() {
public Type type() {
return type;
}
@@ -50,142 +50,94 @@ import java.util.Set;
public final class PersistRequestBean<T> extends PersistRequest implements BeanPersistRequest<T>, DocStoreUpdate, PreGetterCallback, SpiProfileTransactionEvent {
private final BeanManager<T> beanManager;
private final BeanDescriptor<T> beanDescriptor;
private final BeanPersistListener beanPersistListener;
/**
* For per post insert update delete control.
*/
private final BeanPersistController controller;
/**
* The bean being persisted.
*/
private final T bean;
private final EntityBean entityBean;
/**
* The associated intercept.
*/
private final EntityBeanIntercept intercept;
/**
* The parent bean for unidirectional save.
*/
private final Object parentBean;
private final boolean dirty;
private final boolean publish;
private int flags;
private boolean saveRecurse;
private DocStoreMode docStoreMode;
private final ConcurrencyMode concurrencyMode;
/**
* The unique id used for logging summary.
*/
private Object idValue;
/**
* Hash value used to handle cascade delete both ways in a relationship.
*/
private Integer beanHash;
/**
* Flag set if this is a stateless update.
*/
private boolean statelessUpdate;
private boolean notifyCache;
/**
* Flag used to detect when only many properties where updated via a cascade. Used to ensure
* appropriate caches are updated in that case.
*/
private boolean updatedManysOnly;
/**
* Element collection change as part of bean cache.
*/
private Map<String, Object> collectionChanges;
/**
* Set true when the request includes cascade save to a many.
*/
private boolean updatedMany;
/**
* Many properties that were cascade saved (and hence might need caches updated later).
*/
private List<BeanPropertyAssocMany<?>> updatedManys;
/**
* Need to get and store the updated properties because the persist listener is notified
* later on a different thread and the bean has been reset at that point.
*/
private Set<String> updatedProperties;
/**
* Flags indicating the dirty properties on the bean.
*/
private boolean[] dirtyProperties;
/**
* Imported OneToOne orphan that needs to be deleted.
*/
private EntityBean orphanBean;
/**
* Flag set when request is added to JDBC batch.
*/
private boolean batched;
/**
* Flag set when batchOnCascade to avoid using batch on the top bean.
*/
private boolean skipBatchForTopLevel;
/**
* Flag set when batch mode is turned on for a persist cascade.
*/
private boolean batchOnCascadeSet;
/**
* Set for updates to determine if all loaded properties are included in the update.
*/
private boolean requestUpdateAllLoadedProps;
private long version;
private long now;
private long profileOffset;
/**
* Flag set when request is added to JDBC batch registered as a "getter callback" to automatically flush batch.
*/
private boolean getterCallback;
private boolean pendingPostUpdateNotify;
/**
* Set to true when post execute has occurred (so includes batch flush).
*/
private boolean postExecute;
/**
* Set to true after many properties have been persisted (so includes element collections).
*/
private boolean complete;
/**
* Many to many intersection table changes that are held for later batch processing.
*/
@@ -198,10 +150,10 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
this.intercept = entityBean._ebean_getIntercept();
this.beanManager = mgr;
this.beanDescriptor = mgr.getBeanDescriptor();
this.beanPersistListener = beanDescriptor.getPersistListener();
this.beanPersistListener = beanDescriptor.persistListener();
this.bean = bean;
this.parentBean = parentBean;
this.controller = beanDescriptor.getPersistController();
this.controller = beanDescriptor.persistController();
this.type = type;
this.docStoreMode = calcDocStoreMode(transaction, type);
this.flags = flags;
@@ -217,7 +169,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
// Mark Mutable scalar properties (like Hstore) as dirty where necessary
beanDescriptor.checkMutableProperties(intercept);
}
this.concurrencyMode = beanDescriptor.getConcurrencyMode(intercept);
this.concurrencyMode = beanDescriptor.concurrencyMode(intercept);
this.publish = Flags.isPublish(flags);
if (isMarkDraftDirty(publish)) {
beanDescriptor.setDraftDirty(entityBean, true);
@@ -247,7 +199,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
*/
@Override
public void profile(long offset, int flushCount) {
profileBase(type.profileEventId, offset, beanDescriptor.getName(), flushCount);
profileBase(type.profileEventId, offset, beanDescriptor.name(), flushCount);
}
/**
@@ -258,7 +210,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
*/
private DocStoreMode calcDocStoreMode(SpiTransaction txn, Type type) {
DocStoreMode txnMode = (txn == null) ? null : txn.getDocStoreMode();
return beanDescriptor.getDocStoreMode(type, txnMode);
return beanDescriptor.docStoreMode(type, txnMode);
}
/**
@@ -320,28 +272,28 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
private void onUpdateGeneratedProperties() {
for (BeanProperty prop : beanDescriptor.propertiesGenUpdate()) {
GeneratedProperty generatedProperty = prop.getGeneratedProperty();
GeneratedProperty generatedProperty = prop.generatedProperty();
if (prop.isVersion()) {
if (isLoadedProperty(prop)) {
// @Version property must be loaded to be involved
Object value = generatedProperty.getUpdateValue(prop, entityBean, now());
Object oldVal = prop.getValue(entityBean);
setVersionValue(value);
intercept.setOldValue(prop.getPropertyIndex(), oldVal);
intercept.setOldValue(prop.propertyIndex(), oldVal);
}
} else {
// @WhenModified set without invoking interception
Object oldVal = prop.getValue(entityBean);
Object value = generatedProperty.getUpdateValue(prop, entityBean, now());
prop.setValueChanged(entityBean, value);
intercept.setOldValue(prop.getPropertyIndex(), oldVal);
intercept.setOldValue(prop.propertyIndex(), oldVal);
}
}
}
private void onInsertGeneratedProperties() {
for (BeanProperty prop : beanDescriptor.propertiesGenInsert()) {
Object value = prop.getGeneratedProperty().getInsertValue(prop, entityBean, now());
Object value = prop.generatedProperty().getInsertValue(prop, entityBean, now());
prop.setValueChanged(entityBean, value);
}
}
@@ -424,12 +376,12 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
}
@Override
public Set<String> getLoadedProperties() {
public Set<String> loadedProperties() {
return intercept.getLoadedPropertyNames();
}
@Override
public Set<String> getUpdatedProperties() {
public Set<String> updatedProperties() {
return intercept.getDirtyPropertyNames();
}
@@ -437,7 +389,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
* Return the dirty properties on this request.
*/
@Override
public boolean[] getDirtyProperties() {
public boolean[] dirtyProperties() {
return dirtyProperties;
}
@@ -462,7 +414,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
}
@Override
public Map<String, ValuePair> getUpdatedValues() {
public Map<String, ValuePair> updatedValues() {
return intercept.getDirtyValues();
}
@@ -543,10 +495,10 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
case INSERT:
case UPDATE:
case DELETE_SOFT:
docStoreUpdates.queueIndex(beanDescriptor.getDocStoreQueueId(), idValue);
docStoreUpdates.queueIndex(beanDescriptor.docStoreQueueId(), idValue);
break;
case DELETE:
docStoreUpdates.queueDelete(beanDescriptor.getDocStoreQueueId(), idValue);
docStoreUpdates.queueDelete(beanDescriptor.docStoreQueueId(), idValue);
break;
default:
throw new IllegalStateException("Invalid type " + type);
@@ -582,8 +534,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
}
/**
* Return true if this bean has been already been persisted (inserted or updated) in this
* transaction.
* Return true if this bean has been already been persisted (inserted or updated) in this transaction.
*/
public boolean isRegisteredBean() {
return transaction.isRegisteredBean(bean);
@@ -600,7 +551,6 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
* The hash used to register the bean with the transaction.
* <p>
* Takes into account the class type and id value.
* </p>
*/
private Integer getBeanHash() {
if (beanHash == null) {
@@ -631,7 +581,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
/**
* Return the BeanDescriptor for the associated bean.
*/
public BeanDescriptor<T> getBeanDescriptor() {
public BeanDescriptor<T> descriptor() {
return beanDescriptor;
}
@@ -656,7 +606,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
/**
* Return the concurrency mode used for this persist.
*/
public ConcurrencyMode getConcurrencyMode() {
public ConcurrencyMode concurrencyMode() {
return concurrencyMode;
}
@@ -667,26 +617,26 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
* Used to determine common persist requests for queueing and statement batching.
* </p>
*/
public String getFullName() {
return beanDescriptor.getFullName();
public String fullName() {
return beanDescriptor.fullName();
}
/**
* Return the bean associated with this request.
*/
@Override
public T getBean() {
public T bean() {
return bean;
}
public EntityBean getEntityBean() {
public EntityBean entityBean() {
return entityBean;
}
/**
* Return the Id value for the bean.
*/
public Object getBeanId() {
public Object beanId() {
return beanDescriptor.getId(entityBean);
}
@@ -694,7 +644,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
* Create and return a new reference bean matching this beans Id value.
*/
public T createReference() {
return beanDescriptor.createRef(getBeanId(), null);
return beanDescriptor.createRef(beanId(), null);
}
/**
@@ -739,14 +689,14 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
/**
* Return the parent bean for cascading save with unidirectional relationship.
*/
public Object getParentBean() {
public Object parentBean() {
return parentBean;
}
/**
* Return the intercept if there is one.
*/
public EntityBeanIntercept getEntityBeanIntercept() {
public EntityBeanIntercept intercept() {
return intercept;
}
@@ -754,21 +704,21 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
* Return true if this property is loaded (full bean or included in partial bean).
*/
public boolean isLoadedProperty(BeanProperty prop) {
return intercept.isLoadedProperty(prop.getPropertyIndex());
return intercept.isLoadedProperty(prop.propertyIndex());
}
/**
* Return true if the property is dirty.
*/
public boolean isDirtyProperty(BeanProperty prop) {
return intercept.isDirtyProperty(prop.getPropertyIndex());
return intercept.isDirtyProperty(prop.propertyIndex());
}
/**
* Return the original / old value for the given property.
*/
public Object getOrigValue(BeanProperty prop) {
return intercept.getOrigValue(prop.getPropertyIndex());
return intercept.getOrigValue(prop.propertyIndex());
}
@Override
@@ -783,7 +733,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
case UPDATE:
if (beanPersistListener != null) {
// store the updated properties for sending later
updatedProperties = getUpdatedProperties();
updatedProperties = updatedProperties();
}
executeUpdate();
return -1;
@@ -802,7 +752,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
* Soft delete is executed as update so we want to set deleted=true property.
*/
private void prepareForSoftDelete() {
beanDescriptor.setSoftDeleteValue(entityBean);
beanDescriptor.softDeleteValue(entityBean);
}
@Override
@@ -854,7 +804,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
* Check for optimistic concurrency exception.
*/
@Override
public final void checkRowCount(int rowCount) {
public void checkRowCount(int rowCount) {
if (rowCount != 1 && rowCount != Statement.SUCCESS_NO_INFO) {
if (ConcurrencyMode.VERSION == concurrencyMode) {
throw new OptimisticLockException("Data has changed. updated row count " + rowCount, null, bean);
@@ -905,7 +855,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
}
private void changeLog() {
BeanChange changeLogBean = beanDescriptor.getChangeLogBean(this);
BeanChange changeLogBean = beanDescriptor.changeLogBean(this);
if (changeLogBean != null) {
transaction.addBeanChange(changeLogBean);
}
@@ -937,8 +887,8 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
}
addPostCommitListeners();
notifyCacheOnPostExecute();
if (isLogSummary()) {
logSummary();
if (logSummary()) {
logSummaryMessage();
}
}
@@ -985,9 +935,9 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
}
}
private void logSummary() {
private void logSummaryMessage() {
String draft = (beanDescriptor.isDraftable() && !publish) ? " draft[true]" : "";
String name = beanDescriptor.getName();
String name = beanDescriptor.name();
switch (type) {
case INSERT:
transaction.logSummary("Inserted [" + name + "] [" + idValue + "]" + draft);
@@ -1021,9 +971,9 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
*/
public boolean isAddToUpdate(BeanProperty prop) {
if (requestUpdateAllLoadedProps) {
return intercept.isLoadedProperty(prop.getPropertyIndex());
return intercept.isLoadedProperty(prop.propertyIndex());
} else {
return intercept.isDirtyProperty(prop.getPropertyIndex());
return intercept.isDirtyProperty(prop.propertyIndex());
}
}
@@ -1031,7 +981,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
* Register the derived relationships to get executed later (on JDBC batch flush or commit).
*/
public void deferredRelationship(EntityBean assocBean, ImportedId importedId, EntityBean bean) {
transaction.registerDeferred(new PersistDeferredRelationship(ebeanServer, beanDescriptor, assocBean, importedId, bean));
transaction.registerDeferred(new PersistDeferredRelationship(server, beanDescriptor, assocBean, importedId, bean));
}
private void postInsert() {
@@ -1074,7 +1024,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
/**
* Return the list of updated many properties for L2 cache update (can be null).
*/
public List<BeanPropertyAssocMany<?>> getUpdatedManyForL2Cache() {
public List<BeanPropertyAssocMany<?>> updatedManyForL2Cache() {
return updatedManys;
}
@@ -1151,9 +1101,9 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
}
case QUEUE: {
if (type == Type.DELETE) {
docStoreUpdates.queueDelete(beanDescriptor.getDocStoreQueueId(), idValue);
docStoreUpdates.queueDelete(beanDescriptor.docStoreQueueId(), idValue);
} else {
docStoreUpdates.queueIndex(beanDescriptor.getDocStoreQueueId(), idValue);
docStoreUpdates.queueIndex(beanDescriptor.docStoreQueueId(), idValue);
}
}
break;
@@ -1175,7 +1125,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
requestUpdateAllLoadedProps = txnUpdateAll;
} else {
// if using batch use the server default setting
requestUpdateAllLoadedProps = isBatchThisRequest() && ebeanServer.isUpdateAllPropertiesInBatch();
requestUpdateAllLoadedProps = isBatchThisRequest() && server.isUpdateAllPropertiesInBatch();
}
return requestUpdateAllLoadedProps;
}
@@ -1183,7 +1133,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
/**
* Return the flags set on this persist request.
*/
public int getFlags() {
public int flags() {
return flags;
}
@@ -1197,16 +1147,16 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
/**
* Return the key for an update persist request.
*/
public String getUpdatePlanHash() {
public String updatePlanHash() {
StringBuilder key;
if (determineUpdateAllLoadedProperties()) {
key = intercept.getLoadedPropertyKey();
} else {
key = intercept.getDirtyPropertyKey();
}
BeanProperty versionProperty = beanDescriptor.getVersionProperty();
BeanProperty versionProperty = beanDescriptor.versionProperty();
if (versionProperty != null) {
if (intercept.isLoadedProperty(versionProperty.getPropertyIndex())) {
if (intercept.isLoadedProperty(versionProperty.propertyIndex())) {
key.append('v');
}
}
@@ -1219,8 +1169,8 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
/**
* Return the table to update depending if the request is a 'publish' one or normal.
*/
public String getUpdateTable() {
return publish ? beanDescriptor.getBaseTable() : beanDescriptor.getDraftTable();
public String updateTable() {
return publish ? beanDescriptor.baseTable() : beanDescriptor.draftTable();
}
/**
@@ -1240,7 +1190,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
/**
* Return the version in long form (if set).
*/
public long getVersion() {
public long version() {
return version;
}
@@ -1313,7 +1263,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
*/
public long now() {
if (now == 0) {
now = ebeanServer.clockNow();
now = server.clockNow();
}
return now;
}
@@ -1330,7 +1280,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
*/
@Override
public void profile() {
profileBase(type.profileEventId, profileOffset, beanDescriptor.getName(), 1);
profileBase(type.profileEventId, profileOffset, beanDescriptor.name(), 1);
}
/**
@@ -1383,15 +1333,15 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
String key = beanDescriptor.cacheKey(idValue);
Map<String, Object> changes = new LinkedHashMap<>();
EntityBean bean = getEntityBean();
boolean[] dirtyProperties = getDirtyProperties();
EntityBean bean = entityBean();
boolean[] dirtyProperties = dirtyProperties();
if (dirtyProperties != null) {
for (int i = 0; i < dirtyProperties.length; i++) {
if (dirtyProperties[i]) {
BeanProperty property = beanDescriptor.propertyByIndex(i);
if (property.isCacheDataInclude()) {
Object val = property.getCacheDataValue(bean);
changes.put(property.getName(), val);
changes.put(property.name(), val);
if (property.isNaturalKey()) {
updateNaturalKey = true;
String valStr = (val == null) ? null : val.toString();
@@ -1405,7 +1355,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
// add element collection update
changes.putAll(collectionChanges);
}
changeSet.addBeanUpdate(beanDescriptor, key, changes, updateNaturalKey, getVersion());
changeSet.addBeanUpdate(beanDescriptor, key, changes, updateNaturalKey, version());
}
}
@@ -1419,7 +1369,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
}
}
public EntityBean getImportedOrphanForRemoval() {
public EntityBean importedOrphanForRemoval() {
return orphanBean;
}
@@ -1427,7 +1377,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
* Return the SQL used to fetch the last inserted id value.
*/
public String getSelectLastInsertedId() {
return beanDescriptor.getSelectLastInsertedId(publish);
return beanDescriptor.selectLastInsertedId(publish);
}
/**
@@ -19,20 +19,15 @@ import java.util.List;
public final class PersistRequestCallableSql extends PersistRequest {
private final SpiCallableSql callableSql;
private int rowCount;
private String bindLog;
private CallableStatement cstmt;
private BindParams bindParam;
/**
* Create.
*/
public PersistRequestCallableSql(SpiEbeanServer server, CallableSql cs, SpiTransaction t, PersistExecute persistExecute) {
super(server, t, persistExecute, cs.getLabel());
this.type = PersistRequest.Type.CALLABLESQL;
this.callableSql = (SpiCallableSql) cs;
@@ -56,7 +51,7 @@ public final class PersistRequestCallableSql extends PersistRequest {
/**
* Return the CallableSql.
*/
public SpiCallableSql getCallableSql() {
public SpiCallableSql callableSql() {
return callableSql;
}
@@ -97,13 +92,11 @@ public final class PersistRequestCallableSql extends PersistRequest {
// register table modifications with the transaction event
TransactionEventTable tableEvents = callableSql.getTransactionEventTable();
if (tableEvents != null && !tableEvents.isEmpty()) {
transaction.getEvent().add(tableEvents);
} else {
transaction.markNotQueryOnly();
}
}
/**
@@ -120,7 +113,6 @@ public final class PersistRequestCallableSql extends PersistRequest {
* Execute the statement in normal non batch mode.
*/
public int executeUpdate() throws SQLException {
// check to see if the execution has been overridden
// only works in non-batch mode
if (callableSql.executeOverride(cstmt)) {
@@ -129,20 +121,15 @@ public final class PersistRequestCallableSql extends PersistRequest {
// rowCount = callableSql.getRowCount();
// return rowCount;
}
rowCount = cstmt.executeUpdate();
// only read in non-batch mode
readOutParams();
return rowCount;
}
private void readOutParams() throws SQLException {
List<Param> list = bindParam.positionedParameters();
int pos = 0;
for (Param param : list) {
pos++;
if (param.isOutParam()) {
@@ -151,5 +138,4 @@ public final class PersistRequestCallableSql extends PersistRequest {
}
}
}
}
@@ -14,19 +14,11 @@ import io.ebeaninternal.server.persist.PersistExecute;
public final class PersistRequestOrmUpdate extends PersistRequest {
private final BeanDescriptor<?> beanDescriptor;
private final SpiUpdate<?> ormUpdate;
private int rowCount;
private String bindLog;
/**
* Create.
*/
public PersistRequestOrmUpdate(SpiEbeanServer server, BeanManager<?> mgr, SpiUpdate<?> ormUpdate,
SpiTransaction t, PersistExecute persistExecute) {
public PersistRequestOrmUpdate(SpiEbeanServer server, BeanManager<?> mgr, SpiUpdate<?> ormUpdate, SpiTransaction t, PersistExecute persistExecute) {
super(server, t, persistExecute, ormUpdate.getLabel());
this.beanDescriptor = mgr.getBeanDescriptor();
this.ormUpdate = ormUpdate;
@@ -34,10 +26,10 @@ public final class PersistRequestOrmUpdate extends PersistRequest {
@Override
public void profile(long offset, int flushCount) {
profileBase(EVT_ORMUPDATE, offset, beanDescriptor.getName(), flushCount);
profileBase(EVT_ORMUPDATE, offset, beanDescriptor.name(), flushCount);
}
public BeanDescriptor<?> getBeanDescriptor() {
public BeanDescriptor<?> descriptor() {
return beanDescriptor;
}
@@ -51,11 +43,10 @@ public final class PersistRequestOrmUpdate extends PersistRequest {
return executeStatement();
}
/**
* Return the UpdateSql.
*/
public SpiUpdate<?> getOrmUpdate() {
public SpiUpdate<?> ormUpdate() {
return ormUpdate;
}
@@ -91,14 +82,11 @@ public final class PersistRequestOrmUpdate extends PersistRequest {
}
OrmUpdateType ormUpdateType = ormUpdate.getOrmUpdateType();
String tableName = ormUpdate.getBaseTable();
if (transaction.isLogSummary()) {
String m = ormUpdateType + " table[" + tableName + "] rows[" + rowCount + "] bind[" + bindLog + "]";
transaction.logSummary(m);
}
if (ormUpdate.isNotifyCache()) {
// add the modification info to the TransactionEvent
// this is used to invalidate cached objects etc
switch (ormUpdateType) {
@@ -116,5 +104,4 @@ public final class PersistRequestOrmUpdate extends PersistRequest {
}
}
}
}
@@ -18,25 +18,17 @@ public final class PersistRequestUpdateSql extends PersistRequest {
}
private final SpiSqlUpdate updateSql;
private int rowCount;
private String bindLog;
private SqlType sqlType;
private String tableName;
private boolean addBatch;
private final boolean forceNoBatch;
private boolean batchThisRequest;
private boolean flushQueue;
public PersistRequestUpdateSql(SpiEbeanServer server, SpiSqlUpdate sqlUpdate,
SpiTransaction t, PersistExecute persistExecute, boolean forceNoBatch) {
super(server, t, persistExecute, sqlUpdate.getLabel());
this.type = Type.UPDATESQL;
this.updateSql = sqlUpdate;
@@ -105,7 +97,7 @@ public final class PersistRequestUpdateSql extends PersistRequest {
/**
* Return the UpdateSql.
*/
public SpiSqlUpdate getUpdateSql() {
public SpiSqlUpdate updateSql() {
return updateSql;
}
@@ -145,6 +137,7 @@ public final class PersistRequestUpdateSql extends PersistRequest {
this.bindLog = bindLog;
}
@Override
public void startBind(boolean batchThisRequest) {
this.batchThisRequest = batchThisRequest;
super.startBind(batchThisRequest);
@@ -170,7 +163,6 @@ public final class PersistRequestUpdateSql extends PersistRequest {
if (transaction.isLogSql() && !batchThisRequest) {
transaction.logSql(Str.add(TrimLogSql.trim(updateSql.getGeneratedSql()), "; -- bind(", bindLog, ") rows(", String.valueOf(rowCount), ")"));
}
if (updateSql.isAutoTableMod()) {
// add the modification info to the TransactionEvent
// this is used to invalidate cached objects etc
@@ -22,12 +22,12 @@ public interface SpiOrmQueryRequest<T> extends BeanQueryRequest<T>, DocQueryRequ
* Return the query.
*/
@Override
SpiQuery<T> getQuery();
SpiQuery<T> query();
/**
* Return the associated BeanDescriptor.
*/
BeanDescriptor<T> getBeanDescriptor();
BeanDescriptor<T> descriptor();
/**
* Prepare the query for execution.
@@ -145,12 +145,12 @@ public interface SpiOrmQueryRequest<T> extends BeanQueryRequest<T>, DocQueryRequ
/**
* Return the bean cache hits (when all hits / no misses).
*/
List<T> getBeanCacheHits();
List<T> beanCacheHits();
/**
* Return the bean cache hits for findMap (when all hits / no misses).
*/
<K> Map<K,T> getBeanCacheHitsAsMap();
<K> Map<K,T> beanCacheHitsAsMap();
/**
* Reset Bean cache mode AUTO - require explicit setting for bean cache use with findList().
@@ -160,7 +160,7 @@ public interface SpiOrmQueryRequest<T> extends BeanQueryRequest<T>, DocQueryRequ
/**
* Return the Database platform like clause.
*/
String getDBLikeClause(boolean rawLikeExpression);
String dbLikeClause(boolean rawLikeExpression);
/**
* Escapes a string to use it as exact match in Like clause.
@@ -13,7 +13,7 @@ final class AssocOneHelpRefExported extends AssocOneHelp {
AssocOneHelpRefExported(BeanPropertyAssocOne<?> property) {
super(property);
this.softDelete = property.targetDescriptor.isSoftDelete();
this.softDeletePredicate = (softDelete) ? property.targetDescriptor.getSoftDeletePredicate("") : null;
this.softDeletePredicate = (softDelete) ? property.targetDescriptor.softDeletePredicate("") : null;
}
/**
@@ -22,7 +22,7 @@ final class AssocOneHelpRefExported extends AssocOneHelp {
@Override
void appendSelect(DbSqlContext ctx, boolean subQuery) {
// set appropriate tableAlias for the exported id columns
String relativePrefix = ctx.getRelativePrefix(property.getName());
String relativePrefix = ctx.getRelativePrefix(property.name());
ctx.pushTableAlias(relativePrefix);
property.targetIdBinder.appendSelect(ctx, subQuery);
ctx.popTableAlias();
@@ -30,7 +30,7 @@ final class AssocOneHelpRefExported extends AssocOneHelp {
@Override
void appendFrom(DbSqlContext ctx, SqlJoinType joinType) {
String relativePrefix = ctx.getRelativePrefix(property.getName());
String relativePrefix = ctx.getRelativePrefix(property.name());
if (softDelete && !ctx.isIncludeSoftDelete()) {
property.tableJoin.addJoin(joinType, relativePrefix, ctx, softDeletePredicate);
} else {
@@ -70,7 +70,7 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
void appendSelect(DbSqlContext ctx, boolean subQuery) {
if (!subQuery) {
// add discriminator column
String relativePrefix = ctx.getRelativePrefix(property.getName());
String relativePrefix = ctx.getRelativePrefix(property.name());
String tableAlias = ctx.getTableAlias(relativePrefix);
ctx.appendColumn(tableAlias, property.targetInheritInfo.getDiscriminatorColumn());
}
@@ -17,8 +17,8 @@ abstract class BaseCollectionHelp<T> implements BeanCollectionHelp<T> {
BaseCollectionHelp(BeanPropertyAssocMany<T> many) {
this.many = many;
this.targetDescriptor = many.getTargetDescriptor();
this.propertyName = many.getName();
this.targetDescriptor = many.targetDescriptor();
this.propertyName = many.name();
}
BaseCollectionHelp() {
@@ -54,10 +54,10 @@ final class BeanChangeJson implements BeanDiffVisitor {
public void visitPush(int position) {
stack.push(descriptor);
BeanPropertyAssocOne<?> embedded = (BeanPropertyAssocOne<?>)descriptor.propertiesIndex[position];
descriptor = embedded.getTargetDescriptor();
newJson.writeStartObject(embedded.getName());
descriptor = embedded.targetDescriptor();
newJson.writeStartObject(embedded.name());
if (oldJson != null) {
oldJson.writeStartObject(embedded.getName());
oldJson.writeStartObject(embedded.name());
}
}
@@ -22,7 +22,7 @@ public final class BeanCollectionHelpFactory {
*/
public static <T> BeanCollectionHelp<T> create(BeanPropertyAssocMany<T> many) {
boolean elementCollection = many.isElementCollection();
ManyType manyType = many.getManyType();
ManyType manyType = many.manyType();
switch (manyType) {
case LIST:
return elementCollection ? new BeanListHelpElement<>(many) : new BeanListHelp<>(many);
@@ -44,8 +44,8 @@ public final class BeanCollectionHelpFactory {
return SET_HELP;
} else if (manyType == SpiQuery.Type.MAP) {
BeanDescriptor<T> target = request.getBeanDescriptor();
ElPropertyValue elProperty = target.getElGetValue(request.getQuery().getMapKey());
BeanDescriptor<T> target = request.descriptor();
ElPropertyValue elProperty = target.elGetValue(request.query().getMapKey());
return new BeanMapQueryHelp<>(elProperty);
} else {
File diff suppressed because it is too large Load Diff
@@ -124,7 +124,7 @@ final class BeanDescriptorCacheHelp<T> {
if (cacheNotifyOnAll || cacheNotifyOnDelete) {
String notifyMode = cacheNotifyOnAll ? "All" : "Delete";
logger.debug("l2 caching on {} - beanCaching:{} queryCaching:{} notifyMode:{} ",
desc.getFullName(), isBeanCaching(), isQueryCaching(), notifyMode);
desc.fullName(), isBeanCaching(), isQueryCaching(), notifyMode);
}
}
}
@@ -282,7 +282,7 @@ final class BeanDescriptorCacheHelp<T> {
// held as part of the bean cache so skip
return false;
}
CachedManyIds entry = manyPropGet(parentId, many.getName());
CachedManyIds entry = manyPropGet(parentId, many.name());
if (entry == null) {
// not in cache so return unsuccessful
return false;
@@ -290,7 +290,7 @@ final class BeanDescriptorCacheHelp<T> {
EntityBean ownerBean = bc.getOwnerBean();
EntityBeanIntercept ebi = ownerBean._ebean_getIntercept();
PersistenceContext persistenceContext = ebi.getPersistenceContext();
BeanDescriptor<?> targetDescriptor = many.getTargetDescriptor();
BeanDescriptor<?> targetDescriptor = many.targetDescriptor();
List<Object> idList = entry.getIdList();
bc.checkEmptyLazyLoad();
@@ -316,7 +316,7 @@ final class BeanDescriptorCacheHelp<T> {
// add as JSON to bean cache
String asJson = many.jsonWriteCollection(details);
Map<String, Object> changes = new HashMap<>();
changes.put(many.getName(), asJson);
changes.put(many.name(), asJson);
CachedBeanData newData = data.update(changes, data.getVersion());
if (beanLog.isDebugEnabled()) {
@@ -330,7 +330,7 @@ final class BeanDescriptorCacheHelp<T> {
} else {
CachedManyIds entry = createManyIds(many, details);
if (entry != null) {
cachePutManyIds(parentId, many.getName(), entry);
cachePutManyIds(parentId, many.name(), entry);
}
}
}
@@ -349,10 +349,10 @@ final class BeanDescriptorCacheHelp<T> {
return null;
}
BeanDescriptor<?> targetDescriptor = many.getTargetDescriptor();
BeanDescriptor<?> targetDescriptor = many.targetDescriptor();
List<Object> idList = new ArrayList<>(actualDetails.size());
for (Object bean : actualDetails) {
idList.add(targetDescriptor.getId((EntityBean) bean));
idList.add(targetDescriptor.id(bean));
}
return new CachedManyIds(idList);
}
@@ -375,7 +375,7 @@ final class BeanDescriptorCacheHelp<T> {
for (Map.Entry<Object, Object> entry : beanDataMap.entrySet()) {
CachedBeanData cachedBeanData = (CachedBeanData) entry.getValue();
T bean = convertToBean(entry.getKey(), false, context, cachedBeanData);
result.add(bean, desc.getBeanId(bean));
result.add(bean, desc.id(bean));
}
return result;
}
@@ -773,7 +773,7 @@ final class BeanDescriptorCacheHelp<T> {
void cacheUpdateQuery(boolean update, SpiTransaction transaction) {
if (invalidateQueryCache || cacheNotifyOnAll || (!update && cacheNotifyOnDelete)) {
transaction.getEvent().add(desc.getBaseTable(), false, update, !update);
transaction.getEvent().add(desc.baseTable(), false, update, !update);
}
}
@@ -803,7 +803,7 @@ final class BeanDescriptorCacheHelp<T> {
if (beanCache != null) {
changeSet.addBeanRemove(desc, id);
}
cacheDeleteImported(true, deleteRequest.getEntityBean(), changeSet);
cacheDeleteImported(true, deleteRequest.entityBean(), changeSet);
}
}
@@ -815,8 +815,8 @@ final class BeanDescriptorCacheHelp<T> {
changeSet.addInvalidate(desc);
} else {
queryCacheClear(changeSet);
cacheDeleteImported(false, insertRequest.getEntityBean(), changeSet);
changeSet.addBeanInsert(desc.getBaseTable());
cacheDeleteImported(false, insertRequest.entityBean(), changeSet);
changeSet.addBeanInsert(desc.baseTable());
}
}
@@ -839,13 +839,13 @@ final class BeanDescriptorCacheHelp<T> {
// query caching only
return;
}
List<BeanPropertyAssocMany<?>> manyCollections = updateRequest.getUpdatedManyForL2Cache();
List<BeanPropertyAssocMany<?>> manyCollections = updateRequest.updatedManyForL2Cache();
if (manyCollections != null) {
for (BeanPropertyAssocMany<?> many : manyCollections) {
Object details = many.getValue(updateRequest.getEntityBean());
Object details = many.getValue(updateRequest.entityBean());
CachedManyIds entry = createManyIds(many, details);
if (entry != null) {
changeSet.addManyPut(desc, many.getName(), id, entry);
changeSet.addManyPut(desc, many.name(), id, entry);
}
}
}
@@ -19,7 +19,7 @@ final class BeanDescriptorDraftHelp<T> {
BeanDescriptorDraftHelp(BeanDescriptor<T> desc) {
this.desc = desc;
this.draftDirty = desc.getDraftDirty();
this.draftDirty = desc.draftDirty();
this.resetProperties = resetProperties();
}
@@ -66,7 +66,7 @@ final class BeanDescriptorDraftHelp<T> {
}
EntityBean draft = (EntityBean) draftBean;
EntityBean live = (EntityBean) liveBean;
BeanProperty idProperty = desc.getIdProperty();
BeanProperty idProperty = desc.idProperty();
if (idProperty != null) {
idProperty.publish(draft, live);
}
@@ -74,7 +74,7 @@ final class BeanDescriptorDraftHelp<T> {
prop.publish(draft, live);
}
for (BeanPropertyAssocMany<?> many : desc.propertiesMany()) {
if (many.getTargetDescriptor().isDraftable()) {
if (many.targetDescriptor().isDraftable()) {
many.publishMany(draft, live);
}
}
@@ -86,13 +86,13 @@ final class BeanDescriptorDraftHelp<T> {
*/
void draftQueryOptimise(Query<T> query) {
for (BeanPropertyAssocOne<?> anOne : desc.propertiesOne()) {
if (anOne.getTargetDescriptor().isDraftableElement()) {
query.fetch(anOne.getName());
if (anOne.targetDescriptor().isDraftableElement()) {
query.fetch(anOne.name());
}
}
for (BeanPropertyAssocMany<?> aMany : desc.propertiesMany()) {
if (aMany.getTargetDescriptor().isDraftableElement()) {
query.fetch(aMany.getName());
if (aMany.targetDescriptor().isDraftableElement()) {
query.fetch(aMany.name());
}
}
}
@@ -35,7 +35,7 @@ abstract class BeanDescriptorElement<T> extends BeanDescriptor<T> {
}
@Override
public String getSimpleName() {
public String simpleName() {
return simpleName;
}
@@ -52,7 +52,7 @@ abstract class BeanDescriptorElement<T> extends BeanDescriptor<T> {
if (props.length != 1) {
throw new IllegalStateException("Expecting 1 property for element scalar but got " + Arrays.toString(props));
}
return props[0].getScalarType();
return props[0].scalarType();
}
/**
@@ -42,7 +42,7 @@ class BeanDescriptorElementEmbedded<T> extends BeanDescriptorElement<T> {
@Override
public void initialiseOther(BeanDescriptorInitContext initContext) {
super.initialiseOther(initContext);
this.targetDescriptor = embeddedProperty.getTargetDescriptor();
this.targetDescriptor = embeddedProperty.targetDescriptor();
}
@Override
@@ -26,8 +26,8 @@ class BeanDescriptorElementScalarMap<T> extends BeanDescriptorElement<T> {
if (props.length != 2) {
throw new IllegalStateException("Expecting 2 properties for key and value but got " + Arrays.toString(props));
}
this.scalarTypeKey = props[0].getScalarType();
this.scalarTypeVal = props[1].getScalarType();
this.scalarTypeKey = props[0].scalarType();
this.scalarTypeVal = props[1].scalarType();
this.stringKey = String.class.equals(scalarTypeKey.getType());
}
@@ -57,7 +57,7 @@ final class BeanDescriptorJsonHelp<T> {
// render the dirty properties
BeanProperty[] props = desc.propertiesNonTransient();
for (BeanProperty prop : props) {
if (dirtyProps[prop.getPropertyIndex()]) {
if (dirtyProps[prop.propertyIndex()]) {
prop.jsonWrite(writeJson, bean);
}
}
@@ -123,7 +123,7 @@ final class BeanDescriptorJsonHelp<T> {
JsonToken event = parser.nextToken();
if (JsonToken.FIELD_NAME == event) {
String key = parser.getCurrentName();
BeanProperty p = desc.getBeanProperty(key);
BeanProperty p = desc.beanProperty(key);
if (p != null) {
p.jsonRead(readJson, bean);
} else {
@@ -145,7 +145,7 @@ final class BeanDescriptorJsonHelp<T> {
desc.setUnmappedJson(bean, unmappedProperties);
}
Object contextBean = null;
Object id = desc.beanId(bean);
Object id = desc.id(bean);
if (!isNullOrZero(id)) {
// check if the bean has already been loaded
contextBean = readJson.persistenceContextPutIfAbsent(id, bean, desc);
@@ -136,8 +136,8 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
this.multiValueBind = config.getMultiValueBind();
this.idBinderFactory = new IdBinderFactory(databasePlatform.isIdInExpandedForm(), multiValueBind);
this.queryPlanTTLSeconds = this.config.getQueryPlanTTLSeconds();
this.asOfViewSuffix = getAsOfViewSuffix(databasePlatform, this.config);
String versionsBetweenSuffix = getVersionsBetweenSuffix(databasePlatform, this.config);
this.asOfViewSuffix = asOfViewSuffix(databasePlatform, this.config);
String versionsBetweenSuffix = versionsBetweenSuffix(databasePlatform, this.config);
this.readAnnotations = new ReadAnnotations(config.getGeneratedPropertyFactory(), asOfViewSuffix, versionsBetweenSuffix, this.config);
this.bootupClasses = config.getBootupClasses();
this.createProperties = config.getDeployCreateProperties();
@@ -183,19 +183,19 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
}
@Override
public ScalarType<?> getScalarType(String cast) {
public ScalarType<?> scalarType(String cast) {
return typeManager.getScalarType(cast);
}
@Override
public ScalarType<?> getScalarType(int jdbcType) {
public ScalarType<?> scalarType(int jdbcType) {
return typeManager.getScalarType(jdbcType);
}
/**
* Return the AsOfViewSuffix based on the DbHistorySupport.
*/
private String getAsOfViewSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) {
private String asOfViewSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) {
DbHistorySupport historySupport = databasePlatform.getHistorySupport();
// with historySupport returns a simple view suffix or the sql2011 as of timestamp suffix
return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getAsOfViewSuffix(serverConfig.getAsOfViewSuffix());
@@ -204,7 +204,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
/**
* Return the versions between timestamp suffix based on the DbHistorySupport.
*/
private String getVersionsBetweenSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) {
private String versionsBetweenSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) {
DbHistorySupport historySupport = databasePlatform.getHistorySupport();
// with historySupport returns a simple view suffix or the sql2011 versions between timestamp suffix
return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getVersionsBetweenSuffix(serverConfig.getAsOfViewSuffix());
@@ -216,7 +216,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
}
@Override
public DatabaseConfig getConfig() {
public DatabaseConfig config() {
return config;
}
@@ -225,38 +225,38 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
return docStoreFactory.createAdapter(descriptor, deploy);
}
public BeanDescriptor<?> getBeanDescriptorByQueueId(String queueId) {
public BeanDescriptor<?> descriptorByQueueId(String queueId) {
return descQueueMap.get(queueId);
}
@Override
public SpiBeanType getBeanType(Class<?> entityType) {
return getBeanDescriptor(entityType);
public SpiBeanType beanType(Class<?> entityType) {
return descriptor(entityType);
}
@Override
@SuppressWarnings("unchecked")
public <T> BeanDescriptor<T> getBeanDescriptor(Class<T> entityType) {
public <T> BeanDescriptor<T> descriptor(Class<T> entityType) {
return (BeanDescriptor<T>) descMap.get(entityType.getName());
}
@SuppressWarnings("unchecked")
public <T> BeanDescriptor<T> getBeanDescriptorByClassName(String entityClassName) {
public <T> BeanDescriptor<T> descriptorByClassName(String entityClassName) {
return (BeanDescriptor<T>) descMap.get(entityClassName);
}
@Override
public String getServerName() {
public String name() {
return serverName;
}
@Override
public SpiCacheManager getCacheManager() {
public SpiCacheManager cacheManager() {
return cacheManager;
}
@Override
public NamingConvention getNamingConvention() {
public NamingConvention namingConvention() {
return namingConvention;
}
@@ -277,7 +277,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
/**
* Return the map of base tables to draft tables.
*/
public Map<String, String> getDraftTableMap() {
public Map<String, String> draftTableMap() {
return draftTableMap;
}
@@ -369,7 +369,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
* Return the Encrypt key given the table and column name.
*/
@Override
public EncryptKey getEncryptKey(String tableName, String columnName) {
public EncryptKey encryptKey(String tableName, String columnName) {
return encryptKeyManager.getEncryptKey(tableName, columnName);
}
@@ -377,7 +377,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
* For SQL based modifications we need to invalidate appropriate parts of the cache.
*/
public void cacheNotify(TransactionEventTable.TableIUD tableIUD, CacheChangeSet changeSet) {
String tableName = tableIUD.getTableName().toLowerCase();
String tableName = tableIUD.tableName().toLowerCase();
List<BeanDescriptor<?>> normalBeanTypes = tableToDescMap.get(tableName);
if (normalBeanTypes != null) {
// 'normal' entity beans based on a "base table"
@@ -397,14 +397,14 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
/**
* Return the BeanDescriptors mapped to the table.
*/
public List<BeanDescriptor<?>> getBeanDescriptors(String tableName) {
public List<BeanDescriptor<?>> descriptors(String tableName) {
return tableToDescMap.get(tableName.toLowerCase());
}
/**
* Return the BeanDescriptors mapped to the table.
*/
public List<? extends BeanType<?>> getBeanTypes(String tableName) {
public List<? extends BeanType<?>> beanTypes(String tableName) {
return tableToDescMap.get(tableName.toLowerCase());
}
@@ -433,16 +433,16 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
*/
private void readTableToDescriptor() {
for (BeanDescriptor<?> desc : descMap.values()) {
String baseTable = desc.getBaseTable();
String baseTable = desc.baseTable();
if (baseTable != null) {
baseTable = baseTable.toLowerCase();
List<BeanDescriptor<?>> list = tableToDescMap.computeIfAbsent(baseTable, k -> new ArrayList<>(1));
list.add(desc);
}
if (desc.getEntityType() == EntityType.VIEW && desc.isQueryCaching()) {
if (desc.entityType() == EntityType.VIEW && desc.isQueryCaching()) {
// build map of tables to view entities dependent on those tables
// for the purpose of invalidating appropriate query caches
String[] dependentTables = desc.getDependentTables();
String[] dependentTables = desc.dependentTables();
if (dependentTables != null && dependentTables.length > 0) {
for (String depTable : dependentTables) {
depTable = depTable.toLowerCase();
@@ -508,23 +508,23 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
for (BeanDescriptor<?> d : descMap.values()) {
d.initLast();
if (!d.isEmbedded()) {
beanManagerMap.put(d.getFullName(), beanManagerFactory.create(d));
beanManagerMap.put(d.fullName(), beanManagerFactory.create(d));
checkForValidEmbeddedId(d);
}
}
}
private void checkForValidEmbeddedId(BeanDescriptor<?> d) {
IdBinder idBinder = d.getIdBinder();
IdBinder idBinder = d.idBinder();
if (idBinder instanceof IdBinderEmbedded) {
IdBinderEmbedded embId = (IdBinderEmbedded) idBinder;
BeanDescriptor<?> idBeanDescriptor = embId.getIdBeanDescriptor();
Class<?> idType = idBeanDescriptor.getBeanType();
Class<?> idType = idBeanDescriptor.type();
try {
idType.getDeclaredMethod("hashCode");
idType.getDeclaredMethod("equals", Object.class);
} catch (NoSuchMethodException e) {
checkMissingHashCodeOrEquals(e, idType, d.getBeanType());
checkMissingHashCodeOrEquals(e, idType, d.type());
}
}
}
@@ -546,11 +546,11 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
/**
* Return an immutable list of all the BeanDescriptors.
*/
public List<BeanDescriptor<?>> getBeanDescriptorList() {
public List<BeanDescriptor<?>> descriptorList() {
return immutableDescriptorList;
}
public BeanTable getBeanTable(Class<?> type) {
public BeanTable beanTable(Class<?> type) {
return beanTableMap.get(type);
}
@@ -562,11 +562,11 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
}
@SuppressWarnings("unchecked")
public <T> BeanManager<T> getBeanManager(Class<T> entityType) {
return (BeanManager<T>) getBeanManager(entityType.getName());
public <T> BeanManager<T> beanManager(Class<T> entityType) {
return (BeanManager<T>) beanManager(entityType.getName());
}
private BeanManager<?> getBeanManager(String beanClassName) {
private BeanManager<?> beanManager(String beanClassName) {
return beanManagerMap.get(beanClassName);
}
@@ -591,19 +591,19 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
* Return the bean deploy info for the given class.
*/
@SuppressWarnings("unchecked")
public <T> DeployBeanInfo<T> getDeploy(Class<T> cls) {
public <T> DeployBeanInfo<T> deploy(Class<T> cls) {
return (DeployBeanInfo<T>) deployInfoMap.get(cls);
}
private void registerBeanDescriptor(DeployBeanInfo<?> info) {
private void registerDescriptor(DeployBeanInfo<?> info) {
BeanDescriptor<?> desc = new BeanDescriptor<>(this, info.getDescriptor());
descMap.put(desc.getBeanType().getName(), desc);
descMap.put(desc.type().getName(), desc);
if (desc.isDocStoreMapped()) {
descQueueMap.put(desc.getDocStoreQueueId(), desc);
descQueueMap.put(desc.docStoreQueueId(), desc);
}
for (BeanPropertyAssocMany<?> many : desc.propertiesMany()) {
if (many.isElementCollection()) {
elementDescriptors.add(many.getElementDescriptor());
elementDescriptors.add(many.elementDescriptor());
}
}
}
@@ -640,7 +640,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
private void registerEmbeddedBean(DeployBeanInfo<?> info) {
readDeployAssociations(info);
registerBeanDescriptor(info);
registerDescriptor(info);
}
/**
@@ -711,7 +711,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
}
for (DeployBeanInfo<?> info : deployInfoMap.values()) {
if (!info.isEmbedded()) {
registerBeanDescriptor(info);
registerDescriptor(info);
}
}
}
@@ -785,7 +785,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
}
}
private DeployBeanDescriptor<?> getTargetDescriptor(DeployBeanPropertyAssoc<?> prop) {
private DeployBeanDescriptor<?> targetDescriptor(DeployBeanPropertyAssoc<?> prop) {
Class<?> targetType = prop.getTargetType();
DeployBeanInfo<?> info = deployInfoMap.get(targetType);
if (info == null) {
@@ -805,7 +805,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
Set<String> matchSet = new HashSet<>();
// get the bean descriptor that holds the mappedBy property
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(prop);
DeployBeanDescriptor<?> targetDesc = targetDescriptor(prop);
List<DeployBeanPropertyAssocOne<?>> ones = targetDesc.propertiesAssocOne();
for (DeployBeanPropertyAssocOne<?> possibleMappedBy : ones) {
Class<?> possibleMappedByType = possibleMappedBy.getTargetType();
@@ -866,7 +866,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
}
private void makeOrderColumn(DeployBeanPropertyAssocMany<?> oneToMany) {
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(oneToMany);
DeployBeanDescriptor<?> targetDesc = targetDescriptor(oneToMany);
DeployOrderColumn orderColumn = oneToMany.getOrderColumn();
final ScalarType<?> scalarType = typeManager.getScalarType(Integer.class);
DeployBeanProperty orderProperty = new DeployBeanProperty(targetDesc, Integer.class, scalarType, null);
@@ -898,7 +898,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
* into the order_id column on the order_lines table).
*/
private void makeUnidirectional(DeployBeanPropertyAssocMany<?> oneToMany) {
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(oneToMany);
DeployBeanDescriptor<?> targetDesc = targetDescriptor(oneToMany);
Class<?> owningType = oneToMany.getOwningType();
if (!oneToMany.getCascadeInfo().isSave()) {
// The property MUST have persist cascading so that inserts work.
@@ -915,7 +915,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
oneToMany.setUnidirectional();
// specify table and table alias...
BeanTable beanTable = getBeanTable(owningType);
BeanTable beanTable = beanTable(owningType);
// define the TableJoin
DeployTableJoin oneToManyJoin = oneToMany.getTableJoin();
@@ -951,7 +951,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
// its associated join information if it is available
String mappedBy = prop.getMappedBy();
// get the mappedBy property
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(prop);
DeployBeanDescriptor<?> targetDesc = targetDescriptor(prop);
DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy);
if (mappedProp == null) {
String m = "Error on " + prop.getFullBeanName();
@@ -1008,7 +1008,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
// skip mapping check
return;
}
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(prop);
DeployBeanDescriptor<?> targetDesc = targetDescriptor(prop);
if (targetDesc.isDraftableElement()) {
// automatically turning on orphan removal and CascadeType.ALL
@@ -1087,14 +1087,14 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
// get the bean descriptor that holds the mappedBy property
String mappedBy = prop.getMappedBy();
if (mappedBy == null) {
if (getTargetDescriptor(prop).isDraftable()) {
if (targetDescriptor(prop).isDraftable()) {
prop.setIntersectionDraftTable();
}
return;
}
// get the mappedBy property
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(prop);
DeployBeanDescriptor<?> targetDesc = targetDescriptor(prop);
DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy);
if (mappedProp == null) {
@@ -1433,14 +1433,14 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
* Return the changeLogPrepare (for setting user context into the ChangeSet
* in the foreground thread).
*/
public ChangeLogPrepare getChangeLogPrepare() {
public ChangeLogPrepare changeLogPrepare() {
return changeLogPrepare;
}
/**
* Return the changeLogListener (that actually does the logging).
*/
public ChangeLogListener getChangeLogListener() {
public ChangeLogListener changeLogListener() {
return changeLogListener;
}
@@ -1517,7 +1517,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
@Override
public int compare(BeanDescriptor<?> o1, BeanDescriptor<?> o2) {
return o1.getName().compareTo(o2.getName());
return o1.name().compareTo(o2.name());
}
}
}
@@ -20,22 +20,22 @@ public interface BeanDescriptorMap {
/**
* Return the name of the server/database.
*/
String getServerName();
String name();
/**
* Return the DatabaseConfig.
*/
DatabaseConfig getConfig();
DatabaseConfig config();
/**
* Return the Cache Manager.
*/
SpiCacheManager getCacheManager();
SpiCacheManager cacheManager();
/**
* Return the naming convention.
*/
NamingConvention getNamingConvention();
NamingConvention namingConvention();
/**
* Return true if multiple values can be bound as Array or Table Value and hence share the same query plan.
@@ -45,12 +45,12 @@ public interface BeanDescriptorMap {
/**
* Return the BeanDescriptor for a given class.
*/
<T> BeanDescriptor<T> getBeanDescriptor(Class<T> entityType);
<T> BeanDescriptor<T> descriptor(Class<T> entityType);
/**
* Return the Encrypt key given the table and column name.
*/
EncryptKey getEncryptKey(String tableName, String columnName);
EncryptKey encryptKey(String tableName, String columnName);
/**
* Create a IdBinder for this bean property.
@@ -65,18 +65,18 @@ public interface BeanDescriptorMap {
/**
* Return the scalarType for the given JDBC type.
*/
ScalarType<?> getScalarType(int jdbcType);
ScalarType<?> scalarType(int jdbcType);
/**
* Return the scalarType for the given logical type.
*/
ScalarType<?> getScalarType(String cast);
ScalarType<?> scalarType(String cast);
/**
* Return true if Jackson core is present on the classpath.
*/
boolean isJacksonCorePresent();
/**
* Returns true, if the given table (or view) is managed by ebean
* (= an entity exists)

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