mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
Merge remote-tracking branch 'ebean/master' into pr/enh/formula_in_where_and_order_by
# Conflicts: # ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinOnFormula.java
This commit is contained in:
commit
beec6b4b13
2057 files changed
+14018
-14855
No files matched your search
+13
-6
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ebean-parent</artifactId>
|
<artifactId>ebean-parent</artifactId>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<name>ebean api</name>
|
<name>ebean api</name>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.avaje</groupId>
|
<groupId>io.avaje</groupId>
|
||||||
<artifactId>avaje-config</artifactId>
|
<artifactId>avaje-config</artifactId>
|
||||||
<version>1.3</version>
|
<version>1.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -37,26 +37,26 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.avaje</groupId>
|
<groupId>io.avaje</groupId>
|
||||||
<artifactId>avaje-jsr305</artifactId>
|
<artifactId>avaje-jsr305</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>persistence-api</artifactId>
|
<artifactId>persistence-api</artifactId>
|
||||||
<version>2.2.4</version>
|
<version>2.2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-annotation</artifactId>
|
<artifactId>ebean-annotation</artifactId>
|
||||||
<version>7.2</version>
|
<version>7.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-types</artifactId>
|
<artifactId>ebean-types</artifactId>
|
||||||
<version>2.1</version>
|
<version>2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -104,6 +104,13 @@
|
|||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.avaje</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -79,11 +79,11 @@ public abstract class BeanFinder<I,T> {
|
|||||||
/**
|
/**
|
||||||
* Creates an entity reference for this ID.
|
* Creates an entity reference for this ID.
|
||||||
* <p>
|
* <p>
|
||||||
* Equivalent to {@link Database#getReference(Class, Object)}
|
* Equivalent to {@link Database#reference(Class, Object)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public T ref(I id) {
|
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
|
* // set loaded state on the email property to false so that
|
||||||
* // the email property is not included in a stateless update
|
* // the email property is not included in a stateless update
|
||||||
* DB.getBeanState(user).setPropertyLoaded("email", false);
|
* DB.beanState(user).setPropertyLoaded("email", false);
|
||||||
*
|
*
|
||||||
* user.update();
|
* user.update();
|
||||||
*
|
*
|
||||||
@@ -72,25 +72,47 @@ public interface BeanState {
|
|||||||
* bean.
|
* bean.
|
||||||
* <p>
|
* <p>
|
||||||
* Accessing another property will cause lazy loading to occur.
|
* 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.
|
* 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.
|
* 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.
|
* Return true if the bean is readOnly.
|
||||||
* <p>
|
* <p>
|
||||||
* If a setter is called on a readOnly bean it will throw an exception.
|
* If a setter is called on a readOnly bean it will throw an exception.
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
boolean isReadOnly();
|
boolean isReadOnly();
|
||||||
|
|
||||||
@@ -114,13 +136,29 @@ public interface BeanState {
|
|||||||
void resetForInsert();
|
void resetForInsert();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a map with load erros.
|
* Returns a map with load errors.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@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.
|
* Return the sort order value for an order column.
|
||||||
*/
|
*/
|
||||||
int getSortOrder();
|
int sortOrder();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to sortOrder().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default int getSortOrder() {
|
||||||
|
return sortOrder();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -126,8 +126,16 @@ public final class DB {
|
|||||||
* an expression that uses OR like Expression e = Expr.or(..., ...);
|
* an expression that uses OR like Expression e = Expr.or(..., ...);
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
|
public static ExpressionFactory expressionFactory() {
|
||||||
|
return getDefault().expressionFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to expressionFactory().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static ExpressionFactory getExpressionFactory() {
|
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 beanType the type of entity bean
|
||||||
* @param id the id value
|
* @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) {
|
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>
|
* <ul>
|
||||||
* <li>asc - ascending order (which is the default)</li>
|
* <li>asc - ascending order (which is the default)</li>
|
||||||
* <li>desc - Descending order</li>
|
* <li>desc - Descending order</li>
|
||||||
* <li>nullsHigh - Treat null values as high/large values (which is the
|
* <li>nullsHigh - Treat null values as high/large values (which is the default)</li>
|
||||||
* default)</li>
|
|
||||||
* <li>nullsLow- Treat null values as low/very small values</li>
|
* <li>nullsLow- Treat null values as low/very small values</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* If you leave off any keywords the defaults are ascending order and treating
|
* If you leave off any keywords the defaults are ascending order and treating
|
||||||
* nulls as high values.
|
* nulls as high values.
|
||||||
* </p>
|
|
||||||
* <p>
|
* <p>
|
||||||
* Note that the sorting uses a Comparator and Collections.sort(); and does
|
* Note that the sorting uses a Comparator and Collections.sort(); and does
|
||||||
* not invoke a DB query.
|
* 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.
|
* This will return null if the bean is not an enhanced entity bean.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
|
public static BeanState beanState(Object bean) {
|
||||||
|
return getDefault().beanState(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to beanState().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static BeanState getBeanState(Object bean) {
|
public static BeanState getBeanState(Object bean) {
|
||||||
return getDefault().getBeanState(bean);
|
return beanState(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the value of the Id property for a given 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) {
|
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).
|
* Return the manager of the level 2 cache ("L2" cache).
|
||||||
*/
|
*/
|
||||||
public static ServerCacheManager getServerCacheManager() {
|
public static ServerCacheManager cacheManager() {
|
||||||
return getDefault().getServerCacheManager();
|
return getDefault().cacheManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the BackgroundExecutor service for asynchronous processing of
|
* Return the BackgroundExecutor service for asynchronous processing of
|
||||||
* queries.
|
* queries.
|
||||||
*/
|
*/
|
||||||
|
public static BackgroundExecutor backgroundExecutor() {
|
||||||
|
return getDefault().backgroundExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to backgroundExecutor().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static BackgroundExecutor getBackgroundExecutor() {
|
public static BackgroundExecutor getBackgroundExecutor() {
|
||||||
return getDefault().getBackgroundExecutor();
|
return backgroundExecutor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -120,34 +120,82 @@ public interface Database {
|
|||||||
/**
|
/**
|
||||||
* Return AutoTune which is used to control the AutoTune service at runtime.
|
* 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.
|
* 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).
|
* 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
|
* Return the name. This is used with {@link DB#byName(String)} to get a
|
||||||
* Database that was registered with the DB singleton.
|
* 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.
|
* 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
|
* Return the MetaInfoManager which is used to get meta data from the Database
|
||||||
* such as query execution statistics.
|
* 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.
|
* Return the platform used for this database instance.
|
||||||
@@ -166,12 +214,28 @@ public interface Database {
|
|||||||
*
|
*
|
||||||
* @return platform for this database instance
|
* @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.
|
* 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.
|
* 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.
|
* This will return null if the bean is not an enhanced entity bean.
|
||||||
* </p>
|
* </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.
|
* 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.
|
* 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 bean The entity bean to set the id value on.
|
||||||
* @param id The id value to set.
|
* @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.
|
* 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
|
* @param id the id value
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@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.
|
* Return the extended API for Database.
|
||||||
@@ -1431,13 +1527,29 @@ public interface Database {
|
|||||||
/**
|
/**
|
||||||
* Return the manager of the server cache ("L2" cache).
|
* 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
|
* Return the BackgroundExecutor service for asynchronous processing of
|
||||||
* queries.
|
* queries.
|
||||||
*/
|
*/
|
||||||
BackgroundExecutor getBackgroundExecutor();
|
BackgroundExecutor backgroundExecutor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to backgroundExecutor().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default BackgroundExecutor getBackgroundExecutor() {
|
||||||
|
return backgroundExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the JsonContext for reading/writing JSON.
|
* Return the JsonContext for reading/writing JSON.
|
||||||
@@ -1602,6 +1714,20 @@ public interface Database {
|
|||||||
*/
|
*/
|
||||||
<T> Set<String> validateQuery(Query<T> query);
|
<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.
|
* Truncate all the given tables.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ final class DbContext {
|
|||||||
* Register a server so we can get it by its name.
|
* Register a server so we can get it by its name.
|
||||||
*/
|
*/
|
||||||
void register(Database server, boolean isDefault) {
|
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) {
|
private void registerWithName(String name, Database server, boolean isDefault) {
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public final class Ebean {
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public static ExpressionFactory getExpressionFactory() {
|
public static ExpressionFactory getExpressionFactory() {
|
||||||
return getDefault().getExpressionFactory();
|
return getDefault().expressionFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -642,7 +642,7 @@ public final class Ebean {
|
|||||||
* @param id the id value
|
* @param id the id value
|
||||||
*/
|
*/
|
||||||
public static <T> T getReference(Class<T> beanType, Object id) {
|
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>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public static BeanState getBeanState(Object bean) {
|
public static BeanState getBeanState(Object bean) {
|
||||||
return getDefault().getBeanState(bean);
|
return getDefault().beanState(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the manager of the server cache ("L2" cache).
|
* Return the manager of the server cache ("L2" cache).
|
||||||
*/
|
*/
|
||||||
public static ServerCacheManager getServerCacheManager() {
|
public static ServerCacheManager getServerCacheManager() {
|
||||||
return getDefault().getServerCacheManager();
|
return getDefault().cacheManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1216,7 +1216,7 @@ public final class Ebean {
|
|||||||
* queries.
|
* queries.
|
||||||
*/
|
*/
|
||||||
public static BackgroundExecutor getBackgroundExecutor() {
|
public static BackgroundExecutor getBackgroundExecutor() {
|
||||||
return getDefault().getBackgroundExecutor();
|
return getDefault().backgroundExecutor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import java.util.Map;
|
|||||||
* This provides a convenient way to create expressions for the default
|
* This provides a convenient way to create expressions for the default
|
||||||
* database.
|
* database.
|
||||||
* <p>
|
* <p>
|
||||||
* See also {@link DB#getExpressionFactory()}
|
* See also {@link DB#expressionFactory()}
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* Creates standard common expressions for using in a Query Where or Having
|
* 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.
|
* Equal To - property equal to the given value.
|
||||||
*/
|
*/
|
||||||
public static Expression eq(String propertyName, Object 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.
|
* Not Equal To - property not equal to the given value.
|
||||||
*/
|
*/
|
||||||
public static Expression ne(String propertyName, Object 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).
|
* using a lower() function to make it case insensitive).
|
||||||
*/
|
*/
|
||||||
public static Expression ieq(String propertyName, String value) {
|
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>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public static Expression inRange(String propertyName, Object value1, Object value2) {
|
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.
|
* Between - property between the two given values.
|
||||||
*/
|
*/
|
||||||
public static Expression between(String propertyName, Object value1, Object value2) {
|
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.
|
* Between - value between two given properties.
|
||||||
*/
|
*/
|
||||||
public static Expression between(String lowProperty, String highProperty, Object value) {
|
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.
|
* Greater Than - property greater than the given value.
|
||||||
*/
|
*/
|
||||||
public static Expression gt(String propertyName, Object 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.
|
* value.
|
||||||
*/
|
*/
|
||||||
public static Expression ge(String propertyName, Object 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.
|
* Less Than - property less than the given value.
|
||||||
*/
|
*/
|
||||||
public static Expression lt(String propertyName, Object 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.
|
* Less Than or Equal to - property less than or equal to the given value.
|
||||||
*/
|
*/
|
||||||
public static Expression le(String propertyName, Object 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.
|
* Is Null - property is null.
|
||||||
*/
|
*/
|
||||||
public static Expression isNull(String propertyName) {
|
public static Expression isNull(String propertyName) {
|
||||||
return DB.getExpressionFactory().isNull(propertyName);
|
return DB.expressionFactory().isNull(propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is Not Null - property is not null.
|
* Is Not Null - property is not null.
|
||||||
*/
|
*/
|
||||||
public static Expression isNotNull(String propertyName) {
|
public static Expression isNotNull(String propertyName) {
|
||||||
return DB.getExpressionFactory().isNotNull(propertyName);
|
return DB.expressionFactory().isNotNull(propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Case insensitive {@link #exampleLike(Object)}
|
* Case insensitive {@link #exampleLike(Object)}
|
||||||
*/
|
*/
|
||||||
public static ExampleExpression iexampleLike(Object example) {
|
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 _).
|
* LikeType.RAW (you need to add you own wildcards % and _).
|
||||||
*/
|
*/
|
||||||
public static ExampleExpression exampleLike(Object example) {
|
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.
|
* Create the query by Example expression specifying more options.
|
||||||
*/
|
*/
|
||||||
public static ExampleExpression exampleLike(Object example, boolean caseInsensitive, LikeType likeType) {
|
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).
|
* characters % (percentage) and _ (underscore).
|
||||||
*/
|
*/
|
||||||
public static Expression like(String propertyName, String value) {
|
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.
|
* a lower() function to make the expression case insensitive.
|
||||||
*/
|
*/
|
||||||
public static Expression ilike(String propertyName, String value) {
|
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%.
|
* Starts With - property like value%.
|
||||||
*/
|
*/
|
||||||
public static Expression startsWith(String propertyName, String 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.
|
* lower() function to make the expression case insensitive.
|
||||||
*/
|
*/
|
||||||
public static Expression istartsWith(String propertyName, String value) {
|
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.
|
* Ends With - property like %value.
|
||||||
*/
|
*/
|
||||||
public static Expression endsWith(String propertyName, String 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.
|
* function to make the expression case insensitive.
|
||||||
*/
|
*/
|
||||||
public static Expression iendsWith(String propertyName, String value) {
|
public static Expression iendsWith(String propertyName, String value) {
|
||||||
return DB.getExpressionFactory().iendsWith(propertyName, value);
|
return DB.expressionFactory().iendsWith(propertyName, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains - property like %value%.
|
* Contains - property like %value%.
|
||||||
*/
|
*/
|
||||||
public static Expression contains(String propertyName, String 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.
|
* function to make the expression case insensitive.
|
||||||
*/
|
*/
|
||||||
public static Expression icontains(String propertyName, String value) {
|
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).
|
* For collection properties that are empty (have not existing elements).
|
||||||
*/
|
*/
|
||||||
public static Expression isEmpty(String propertyName) {
|
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).
|
* For collection properties that are not empty (have existing elements).
|
||||||
*/
|
*/
|
||||||
public static Expression isNotEmpty(String propertyName) {
|
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.
|
* In - property has a value in the array of values.
|
||||||
*/
|
*/
|
||||||
public static Expression in(String propertyName, Object[] 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.
|
* In - using a subQuery.
|
||||||
*/
|
*/
|
||||||
public static Expression in(String propertyName, Query<?> 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.
|
* In - property has a value in the collection of values.
|
||||||
*/
|
*/
|
||||||
public static Expression in(String propertyName, Collection<?> 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>
|
* }</pre>
|
||||||
*/
|
*/
|
||||||
public static Expression inOrEmpty(String propertyName, Collection<?> values) {
|
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.
|
* Id Equal to - ID property is equal to the value.
|
||||||
*/
|
*/
|
||||||
public static Expression idEq(Object 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.
|
* @param propertyMap a map keyed by property names.
|
||||||
*/
|
*/
|
||||||
public static Expression allEq(Map<String, Object> propertyMap) {
|
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>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public static Expression raw(String raw, Object value) {
|
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>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public static Expression raw(String raw, Object[] values) {
|
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.
|
* Add raw expression with no parameters.
|
||||||
*/
|
*/
|
||||||
public static Expression raw(String raw) {
|
public static Expression raw(String raw) {
|
||||||
return DB.getExpressionFactory().raw(raw);
|
return DB.expressionFactory().raw(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* And - join two expressions with a logical and.
|
* And - join two expressions with a logical and.
|
||||||
*/
|
*/
|
||||||
public static Expression and(Expression expOne, Expression expTwo) {
|
public static Expression and(Expression expOne, Expression expTwo) {
|
||||||
|
return DB.expressionFactory().and(expOne, expTwo);
|
||||||
return DB.getExpressionFactory().and(expOne, expTwo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Or - join two expressions with a logical or.
|
* Or - join two expressions with a logical or.
|
||||||
*/
|
*/
|
||||||
public static Expression or(Expression expOne, Expression expTwo) {
|
public static Expression or(Expression expOne, Expression expTwo) {
|
||||||
|
return DB.expressionFactory().or(expOne, expTwo);
|
||||||
return DB.getExpressionFactory().or(expOne, expTwo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Negate the expression (prefix it with NOT).
|
* Negate the expression (prefix it with NOT).
|
||||||
*/
|
*/
|
||||||
public static Expression not(Expression exp) {
|
public static Expression not(Expression exp) {
|
||||||
|
return DB.expressionFactory().not(exp);
|
||||||
return DB.getExpressionFactory().not(exp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of expressions that will be joined by AND's.
|
* Return a list of expressions that will be joined by AND's.
|
||||||
*/
|
*/
|
||||||
public static <T> Junction<T> conjunction(Query<T> query) {
|
public static <T> Junction<T> conjunction(Query<T> query) {
|
||||||
|
return DB.expressionFactory().conjunction(query);
|
||||||
return DB.getExpressionFactory().conjunction(query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of expressions that will be joined by OR's.
|
* Return a list of expressions that will be joined by OR's.
|
||||||
*/
|
*/
|
||||||
public static <T> Junction<T> disjunction(Query<T> query) {
|
public static <T> Junction<T> disjunction(Query<T> query) {
|
||||||
|
return DB.expressionFactory().disjunction(query);
|
||||||
return DB.getExpressionFactory().disjunction(query);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,11 +137,11 @@ public class Finder<I, T> {
|
|||||||
/**
|
/**
|
||||||
* Creates an entity reference for this ID.
|
* Creates an entity reference for this ID.
|
||||||
* <p>
|
* <p>
|
||||||
* Equivalent to {@link Database#getReference(Class, Object)}
|
* Equivalent to {@link Database#reference(Class, Object)}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public T ref(I id) {
|
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:
|
* Examples of when a developer may wish to use the connection directly are:
|
||||||
* Savepoints, advanced CLOB BLOB use and advanced stored procedure calls.
|
* 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.
|
* Add table modification information to the TransactionEvent.
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public interface BeanCollectionLoader {
|
|||||||
/**
|
/**
|
||||||
* Return the name of the associated Database.
|
* Return the name of the associated Database.
|
||||||
*/
|
*/
|
||||||
String getName();
|
String name();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke the lazy loading for this bean collection.
|
* 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
|
// For stand alone reference bean or after deserialisation lazy load
|
||||||
// using the ebeanServer. Synchronise only on the bean.
|
// using the ebeanServer. Synchronise only on the bean.
|
||||||
loadBeanInternal(loadProperty, database.getPluginApi().beanLoader());
|
loadBeanInternal(loadProperty, database.pluginApi().beanLoader());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public abstract class SingleBeanLoader implements BeanLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return database.getName();
|
return database.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -39,7 +39,7 @@ public abstract class SingleBeanLoader implements BeanLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadBean(EntityBeanIntercept ebi) {
|
public void loadBean(EntityBeanIntercept ebi) {
|
||||||
database.getPluginApi().loadBeanL2(ebi);
|
database.pluginApi().loadBeanL2(ebi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ public abstract class SingleBeanLoader implements BeanLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadBean(EntityBeanIntercept ebi) {
|
public void loadBean(EntityBeanIntercept ebi) {
|
||||||
database.getPluginApi().loadBeanRef(ebi);
|
database.pluginApi().loadBeanRef(ebi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ public abstract class SingleBeanLoader implements BeanLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadBean(EntityBeanIntercept ebi) {
|
public void loadBean(EntityBeanIntercept ebi) {
|
||||||
database.getPluginApi().loadBean(ebi);
|
database.pluginApi().loadBean(ebi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,9 +13,7 @@ import java.util.Set;
|
|||||||
public class QueryCacheEntry {
|
public class QueryCacheEntry {
|
||||||
|
|
||||||
private final Object value;
|
private final Object value;
|
||||||
|
|
||||||
private final Set<String> dependentTables;
|
private final Set<String> dependentTables;
|
||||||
|
|
||||||
private final long timestamp;
|
private final long timestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+19
-3
@@ -10,17 +10,17 @@ import java.util.Set;
|
|||||||
* Represents part of the "L2" server side cache.
|
* Represents part of the "L2" server side cache.
|
||||||
* <p>
|
* <p>
|
||||||
* This is used to cache beans or query results (bean collections).
|
* This is used to cache beans or query results (bean collections).
|
||||||
* </p>
|
|
||||||
* <p>
|
* <p>
|
||||||
* There are 2 ServerCache's for each bean type. One is used as the 'bean cache'
|
* 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
|
* which holds beans of a given type. The other is the 'query cache' holding
|
||||||
* query results for a given type.
|
* query results for a given type.
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
public interface ServerCache {
|
public interface ServerCache {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get values for many keys.
|
||||||
|
*/
|
||||||
default Map<Object, Object> getAll(Set<Object> keys) {
|
default Map<Object, Object> getAll(Set<Object> keys) {
|
||||||
|
|
||||||
Map<Object, Object> map = new LinkedHashMap<>();
|
Map<Object, Object> map = new LinkedHashMap<>();
|
||||||
for (Object key : keys) {
|
for (Object key : keys) {
|
||||||
Object value = get(key);
|
Object value = get(key);
|
||||||
@@ -73,6 +73,14 @@ public interface ServerCache {
|
|||||||
/**
|
/**
|
||||||
* Return the hit ratio the cache is currently getting.
|
* Return the hit ratio the cache is currently getting.
|
||||||
*/
|
*/
|
||||||
|
default int hitRatio() {
|
||||||
|
return getHitRatio();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to hitRatio().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
int getHitRatio();
|
int getHitRatio();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,6 +88,14 @@ public interface ServerCache {
|
|||||||
*
|
*
|
||||||
* @param reset if true the statistics are reset.
|
* @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);
|
ServerCacheStatistics getStatistics(boolean reset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,7 +21,15 @@ public interface ServerCacheManager {
|
|||||||
* rather than background processing.
|
* rather than background processing.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
boolean isLocalL2Caching();
|
boolean localL2Caching();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to localL2Caching().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default boolean isLocalL2Caching() {
|
||||||
|
return localL2Caching();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all the cache regions.
|
* Return all the cache regions.
|
||||||
@@ -36,37 +44,78 @@ public interface ServerCacheManager {
|
|||||||
*
|
*
|
||||||
* @param regions A region name or comma delimited list of region names.
|
* @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.
|
* 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.
|
* 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.
|
* 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.
|
* 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.
|
* 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.
|
* This clears both the bean and query cache for a given type.
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ public class ServerCacheOptions {
|
|||||||
* Construct with no set options.
|
* Construct with no set options.
|
||||||
*/
|
*/
|
||||||
public ServerCacheOptions() {
|
public ServerCacheOptions() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,7 +72,6 @@ public class ServerCacheOptions {
|
|||||||
* Return a copy of this object.
|
* Return a copy of this object.
|
||||||
*/
|
*/
|
||||||
public ServerCacheOptions copy() {
|
public ServerCacheOptions copy() {
|
||||||
|
|
||||||
ServerCacheOptions copy = new ServerCacheOptions();
|
ServerCacheOptions copy = new ServerCacheOptions();
|
||||||
copy.maxSize = maxSize;
|
copy.maxSize = maxSize;
|
||||||
copy.maxIdleSecs = maxIdleSecs;
|
copy.maxIdleSecs = maxIdleSecs;
|
||||||
|
|||||||
@@ -8,7 +8,15 @@ public interface ServerCacheRegion {
|
|||||||
/**
|
/**
|
||||||
* Return the region name.
|
* 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.
|
* 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) {
|
AbstractBeanCollection(BeanCollectionLoader loader, EntityBean ownerBean, String propertyName) {
|
||||||
this.loader = loader;
|
this.loader = loader;
|
||||||
this.ebeanServerName = loader.getName();
|
this.ebeanServerName = loader.name();
|
||||||
this.ownerBean = ownerBean;
|
this.ownerBean = ownerBean;
|
||||||
this.propertyName = propertyName;
|
this.propertyName = propertyName;
|
||||||
this.readOnly = ownerBean != null && ownerBean._ebean_getIntercept().isReadOnly();
|
this.readOnly = ownerBean != null && ownerBean._ebean_getIntercept().isReadOnly();
|
||||||
@@ -111,7 +111,7 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
|
|||||||
public void setLoader(BeanCollectionLoader loader) {
|
public void setLoader(BeanCollectionLoader loader) {
|
||||||
this.registeredWithLoadContext = true;
|
this.registeredWithLoadContext = true;
|
||||||
this.loader = loader;
|
this.loader = loader;
|
||||||
this.ebeanServerName = loader.getName();
|
this.ebeanServerName = loader.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class SimpleSequenceIdGenerator implements PlatformIdGenerator {
|
|||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rset = null;
|
ResultSet rset = null;
|
||||||
try {
|
try {
|
||||||
c = useTxnConnection ? t.getConnection() : dataSource.getConnection();
|
c = useTxnConnection ? t.connection() : dataSource.getConnection();
|
||||||
pstmt = c.prepareStatement(sql);
|
pstmt = c.prepareStatement(sql);
|
||||||
rset = pstmt.executeQuery();
|
rset = pstmt.executeQuery();
|
||||||
if (rset.next()) {
|
if (rset.next()) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.ebean.event;
|
package io.ebean.event;
|
||||||
|
|
||||||
|
import io.ebean.Database;
|
||||||
import io.ebean.EbeanServer;
|
import io.ebean.EbeanServer;
|
||||||
import io.ebean.Transaction;
|
import io.ebean.Transaction;
|
||||||
|
|
||||||
@@ -9,18 +10,62 @@ import io.ebean.Transaction;
|
|||||||
public interface BeanDeleteIdRequest {
|
public interface BeanDeleteIdRequest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the server processing the request.
|
* Deprecated migrate to database().
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
EbeanServer getEbeanServer();
|
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.
|
* 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.
|
* 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;
|
package io.ebean.event;
|
||||||
|
|
||||||
|
import io.ebean.Database;
|
||||||
import io.ebean.EbeanServer;
|
import io.ebean.EbeanServer;
|
||||||
import io.ebean.Transaction;
|
import io.ebean.Transaction;
|
||||||
import io.ebean.ValuePair;
|
import io.ebean.ValuePair;
|
||||||
@@ -17,20 +18,44 @@ import java.util.Set;
|
|||||||
public interface BeanPersistRequest<T> {
|
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();
|
EbeanServer getEbeanServer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Transaction associated with this request.
|
* 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
|
* For an update or delete of a partially populated bean this is the set of
|
||||||
* loaded properties and otherwise returns null.
|
* 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.
|
* 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.
|
* should be preferred if it satisfies the requirement.
|
||||||
* </p>
|
* </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).
|
* 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
|
* 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.
|
* 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.
|
* 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;
|
package io.ebean.event;
|
||||||
|
|
||||||
|
import io.ebean.Database;
|
||||||
import io.ebean.EbeanServer;
|
import io.ebean.EbeanServer;
|
||||||
import io.ebean.Query;
|
import io.ebean.Query;
|
||||||
import io.ebean.Transaction;
|
import io.ebean.Transaction;
|
||||||
@@ -10,19 +11,43 @@ import io.ebean.Transaction;
|
|||||||
public interface BeanQueryRequest<T> {
|
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();
|
EbeanServer getEbeanServer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Transaction associated with this request.
|
* Return the Transaction associated with this request.
|
||||||
*/
|
*/
|
||||||
Transaction getTransaction();
|
Transaction transaction();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to transaction().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default Transaction getTransaction() {
|
||||||
|
return transaction();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the query.
|
* 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.
|
* 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.
|
* 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.
|
* Return true if rows were inserted.
|
||||||
|
|||||||
@@ -10,7 +10,15 @@ public interface QueryPlanMetric {
|
|||||||
/**
|
/**
|
||||||
* Return the underlying timed metric.
|
* Return the underlying timed metric.
|
||||||
*/
|
*/
|
||||||
TimedMetric getMetric();
|
TimedMetric metric();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to metric().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default TimedMetric getMetric() {
|
||||||
|
return metric();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visit the underlying metric.
|
* Visit the underlying metric.
|
||||||
|
|||||||
@@ -16,11 +16,27 @@ public interface BeanDocType<T> {
|
|||||||
/**
|
/**
|
||||||
* Return the doc store index type for this bean type.
|
* Return the doc store index type for this bean type.
|
||||||
*/
|
*/
|
||||||
|
default String indexType() {
|
||||||
|
return getIndexType();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to indexType().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
String getIndexType();
|
String getIndexType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the doc store index name for this bean type.
|
* Return the doc store index name for this bean type.
|
||||||
*/
|
*/
|
||||||
|
default String indexName() {
|
||||||
|
return getIndexName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to indexName().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
String getIndexName();
|
String getIndexName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,12 +48,28 @@ public interface BeanDocType<T> {
|
|||||||
/**
|
/**
|
||||||
* Return the FetchPath for the embedded document.
|
* Return the FetchPath for the embedded document.
|
||||||
*/
|
*/
|
||||||
|
default FetchPath embedded(String path) {
|
||||||
|
return getEmbedded(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to embedded().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
FetchPath getEmbedded(String path);
|
FetchPath getEmbedded(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For embedded 'many' properties we need a FetchPath relative to the root which is used to
|
* For embedded 'many' properties we need a FetchPath relative to the root which is used to
|
||||||
* build and replace the embedded list.
|
* build and replace the embedded list.
|
||||||
*/
|
*/
|
||||||
|
default FetchPath embeddedManyRoot(String path) {
|
||||||
|
return getEmbeddedManyRoot(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to embeddedManyRoot().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
FetchPath getEmbeddedManyRoot(String path);
|
FetchPath getEmbeddedManyRoot(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,24 +22,56 @@ public interface BeanType<T> {
|
|||||||
* Return the short name of the bean type.
|
* Return the short name of the bean type.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
String getName();
|
String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to name().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default String getName() {
|
||||||
|
return name();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the full name of the bean type.
|
* Return the full name of the bean type.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
String getFullName();
|
String fullName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to fullName().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default String getFullName() {
|
||||||
|
return fullName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the class type this BeanDescriptor describes.
|
* Return the class type this BeanDescriptor describes.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@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.
|
* 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.
|
* Return all the properties for this bean type.
|
||||||
@@ -50,22 +82,54 @@ public interface BeanType<T> {
|
|||||||
/**
|
/**
|
||||||
* Return the Id property.
|
* 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.
|
* 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.
|
* 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.
|
* 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.
|
* 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.
|
* This can return a property or nested property path.
|
||||||
* </p>
|
* </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.
|
* 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.
|
* 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.
|
* 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.
|
* 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);
|
Object getBeanId(T bean);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the id value to the 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.
|
* Return the bean persist controller.
|
||||||
*/
|
*/
|
||||||
BeanPersistController getPersistController();
|
BeanPersistController persistController();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to persistController()
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default BeanPersistController getPersistController() {
|
||||||
|
return persistController();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the bean persist listener.
|
* 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.
|
* 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.
|
* 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.
|
* 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.
|
* Return true if this bean type has doc store backing.
|
||||||
@@ -167,12 +304,28 @@ public interface BeanType<T> {
|
|||||||
* for the document store.
|
* for the document store.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
DocMapping getDocMapping();
|
DocMapping docMapping();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to docMapping()
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default DocMapping getDocMapping() {
|
||||||
|
return docMapping();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the doc store queueId for this bean type.
|
* 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.\
|
* Return the doc store support for this bean type.\
|
||||||
@@ -203,12 +356,28 @@ public interface BeanType<T> {
|
|||||||
/**
|
/**
|
||||||
* Returns all direct children of this beantype
|
* 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
|
* Visit all children recursively
|
||||||
@@ -218,7 +387,15 @@ public interface BeanType<T> {
|
|||||||
/**
|
/**
|
||||||
* Return the discriminator column.
|
* 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.
|
* Create a bean given the discriminator value.
|
||||||
|
|||||||
@@ -37,7 +37,15 @@ public interface ExpressionPath {
|
|||||||
/**
|
/**
|
||||||
* Return the default StringParser for the scalar property.
|
* 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
|
* 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.
|
* 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.
|
* 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.
|
* Typically used to produce id = ? expression strings.
|
||||||
* </p>
|
* </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.
|
* 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.
|
* Return the underlying bean property.
|
||||||
*/
|
*/
|
||||||
Property getProperty();
|
Property property();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to property().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default Property getProperty() {
|
||||||
|
return property();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ElPrefix plus name.
|
* 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.
|
* Return the name of the property.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
String getName();
|
String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to name().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default String getName() {
|
||||||
|
return name();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the type of the property.
|
* Return the type of the property.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@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.
|
* 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.
|
* Return true if this is a OneToMany or ManyToMany property.
|
||||||
|
|||||||
@@ -16,32 +16,80 @@ public interface SpiServer extends Database {
|
|||||||
/**
|
/**
|
||||||
* Return the DatabaseConfig.
|
* Return the DatabaseConfig.
|
||||||
*/
|
*/
|
||||||
DatabaseConfig getServerConfig();
|
DatabaseConfig config();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migrate to config().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default DatabaseConfig getServerConfig() {
|
||||||
|
return config();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the DatabasePlatform for this database.
|
* 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.
|
* 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.
|
* 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.
|
* 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.
|
* 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.
|
* Return a BeanLoader.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package io.ebean.config.dbplatform;
|
package io.ebean.config.dbplatform;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ebean-parent</artifactId>
|
<artifactId>ebean-parent</artifactId>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<!-- <parent>-->
|
<!-- <parent>-->
|
||||||
<!-- <groupId>org.avaje</groupId>-->
|
<!-- <groupId>org.avaje</groupId>-->
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
|
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
|
||||||
<tag>ebean-parent-12.8.0</tag>
|
<tag>ebean-parent-12.11.4</tag>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<name>ebean autotune</name>
|
<name>ebean autotune</name>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-core</artifactId>
|
<artifactId>ebean-core</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -46,9 +46,9 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.avaje.composite</groupId>
|
<groupId>io.avaje</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -59,12 +59,12 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>io.repaint.maven</groupId>
|
<groupId>io.repaint.maven</groupId>
|
||||||
<artifactId>tiles-maven-plugin</artifactId>
|
<artifactId>tiles-maven-plugin</artifactId>
|
||||||
<version>2.19</version>
|
<version>2.24</version>
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<tiles>
|
<tiles>
|
||||||
<!-- other tiles ... -->
|
<!-- other tiles ... -->
|
||||||
<tile>io.ebean.tile:enhancement:12.6.0</tile>
|
<tile>io.ebean.tile:enhancement:12.11.3</tile>
|
||||||
</tiles>
|
</tiles>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
+2
-2
@@ -59,7 +59,7 @@ public class DefaultAutoTuneService implements AutoTuneService {
|
|||||||
this.tuningFile = config.getQueryTuningFile();
|
this.tuningFile = config.getQueryTuningFile();
|
||||||
this.profilingFile = config.getProfilingFile();
|
this.profilingFile = config.getProfilingFile();
|
||||||
this.profilingUpdateFrequency = config.getProfilingUpdateFrequency();
|
this.profilingUpdateFrequency = config.getProfilingUpdateFrequency();
|
||||||
this.serverName = server.getName();
|
this.serverName = server.name();
|
||||||
this.profileManager = new ProfileManager(config, server);
|
this.profileManager = new ProfileManager(config, server);
|
||||||
this.queryTuner = new BaseQueryTuner(config, server, profileManager);
|
this.queryTuner = new BaseQueryTuner(config, server, profileManager);
|
||||||
this.skipGarbageCollectionOnShutdown = config.isSkipGarbageCollectionOnShutdown();
|
this.skipGarbageCollectionOnShutdown = config.isSkipGarbageCollectionOnShutdown();
|
||||||
@@ -77,7 +77,7 @@ public class DefaultAutoTuneService implements AutoTuneService {
|
|||||||
loadTuningFile();
|
loadTuningFile();
|
||||||
if (isRuntimeTuningUpdates()) {
|
if (isRuntimeTuningUpdates()) {
|
||||||
// periodically gather and update query tuning
|
// periodically gather and update query tuning
|
||||||
server.getBackgroundExecutor().scheduleWithFixedDelay(new ProfilingUpdate(), profilingUpdateFrequency, profilingUpdateFrequency, TimeUnit.SECONDS);
|
server.backgroundExecutor().scheduleWithFixedDelay(new ProfilingUpdate(), profilingUpdateFrequency, profilingUpdateFrequency, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -111,7 +111,7 @@ public class ProfileManager implements ProfilingListener {
|
|||||||
public AutoTuneCollection profilingCollection(boolean reset) {
|
public AutoTuneCollection profilingCollection(boolean reset) {
|
||||||
AutoTuneCollection req = new AutoTuneCollection();
|
AutoTuneCollection req = new AutoTuneCollection();
|
||||||
for (ProfileOrigin origin : profileMap.values()) {
|
for (ProfileOrigin origin : profileMap.values()) {
|
||||||
BeanDescriptor<?> desc = server.getBeanDescriptorById(origin.getOrigin().getBeanType());
|
BeanDescriptor<?> desc = server.descriptorById(origin.getOrigin().getBeanType());
|
||||||
if (desc != null) {
|
if (desc != null) {
|
||||||
origin.profilingCollection(desc, req, reset);
|
origin.profilingCollection(desc, req, reset);
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -43,14 +43,14 @@ public class ProfileOriginNodeUsage {
|
|||||||
try {
|
try {
|
||||||
BeanDescriptor<?> desc = rootDesc;
|
BeanDescriptor<?> desc = rootDesc;
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
ElPropertyValue elGetValue = rootDesc.getElGetValue(path);
|
ElPropertyValue elGetValue = rootDesc.elGetValue(path);
|
||||||
if (elGetValue == null) {
|
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;
|
return;
|
||||||
} else {
|
} else {
|
||||||
BeanProperty beanProperty = elGetValue.getBeanProperty();
|
BeanProperty beanProperty = elGetValue.beanProperty();
|
||||||
if (beanProperty instanceof BeanPropertyAssoc<?>) {
|
if (beanProperty instanceof BeanPropertyAssoc<?>) {
|
||||||
desc = ((BeanPropertyAssoc<?>) beanProperty).getTargetDescriptor();
|
desc = ((BeanPropertyAssoc<?>) beanProperty).targetDescriptor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ public class ProfileOriginNodeUsage {
|
|||||||
for (String propName : aggregateUsed) {
|
for (String propName : aggregateUsed) {
|
||||||
BeanProperty beanProp = desc.findPropertyFromPath(propName);
|
BeanProperty beanProp = desc.findPropertyFromPath(propName);
|
||||||
if (beanProp == null) {
|
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 {
|
} else {
|
||||||
if (beanProp.isId()) {
|
if (beanProp.isId()) {
|
||||||
@@ -76,24 +76,24 @@ public class ProfileOriginNodeUsage {
|
|||||||
// (which is the default for Lob's so typical).
|
// (which is the default for Lob's so typical).
|
||||||
} else {
|
} else {
|
||||||
addedToPath = true;
|
addedToPath = true;
|
||||||
pathProps.addToPath(path, beanProp.getName());
|
pathProps.addToPath(path, beanProp.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((modified || addVersionProperty) && desc != null) {
|
if ((modified || addVersionProperty) && desc != null) {
|
||||||
BeanProperty versionProp = desc.getVersionProperty();
|
BeanProperty versionProp = desc.versionProperty();
|
||||||
if (versionProp != null) {
|
if (versionProp != null) {
|
||||||
addedToPath = true;
|
addedToPath = true;
|
||||||
pathProps.addToPath(path, versionProp.getName());
|
pathProps.addToPath(path, versionProp.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toOneIdProperty != null && !addedToPath) {
|
if (toOneIdProperty != null && !addedToPath) {
|
||||||
// add ToOne property to parent path
|
// add ToOne property to parent path
|
||||||
ElPropertyValue assocOne = rootDesc.getElGetValue(path);
|
ElPropertyValue assocOne = rootDesc.elGetValue(path);
|
||||||
pathProps.addToPath(SplitName.parent(path), assocOne.getName());
|
pathProps.addToPath(SplitName.parent(path), assocOne.name());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package io.ebeaninternal.server.autotune.service;
|
package io.ebeaninternal.server.autotune.service;
|
||||||
|
|
||||||
import io.ebeaninternal.server.autotune.model.Autotune;
|
import io.ebeaninternal.server.autotune.model.Autotune;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ import io.ebean.bean.ObjectGraphNode;
|
|||||||
import io.ebean.bean.ObjectGraphOrigin;
|
import io.ebean.bean.ObjectGraphOrigin;
|
||||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||||
import io.ebeaninternal.server.querydefn.OrmQueryDetail;
|
import io.ebeaninternal.server.querydefn.OrmQueryDetail;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.tests.autofetch.BaseTestCase;
|
import org.tests.autofetch.BaseTestCase;
|
||||||
import org.tests.model.basic.Order;
|
import org.tests.model.basic.Order;
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,6 @@ public class BaseTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected <T> BeanDescriptor<T> getBeanDescriptor(Class<T> cls) {
|
protected <T> BeanDescriptor<T> getBeanDescriptor(Class<T> cls) {
|
||||||
return spiEbeanServer().getBeanDescriptor(cls);
|
return spiEbeanServer().descriptor(cls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+15
-15
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ebean-parent</artifactId>
|
<artifactId>ebean-parent</artifactId>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<name>ebean bom</name>
|
<name>ebean bom</name>
|
||||||
@@ -71,88 +71,88 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean</artifactId>
|
<artifactId>ebean</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-api</artifactId>
|
<artifactId>ebean-api</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-core</artifactId>
|
<artifactId>ebean-core</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-core-type</artifactId>
|
<artifactId>ebean-core-type</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-ddl-generator</artifactId>
|
<artifactId>ebean-ddl-generator</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-externalmapping-api</artifactId>
|
<artifactId>ebean-externalmapping-api</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-externalmapping-xml</artifactId>
|
<artifactId>ebean-externalmapping-xml</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-autotune</artifactId>
|
<artifactId>ebean-autotune</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-querybean</artifactId>
|
<artifactId>ebean-querybean</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>querybean-generator</artifactId>
|
<artifactId>querybean-generator</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>kotlin-querybean-generator</artifactId>
|
<artifactId>kotlin-querybean-generator</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-test</artifactId>
|
<artifactId>ebean-test</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-postgis</artifactId>
|
<artifactId>ebean-postgis</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-redis</artifactId>
|
<artifactId>ebean-redis</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ebean-parent</artifactId>
|
<artifactId>ebean-parent</artifactId>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>ebean-core-type</artifactId>
|
<artifactId>ebean-core-type</artifactId>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-api</artifactId>
|
<artifactId>ebean-api</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
+20
-149
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ebean-parent</artifactId>
|
<artifactId>ebean-parent</artifactId>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>ebean-core</artifactId>
|
<artifactId>ebean-core</artifactId>
|
||||||
@@ -15,35 +15,21 @@
|
|||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
|
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
|
||||||
<tag>ebean-parent-12.8.0</tag>
|
<tag>ebean-parent-12.11.4</tag>
|
||||||
</scm>
|
</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>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-ddl-runner</artifactId>
|
<artifactId>ebean-ddl-runner</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.avaje</groupId>
|
<groupId>io.avaje</groupId>
|
||||||
<artifactId>classpath-scanner</artifactId>
|
<artifactId>classpath-scanner</artifactId>
|
||||||
<version>6.0</version>
|
<version>6.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -52,45 +38,22 @@
|
|||||||
<version>1.1</version>
|
<version>1.1</version>
|
||||||
</dependency>
|
</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>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-api</artifactId>
|
<artifactId>ebean-api</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-core-type</artifactId>
|
<artifactId>ebean-core-type</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-externalmapping-api</artifactId>
|
<artifactId>ebean-externalmapping-api</artifactId>
|
||||||
<version>12.11.2-SNAPSHOT</version>
|
<version>12.11.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -105,8 +68,8 @@
|
|||||||
-->
|
-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.avaje</groupId>
|
<groupId>io.avaje</groupId>
|
||||||
<artifactId>avaje-jsr305</artifactId>
|
<artifactId>avaje-jsr305-x</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -121,8 +84,8 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.transaction</groupId>
|
<groupId>javax.transaction</groupId>
|
||||||
<artifactId>jta</artifactId>
|
<artifactId>javax.transaction-api</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.3</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -130,7 +93,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.validation</groupId>
|
<groupId>javax.validation</groupId>
|
||||||
<artifactId>validation-api</artifactId>
|
<artifactId>validation-api</artifactId>
|
||||||
<version>1.1.0.Final</version>
|
<version>2.0.1.Final</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -147,12 +110,12 @@
|
|||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>javax.annotation</groupId>
|
<!-- <groupId>javax.annotation</groupId>-->
|
||||||
<artifactId>javax.annotation-api</artifactId>
|
<!-- <artifactId>javax.annotation-api</artifactId>-->
|
||||||
<version>1.3.2</version>
|
<!-- <version>1.3.2</version>-->
|
||||||
<optional>true</optional>
|
<!-- <optional>true</optional>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<!-- Jackson core used internally by Ebean -->
|
<!-- Jackson core used internally by Ebean -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -186,107 +149,15 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</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>
|
<dependency>
|
||||||
<groupId>io.avaje</groupId>
|
<groupId>io.avaje</groupId>
|
||||||
<artifactId>mod-uuid</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface LoadBeanBuffer {
|
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);
|
void configureQuery(SpiQuery<?> query, String lazyLoadProperty);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package io.ebeaninternal.api;
|
package io.ebeaninternal.api;
|
||||||
|
|
||||||
import io.ebean.bean.EntityBean;
|
import io.ebean.CacheMode;
|
||||||
import io.ebean.bean.EntityBeanIntercept;
|
import io.ebean.bean.EntityBeanIntercept;
|
||||||
|
import io.ebeaninternal.api.SpiQuery.Mode;
|
||||||
import io.ebeaninternal.server.core.OrmQueryRequest;
|
import io.ebeaninternal.server.core.OrmQueryRequest;
|
||||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||||
|
|
||||||
@@ -19,77 +20,54 @@ public final class LoadBeanRequest extends LoadRequest {
|
|||||||
private final LoadBeanBuffer loadBuffer;
|
private final LoadBeanBuffer loadBuffer;
|
||||||
private final String lazyLoadProperty;
|
private final String lazyLoadProperty;
|
||||||
private final boolean loadCache;
|
private final boolean loadCache;
|
||||||
private boolean loadedFromCache;
|
private final boolean alreadyLoaded;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct for lazy load request.
|
* Construct for lazy load request.
|
||||||
*/
|
*/
|
||||||
public LoadBeanRequest(LoadBeanBuffer LoadBuffer, EntityBeanIntercept ebi, boolean loadCache) {
|
public LoadBeanRequest(LoadBeanBuffer loadBuffer, EntityBeanIntercept ebi, boolean loadCache) {
|
||||||
this(LoadBuffer, null, true, ebi.getLazyLoadProperty(), loadCache);
|
this(loadBuffer, null, true, ebi.getLazyLoadProperty(), ebi.isLoaded(), loadCache || ebi.isLoadedFromCache());
|
||||||
this.loadedFromCache = ebi.isLoadedFromCache();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct for secondary query.
|
* Construct for secondary query.
|
||||||
*/
|
*/
|
||||||
public LoadBeanRequest(LoadBeanBuffer LoadBuffer, OrmQueryRequest<?> parentRequest) {
|
public LoadBeanRequest(LoadBeanBuffer loadBuffer, OrmQueryRequest<?> parentRequest) {
|
||||||
this(LoadBuffer, parentRequest, false, null, false);
|
this(loadBuffer, parentRequest, false, null, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LoadBeanRequest(LoadBeanBuffer loadBuffer, OrmQueryRequest<?> parentRequest, boolean lazy,
|
private LoadBeanRequest(LoadBeanBuffer loadBuffer, OrmQueryRequest<?> parentRequest, boolean lazy,
|
||||||
String lazyLoadProperty, boolean loadCache) {
|
String lazyLoadProperty, boolean alreadyLoaded, boolean loadCache) {
|
||||||
|
|
||||||
super(parentRequest, lazy);
|
super(parentRequest, lazy);
|
||||||
this.loadBuffer = loadBuffer;
|
this.loadBuffer = loadBuffer;
|
||||||
this.batch = loadBuffer.getBatch();
|
this.batch = loadBuffer.batch();
|
||||||
this.lazyLoadProperty = lazyLoadProperty;
|
this.lazyLoadProperty = lazyLoadProperty;
|
||||||
|
this.alreadyLoaded = alreadyLoaded;
|
||||||
this.loadCache = loadCache;
|
this.loadCache = loadCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getBeanType() {
|
public Class<?> beanType() {
|
||||||
return loadBuffer.getBeanDescriptor().getBeanType();
|
return loadBuffer.descriptor().type();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public String description() {
|
||||||
* Return true if the beans invoking lazy loading were previously loaded from cache.
|
return loadBuffer.fullPath();
|
||||||
*/
|
|
||||||
public boolean isLoadedFromCache() {
|
|
||||||
return loadedFromCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isLoadCache() {
|
|
||||||
return loadCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return "path:" + loadBuffer.getFullPath() + " batch:" + batch.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the batch of beans to actually load.
|
* Return the batch of beans to actually load.
|
||||||
*/
|
*/
|
||||||
public List<EntityBeanIntercept> getBatch() {
|
public List<EntityBeanIntercept> batch() {
|
||||||
return 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.
|
* Return the list of Id values for the beans in the lazy load buffer.
|
||||||
*/
|
*/
|
||||||
public List<Object> getIdList() {
|
public List<Object> getIdList() {
|
||||||
List<Object> idList = new ArrayList<>();
|
List<Object> idList = new ArrayList<>();
|
||||||
BeanDescriptor<?> desc = loadBuffer.getBeanDescriptor();
|
BeanDescriptor<?> desc = loadBuffer.descriptor();
|
||||||
for (EntityBeanIntercept ebi : batch) {
|
for (EntityBeanIntercept ebi : batch) {
|
||||||
idList.add(desc.getId(ebi.getOwner()));
|
idList.add(desc.getId(ebi.getOwner()));
|
||||||
}
|
}
|
||||||
@@ -100,16 +78,21 @@ public final class LoadBeanRequest extends LoadRequest {
|
|||||||
* Configure the query for lazy loading execution.
|
* Configure the query for lazy loading execution.
|
||||||
*/
|
*/
|
||||||
public void configureQuery(SpiQuery<?> query, List<Object> idList) {
|
public void configureQuery(SpiQuery<?> query, List<Object> idList) {
|
||||||
query.setMode(SpiQuery.Mode.LAZYLOAD_BEAN);
|
query.setMode(Mode.LAZYLOAD_BEAN);
|
||||||
query.setPersistenceContext(loadBuffer.getPersistenceContext());
|
query.setPersistenceContext(loadBuffer.persistenceContext());
|
||||||
String mode = isLazy() ? "+lazy" : "+query";
|
query.setLoadDescription(lazy ? "+lazy" : "+query", description());
|
||||||
query.setLoadDescription(mode, getDescription());
|
if (lazy) {
|
||||||
|
query.setLazyLoadBatchSize(loadBuffer.batchSize());
|
||||||
if (isLazy()) {
|
if (alreadyLoaded) {
|
||||||
// cascade the batch size (if set) for further lazy loading
|
query.setBeanCacheMode(CacheMode.OFF);
|
||||||
query.setLazyLoadBatchSize(getBatchSize());
|
}
|
||||||
|
} else {
|
||||||
|
query.setBeanCacheMode(CacheMode.OFF);
|
||||||
}
|
}
|
||||||
loadBuffer.configureQuery(query, lazyLoadProperty);
|
loadBuffer.configureQuery(query, lazyLoadProperty);
|
||||||
|
if (loadCache) {
|
||||||
|
query.setBeanCacheMode(CacheMode.PUT);
|
||||||
|
}
|
||||||
if (idList.size() == 1) {
|
if (idList.size() == 1) {
|
||||||
query.where().idEq(idList.get(0));
|
query.where().idEq(idList.get(0));
|
||||||
} else {
|
} else {
|
||||||
@@ -122,13 +105,12 @@ public final class LoadBeanRequest extends LoadRequest {
|
|||||||
*/
|
*/
|
||||||
public void postLoad(List<?> list) {
|
public void postLoad(List<?> list) {
|
||||||
Set<Object> loadedIds = new HashSet<>();
|
Set<Object> loadedIds = new HashSet<>();
|
||||||
BeanDescriptor<?> desc = loadBuffer.getBeanDescriptor();
|
BeanDescriptor<?> desc = loadBuffer.descriptor();
|
||||||
// collect Ids and maybe load bean cache
|
// collect Ids and maybe load bean cache
|
||||||
for (Object bean : list) {
|
for (Object bean : list) {
|
||||||
EntityBean loadedBean = (EntityBean) bean;
|
loadedIds.add(desc.id(bean));
|
||||||
loadedIds.add(desc.getId(loadedBean));
|
|
||||||
}
|
}
|
||||||
if (isLoadCache()) {
|
if (loadCache) {
|
||||||
desc.cacheBeanPutAll(list);
|
desc.cacheBeanPutAll(list);
|
||||||
}
|
}
|
||||||
if (lazyLoadProperty != null) {
|
if (lazyLoadProperty != null) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.ebeaninternal.api;
|
package io.ebeaninternal.api;
|
||||||
|
|
||||||
|
import io.ebean.CacheMode;
|
||||||
import io.ebean.bean.BeanCollection;
|
import io.ebean.bean.BeanCollection;
|
||||||
import io.ebean.bean.EntityBean;
|
import io.ebean.bean.EntityBean;
|
||||||
import io.ebeaninternal.server.core.BindPadding;
|
import io.ebeaninternal.server.core.BindPadding;
|
||||||
@@ -47,96 +48,58 @@ public final class LoadManyRequest extends LoadRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getBeanType() {
|
public Class<?> beanType() {
|
||||||
return loadContext.getBeanDescriptor().getBeanType();
|
return loadContext.getBeanDescriptor().type();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String description() {
|
||||||
return "path:" + loadContext.getFullPath() + " size:" + batch.size();
|
return loadContext.getFullPath();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Object> parentIdList(SpiEbeanServer server) {
|
private List<Object> parentIdList(SpiEbeanServer server) {
|
||||||
List<Object> idList = new ArrayList<>();
|
List<Object> idList = new ArrayList<>();
|
||||||
BeanPropertyAssocMany<?> many = getMany();
|
BeanPropertyAssocMany<?> many = many();
|
||||||
for (BeanCollection<?> bc : batch) {
|
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
|
bc.setLoader(server); // don't use the load buffer again
|
||||||
}
|
}
|
||||||
if (many.getTargetDescriptor().isPadInExpression()) {
|
if (many.targetDescriptor().isPadInExpression()) {
|
||||||
BindPadding.padIds(idList);
|
BindPadding.padIds(idList);
|
||||||
}
|
}
|
||||||
return idList;
|
return idList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BeanPropertyAssocMany<?> getMany() {
|
private BeanPropertyAssocMany<?> many() {
|
||||||
return loadContext.getBeanProperty();
|
return loadContext.getBeanProperty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpiQuery<?> createQuery(SpiEbeanServer server) {
|
public SpiQuery<?> createQuery(SpiEbeanServer server) {
|
||||||
BeanPropertyAssocMany<?> many = getMany();
|
BeanPropertyAssocMany<?> many = many();
|
||||||
SpiQuery<?> query = many.newQuery(server);
|
SpiQuery<?> query = many.newQuery(server);
|
||||||
String orderBy = many.getLazyFetchOrderBy();
|
String orderBy = many.lazyFetchOrderBy();
|
||||||
if (orderBy != null) {
|
if (orderBy != null) {
|
||||||
query.order(orderBy);
|
query.order(orderBy);
|
||||||
}
|
}
|
||||||
|
String extraWhere = many.extraWhere();
|
||||||
String extraWhere = many.getExtraWhere();
|
|
||||||
if (extraWhere != null) {
|
if (extraWhere != null) {
|
||||||
// replace special ${ta} placeholder with the base table alias
|
// replace special ${ta} placeholder with the base table alias
|
||||||
// which is always t0 and add the extra where clause
|
// which is always t0 and add the extra where clause
|
||||||
query.where().raw(extraWhere.replace("${ta}", "t0").replace("${mta}", "int_"));
|
query.where().raw(extraWhere.replace("${ta}", "t0").replace("${mta}", "int_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
query.setLazyLoadForParents(many);
|
query.setLazyLoadForParents(many);
|
||||||
many.addWhereParentIdIn(query, parentIdList(server), loadContext.isUseDocStore());
|
many.addWhereParentIdIn(query, parentIdList(server), loadContext.isUseDocStore());
|
||||||
query.setPersistenceContext(loadContext.getPersistenceContext());
|
query.setPersistenceContext(loadContext.getPersistenceContext());
|
||||||
|
query.setLoadDescription(lazy ? "+lazy" : "+query", description());
|
||||||
String mode = isLazy() ? "+lazy" : "+query";
|
if (lazy) {
|
||||||
query.setLoadDescription(mode, getDescription());
|
query.setLazyLoadBatchSize(loadContext.getBatchSize());
|
||||||
|
} else {
|
||||||
if (isLazy()) {
|
query.setBeanCacheMode(CacheMode.OFF);
|
||||||
// cascade the batch size (if set) for further lazy loading
|
|
||||||
query.setLazyLoadBatchSize(getBatchSize());
|
|
||||||
}
|
}
|
||||||
|
// potentially changes the joins, selected properties, cache mode
|
||||||
// potentially changes the joins and selected properties
|
|
||||||
loadContext.configureQuery(query);
|
loadContext.configureQuery(query);
|
||||||
|
if (onlyIds) {
|
||||||
if (isOnlyIds()) {
|
// lazy loading invoked via clear() and removeAll()
|
||||||
// override to just select the Id values
|
query.select(many.targetIdProperty());
|
||||||
query.select(many.getTargetIdProperty());
|
|
||||||
}
|
}
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
@@ -146,7 +109,7 @@ public final class LoadManyRequest extends LoadRequest {
|
|||||||
*/
|
*/
|
||||||
public void postLoad() {
|
public void postLoad() {
|
||||||
BeanDescriptor<?> desc = loadContext.getBeanDescriptor();
|
BeanDescriptor<?> desc = loadContext.getBeanDescriptor();
|
||||||
BeanPropertyAssocMany<?> many = getMany();
|
BeanPropertyAssocMany<?> many = many();
|
||||||
// check for BeanCollection's that where never processed
|
// check for BeanCollection's that where never processed
|
||||||
// in the +query or +lazy load due to no rows (predicates)
|
// in the +query or +lazy load due to no rows (predicates)
|
||||||
for (BeanCollection<?> bc : batch) {
|
for (BeanCollection<?> bc : batch) {
|
||||||
@@ -156,9 +119,8 @@ public final class LoadManyRequest extends LoadRequest {
|
|||||||
Object parentId = desc.getId(ownerBean);
|
Object parentId = desc.getId(ownerBean);
|
||||||
logger.debug("BeanCollection after lazy load was empty. type:" + ownerBean.getClass().getName() + " id:" + parentId + " owner:" + ownerBean);
|
logger.debug("BeanCollection after lazy load was empty. type:" + ownerBean.getClass().getName() + " id:" + parentId + " owner:" + ownerBean);
|
||||||
}
|
}
|
||||||
} else if (isLoadCache() && many.isUseCache()) {
|
} else if (loadCache && many.isUseCache()) {
|
||||||
Object parentId = desc.getId(bc.getOwnerBean());
|
desc.cacheManyPropPut(many, bc, desc.getId(bc.getOwnerBean()));
|
||||||
desc.cacheManyPropPut(many, bc, parentId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,22 +9,19 @@ import io.ebeaninternal.server.core.OrmQueryRequest;
|
|||||||
public abstract class LoadRequest {
|
public abstract class LoadRequest {
|
||||||
|
|
||||||
protected final OrmQueryRequest<?> parentRequest;
|
protected final OrmQueryRequest<?> parentRequest;
|
||||||
|
|
||||||
protected final Transaction transaction;
|
protected final Transaction transaction;
|
||||||
|
|
||||||
protected final boolean lazy;
|
protected final boolean lazy;
|
||||||
|
|
||||||
public LoadRequest(OrmQueryRequest<?> parentRequest, boolean lazy) {
|
LoadRequest(OrmQueryRequest<?> parentRequest, boolean lazy) {
|
||||||
|
|
||||||
this.parentRequest = parentRequest;
|
this.parentRequest = parentRequest;
|
||||||
this.transaction = parentRequest == null ? null : parentRequest.getTransaction();
|
this.transaction = parentRequest == null ? null : parentRequest.transaction();
|
||||||
this.lazy = lazy;
|
this.lazy = lazy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the associated bean type for this load request.
|
* 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.
|
* 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.
|
* Lazy loading queries run in their own transaction.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public Transaction getTransaction() {
|
public Transaction transaction() {
|
||||||
return transaction;
|
return transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,6 +45,6 @@ public abstract class LoadRequest {
|
|||||||
* So one of - findIterate(), findEach(), findEachWhile() or findVisit().
|
* So one of - findIterate(), findEach(), findEachWhile() or findVisit().
|
||||||
*/
|
*/
|
||||||
public boolean isParentFindIterate() {
|
public boolean isParentFindIterate() {
|
||||||
return parentRequest != null && parentRequest.getQuery().getType() == SpiQuery.Type.ITERATE;
|
return parentRequest != null && parentRequest.query().getType() == SpiQuery.Type.ITERATE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,15 +51,15 @@ public final class ManyWhereJoins implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public void add(ElPropertyDeploy elProp) {
|
public void add(ElPropertyDeploy elProp) {
|
||||||
|
|
||||||
String join = elProp.getElPrefix();
|
String join = elProp.elPrefix();
|
||||||
BeanProperty p = elProp.getBeanProperty();
|
BeanProperty p = elProp.beanProperty();
|
||||||
if (p instanceof BeanPropertyAssocMany<?>) {
|
if (p instanceof BeanPropertyAssocMany<?>) {
|
||||||
join = addManyToJoin(join, p.getName());
|
join = addManyToJoin(join, p.name());
|
||||||
}
|
}
|
||||||
if (join != null) {
|
if (join != null) {
|
||||||
addJoin(join);
|
addJoin(join);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
String secondaryTableJoinPrefix = p.getSecondaryTableJoinPrefix();
|
String secondaryTableJoinPrefix = p.secondaryTableJoinPrefix();
|
||||||
if (secondaryTableJoinPrefix != null) {
|
if (secondaryTableJoinPrefix != null) {
|
||||||
addJoin(join + "." + secondaryTableJoinPrefix);
|
addJoin(join + "." + secondaryTableJoinPrefix);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ public interface SpiBeanTypeManager {
|
|||||||
/**
|
/**
|
||||||
* Return the bean type for the given entity class.
|
* 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();
|
boolean isRelaxedMode();
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the label for the query.
|
|
||||||
*/
|
|
||||||
String getLabel();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the label with fallback to profile location label.
|
* 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.ReadAuditLogger;
|
||||||
import io.ebean.event.readaudit.ReadAuditPrepare;
|
import io.ebean.event.readaudit.ReadAuditPrepare;
|
||||||
import io.ebean.meta.MetricVisitor;
|
import io.ebean.meta.MetricVisitor;
|
||||||
|
import io.ebean.plugin.SpiServer;
|
||||||
import io.ebeaninternal.api.SpiQuery.Type;
|
import io.ebeaninternal.api.SpiQuery.Type;
|
||||||
import io.ebeaninternal.server.core.SpiResultSet;
|
import io.ebeaninternal.server.core.SpiResultSet;
|
||||||
import io.ebeaninternal.server.core.timezone.DataTimeZone;
|
import io.ebeaninternal.server.core.timezone.DataTimeZone;
|
||||||
@@ -23,7 +24,7 @@ import java.util.stream.Stream;
|
|||||||
/**
|
/**
|
||||||
* Service Provider extension to EbeanServer.
|
* 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.
|
* Return true if the L2 cache has been disabled.
|
||||||
@@ -50,16 +51,6 @@ public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollect
|
|||||||
*/
|
*/
|
||||||
Object currentTenantId();
|
Object currentTenantId();
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the server configuration.
|
|
||||||
*/
|
|
||||||
DatabaseConfig getServerConfig();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the DatabasePlatform for this server.
|
|
||||||
*/
|
|
||||||
DatabasePlatform getDatabasePlatform();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an object to represent the current CallStack.
|
* Create an object to represent the current CallStack.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -72,7 +63,7 @@ public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollect
|
|||||||
/**
|
/**
|
||||||
* Return the PersistenceContextScope to use defined at query or server level.
|
* Return the PersistenceContextScope to use defined at query or server level.
|
||||||
*/
|
*/
|
||||||
PersistenceContextScope getPersistenceContextScope(SpiQuery<?> query);
|
PersistenceContextScope persistenceContextScope(SpiQuery<?> query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the query execution statistics.
|
* Clear the query execution statistics.
|
||||||
@@ -82,32 +73,32 @@ public interface SpiEbeanServer extends ExtendedServer, EbeanServer, BeanCollect
|
|||||||
/**
|
/**
|
||||||
* Return the transaction manager.
|
* Return the transaction manager.
|
||||||
*/
|
*/
|
||||||
SpiTransactionManager getTransactionManager();
|
SpiTransactionManager transactionManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all the descriptors.
|
* Return all the descriptors.
|
||||||
*/
|
*/
|
||||||
List<BeanDescriptor<?>> getBeanDescriptors();
|
List<BeanDescriptor<?>> descriptors();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the BeanDescriptor for a given type of bean.
|
* 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.
|
* Return BeanDescriptor using it's unique id.
|
||||||
*/
|
*/
|
||||||
BeanDescriptor<?> getBeanDescriptorById(String className);
|
BeanDescriptor<?> descriptorById(String className);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return BeanDescriptor using it's unique doc store queueId.
|
* Return BeanDescriptor using it's unique doc store queueId.
|
||||||
*/
|
*/
|
||||||
BeanDescriptor<?> getBeanDescriptorByQueueId(String queueId);
|
BeanDescriptor<?> descriptorByQueueId(String queueId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return BeanDescriptors mapped to this table.
|
* Return BeanDescriptors mapped to this table.
|
||||||
*/
|
*/
|
||||||
List<BeanDescriptor<?>> getBeanDescriptors(String tableName);
|
List<BeanDescriptor<?>> descriptors(String tableName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process committed changes from another framework.
|
* 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.
|
* 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
|
* 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.
|
* 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
|
* Return the ReadAuditPrepare used to populate the read audit events with
|
||||||
* user context information (user id, user ip address etc).
|
* user context information (user id, user ip address etc).
|
||||||
*/
|
*/
|
||||||
ReadAuditPrepare getReadAuditPrepare();
|
ReadAuditPrepare readAuditPrepare();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the DataTimeZone to use when reading/writing timestamps via JDBC.
|
* Return the DataTimeZone to use when reading/writing timestamps via JDBC.
|
||||||
*/
|
*/
|
||||||
DataTimeZone getDataTimeZone();
|
DataTimeZone dataTimeZone();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for slow query event.
|
* Check for slow query event.
|
||||||
|
|||||||
@@ -44,8 +44,4 @@ public interface SpiExpressionList<T> extends ExpressionList<T>, SpiExpression {
|
|||||||
// do nothing by default
|
// 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
|
@Override
|
||||||
public Connection getConnection() {
|
public Connection connection() {
|
||||||
return transaction.getConnection();
|
return transaction.connection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public final class TransactionEventTable implements Serializable, BinaryWritable
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void add(TableIUD newTableIUD) {
|
public void add(TableIUD newTableIUD) {
|
||||||
TableIUD existingTableIUD = map.put(newTableIUD.getTableName(), newTableIUD);
|
TableIUD existingTableIUD = map.put(newTableIUD.tableName(), newTableIUD);
|
||||||
if (existingTableIUD != null) {
|
if (existingTableIUD != null) {
|
||||||
newTableIUD.add(existingTableIUD);
|
newTableIUD.add(existingTableIUD);
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ public final class TransactionEventTable implements Serializable, BinaryWritable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTableName() {
|
public String tableName() {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public final class CacheChangeSet {
|
|||||||
* Add an entry to clear a query cache.
|
* Add an entry to clear a query cache.
|
||||||
*/
|
*/
|
||||||
public void addInvalidate(BeanDescriptor<?> descriptor) {
|
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) {
|
public void addClearQuery(BeanDescriptor<?> descriptor) {
|
||||||
queryCaches.add(descriptor);
|
queryCaches.add(descriptor);
|
||||||
touchedTables.add(descriptor.getBaseTable());
|
touchedTables.add(descriptor.baseTable());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -125,7 +125,7 @@ public final class CacheChangeSet {
|
|||||||
entry.addId(id);
|
entry.addId(id);
|
||||||
} else {
|
} else {
|
||||||
beanRemoveMap.put(desc, new CacheChangeBeanRemove(id, desc));
|
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);
|
entry.addIds(ids);
|
||||||
} else {
|
} else {
|
||||||
beanRemoveMap.put(desc, new CacheChangeBeanRemove(desc, ids));
|
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.
|
* Update a bean entry.
|
||||||
*/
|
*/
|
||||||
public <T> void addBeanUpdate(BeanDescriptor<T> desc, String key, Map<String, Object> changes, boolean updateNaturalKey, long version) {
|
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));
|
entries.add(new CacheChangeBeanUpdate(desc, key, changes, updateNaturalKey, version));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -15,33 +15,33 @@ public final class CachedBeanDataFromBean {
|
|||||||
EntityBeanIntercept ebi = bean._ebean_getIntercept();
|
EntityBeanIntercept ebi = bean._ebean_getIntercept();
|
||||||
Map<String, Object> data = new LinkedHashMap<>();
|
Map<String, Object> data = new LinkedHashMap<>();
|
||||||
|
|
||||||
BeanProperty idProperty = desc.getIdProperty();
|
BeanProperty idProperty = desc.idProperty();
|
||||||
if (idProperty != null) {
|
if (idProperty != null) {
|
||||||
int propertyIndex = idProperty.getPropertyIndex();
|
int propertyIndex = idProperty.propertyIndex();
|
||||||
if (ebi.isLoadedProperty(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
|
// extract all the non-many properties
|
||||||
final boolean dirty = ebi.isDirty();
|
final boolean dirty = ebi.isDirty();
|
||||||
for (BeanProperty prop : desc.propertiesNonMany()) {
|
for (BeanProperty prop : desc.propertiesNonMany()) {
|
||||||
if (dirty && ebi.isDirtyProperty(prop.getPropertyIndex())) {
|
if (dirty && ebi.isDirtyProperty(prop.propertyIndex())) {
|
||||||
data.put(prop.getName(), prop.getCacheDataValueOrig(ebi));
|
data.put(prop.name(), prop.getCacheDataValueOrig(ebi));
|
||||||
} else if (ebi.isLoadedProperty(prop.getPropertyIndex())) {
|
} else if (ebi.isLoadedProperty(prop.propertyIndex())) {
|
||||||
data.put(prop.getName(), prop.getCacheDataValue(bean));
|
data.put(prop.name(), prop.getCacheDataValue(bean));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (BeanPropertyAssocMany<?> prop : desc.propertiesMany()) {
|
for (BeanPropertyAssocMany<?> prop : desc.propertiesMany()) {
|
||||||
if (prop.isElementCollection()) {
|
if (prop.isElementCollection()) {
|
||||||
data.put(prop.getName(), prop.getCacheDataValue(bean));
|
data.put(prop.name(), prop.getCacheDataValue(bean));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long version = desc.getVersion(bean);
|
long version = desc.getVersion(bean);
|
||||||
EntityBean sharableBean = createSharableBean(desc, bean, ebi);
|
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) {
|
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
|
// create a readOnly sharable instance by copying the data
|
||||||
EntityBean sharableBean = desc.createEntityBean();
|
EntityBean sharableBean = desc.createEntityBean();
|
||||||
BeanProperty idProp = desc.getIdProperty();
|
BeanProperty idProp = desc.idProperty();
|
||||||
if (idProp != null) {
|
if (idProp != null) {
|
||||||
Object v = idProp.getValue(bean);
|
Object v = idProp.getValue(bean);
|
||||||
idProp.setValue(sharableBean, v);
|
idProp.setValue(sharableBean, v);
|
||||||
|
|||||||
+6
-6
@@ -13,9 +13,9 @@ public final class CachedBeanDataToBean {
|
|||||||
EntityBeanIntercept ebi = bean._ebean_getIntercept();
|
EntityBeanIntercept ebi = bean._ebean_getIntercept();
|
||||||
// any future lazy loading skips L2 bean cache
|
// any future lazy loading skips L2 bean cache
|
||||||
ebi.setLoadedFromCache(true);
|
ebi.setLoadedFromCache(true);
|
||||||
BeanProperty idProperty = desc.getIdProperty();
|
BeanProperty idProperty = desc.idProperty();
|
||||||
if (desc.getInheritInfo() != null) {
|
if (desc.inheritInfo() != null) {
|
||||||
desc = desc.getInheritInfo().readType(bean.getClass()).desc();
|
desc = desc.inheritInfo().readType(bean.getClass()).desc();
|
||||||
}
|
}
|
||||||
if (idProperty != null) {
|
if (idProperty != null) {
|
||||||
// load the id property
|
// 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) {
|
private static void loadProperty(EntityBean bean, CachedBeanData cacheBeanData, EntityBeanIntercept ebi, BeanProperty prop, PersistenceContext context) {
|
||||||
if (cacheBeanData.isLoaded(prop.getName())) {
|
if (cacheBeanData.isLoaded(prop.name())) {
|
||||||
if (!ebi.isLoadedProperty(prop.getPropertyIndex())) {
|
if (!ebi.isLoadedProperty(prop.propertyIndex())) {
|
||||||
Object value = cacheBeanData.getData(prop.getName());
|
Object value = cacheBeanData.getData(prop.name());
|
||||||
prop.setCacheDataValue(bean, value, context);
|
prop.setCacheDataValue(bean, value, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -27,7 +27,7 @@ public final class DefaultCacheAdapter implements ServerCacheManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLocalL2Caching() {
|
public boolean localL2Caching() {
|
||||||
return cacheManager.isLocalL2Caching();
|
return cacheManager.isLocalL2Caching();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,37 +37,37 @@ public final class DefaultCacheAdapter implements ServerCacheManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setEnabledRegions(String regions) {
|
public void enabledRegions(String regions) {
|
||||||
cacheManager.setEnabledRegions(regions);
|
cacheManager.setEnabledRegions(regions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerCacheRegion getRegion(String region) {
|
public ServerCacheRegion region(String region) {
|
||||||
return cacheManager.getRegion(region);
|
return cacheManager.getRegion(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAllRegionsEnabled(boolean enabled) {
|
public void allRegionsEnabled(boolean enabled) {
|
||||||
cacheManager.setAllRegionsEnabled(enabled);
|
cacheManager.setAllRegionsEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerCache getNaturalKeyCache(Class<?> beanType) {
|
public ServerCache naturalKeyCache(Class<?> beanType) {
|
||||||
return cacheManager.getNaturalKeyCache(beanType);
|
return cacheManager.getNaturalKeyCache(beanType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerCache getBeanCache(Class<?> beanType) {
|
public ServerCache beanCache(Class<?> beanType) {
|
||||||
return cacheManager.getBeanCache(beanType);
|
return cacheManager.getBeanCache(beanType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerCache getCollectionIdsCache(Class<?> beanType, String propertyName) {
|
public ServerCache collectionIdsCache(Class<?> beanType, String propertyName) {
|
||||||
return cacheManager.getCollectionIdsCache(beanType, propertyName);
|
return cacheManager.getCollectionIdsCache(beanType, propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerCache getQueryCache(Class<?> beanType) {
|
public ServerCache queryCache(Class<?> beanType) {
|
||||||
return cacheManager.getQueryCache(beanType);
|
return cacheManager.getQueryCache(beanType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -65,17 +65,17 @@ public final class DefaultServerCacheManager implements SpiCacheManager {
|
|||||||
List<String> enabled = new ArrayList<>();
|
List<String> enabled = new ArrayList<>();
|
||||||
|
|
||||||
for (SpiCacheRegion region : regionMap.values()) {
|
for (SpiCacheRegion region : regionMap.values()) {
|
||||||
if (enabledRegionNames.contains(region.getName())) {
|
if (enabledRegionNames.contains(region.name())) {
|
||||||
enabled.add(region.getName());
|
enabled.add(region.name());
|
||||||
if (!region.isEnabled()) {
|
if (!region.isEnabled()) {
|
||||||
region.setEnabled(true);
|
region.setEnabled(true);
|
||||||
log.debug("Cache region[{}] enabled", region.getName());
|
log.debug("Cache region[{}] enabled", region.name());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
disabled.add(region.getName());
|
disabled.add(region.name());
|
||||||
if (region.isEnabled()) {
|
if (region.isEnabled()) {
|
||||||
region.setEnabled(false);
|
region.setEnabled(false);
|
||||||
log.debug("Cache region[{}] disabled", region.getName());
|
log.debug("Cache region[{}] disabled", region.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ public final class DefaultChangeLogListener implements ChangeLogListener, Plugin
|
|||||||
@Override
|
@Override
|
||||||
public void configure(SpiServer server) {
|
public void configure(SpiServer server) {
|
||||||
jsonBuilder = new ChangeJsonBuilder();
|
jsonBuilder = new ChangeJsonBuilder();
|
||||||
Properties properties = server.getServerConfig().getProperties();
|
Properties properties = server.config().getProperties();
|
||||||
if (properties != null) {
|
if (properties != null) {
|
||||||
String bufferSize = properties.getProperty("ebean.changeLog.bufferSize");
|
String bufferSize = properties.getProperty("ebean.changeLog.bufferSize");
|
||||||
if (bufferSize != null) {
|
if (bufferSize != null) {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class ClusterManager implements ServerLookup {
|
|||||||
public void registerServer(EbeanServer server) {
|
public void registerServer(EbeanServer server) {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
serverMap.put(server.getName(), server);
|
serverMap.put(server.name(), server);
|
||||||
if (!started) {
|
if (!started) {
|
||||||
startup();
|
startup();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public abstract class AbstractSqlQueryRequest implements CancelableQuery {
|
|||||||
int firstRow = query.getFirstRow();
|
int firstRow = query.getFirstRow();
|
||||||
int maxRows = query.getMaxRows();
|
int maxRows = query.getMaxRows();
|
||||||
if (firstRow > 0 || maxRows > 0) {
|
if (firstRow > 0 || maxRows > 0) {
|
||||||
return server.getDatabasePlatform().getBasicSqlLimiter().limit(sql, firstRow, maxRows);
|
return server.databasePlatform().getBasicSqlLimiter().limit(sql, firstRow, maxRows);
|
||||||
}
|
}
|
||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,21 +14,13 @@ public abstract class BeanRequest {
|
|||||||
|
|
||||||
static final Logger log = LoggerFactory.getLogger(BeanRequest.class);
|
static final Logger log = LoggerFactory.getLogger(BeanRequest.class);
|
||||||
|
|
||||||
/**
|
protected final SpiEbeanServer server;
|
||||||
* The server processing the request.
|
|
||||||
*/
|
|
||||||
protected final SpiEbeanServer ebeanServer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The transaction this is part of.
|
|
||||||
*/
|
|
||||||
protected SpiTransaction transaction;
|
protected SpiTransaction transaction;
|
||||||
|
|
||||||
protected boolean createdTransaction;
|
protected boolean createdTransaction;
|
||||||
|
|
||||||
public BeanRequest(SpiEbeanServer ebeanServer, SpiTransaction t) {
|
public BeanRequest(SpiEbeanServer server, SpiTransaction transaction) {
|
||||||
this.ebeanServer = ebeanServer;
|
this.server = server;
|
||||||
this.transaction = t;
|
this.transaction = transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,7 +28,6 @@ public abstract class BeanRequest {
|
|||||||
* <p>
|
* <p>
|
||||||
* A transaction may have been passed in or active in the thread local. If
|
* A transaction may have been passed in or active in the thread local. If
|
||||||
* not then create one implicitly to handle the request.
|
* not then create one implicitly to handle the request.
|
||||||
* </p>
|
|
||||||
*
|
*
|
||||||
* @return True if a transaction was set (from current or created).
|
* @return True if a transaction was set (from current or created).
|
||||||
*/
|
*/
|
||||||
@@ -44,10 +35,10 @@ public abstract class BeanRequest {
|
|||||||
if (transaction != null) {
|
if (transaction != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
transaction = ebeanServer.currentServerTransaction();
|
transaction = server.currentServerTransaction();
|
||||||
if (transaction == null || !transaction.isActive()) {
|
if (transaction == null || !transaction.isActive()) {
|
||||||
// create an implicit transaction to execute this query
|
// create an implicit transaction to execute this query
|
||||||
transaction = ebeanServer.beginServerTransaction();
|
transaction = server.beginServerTransaction();
|
||||||
createdTransaction = true;
|
createdTransaction = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -58,7 +49,7 @@ public abstract class BeanRequest {
|
|||||||
*/
|
*/
|
||||||
public void commitTransIfRequired() {
|
public void commitTransIfRequired() {
|
||||||
if (createdTransaction) {
|
if (createdTransaction) {
|
||||||
ebeanServer.commitTransaction();
|
server.commitTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +59,7 @@ public abstract class BeanRequest {
|
|||||||
public void rollbackTransIfRequired() {
|
public void rollbackTransIfRequired() {
|
||||||
if (createdTransaction) {
|
if (createdTransaction) {
|
||||||
try {
|
try {
|
||||||
ebeanServer.endTransaction();
|
server.endTransaction();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Just log this and carry on. A previous exception has been
|
// Just log this and carry on. A previous exception has been
|
||||||
// thrown and if this rollback throws exception it likely means
|
// thrown and if this rollback throws exception it likely means
|
||||||
@@ -83,7 +74,7 @@ public abstract class BeanRequest {
|
|||||||
*/
|
*/
|
||||||
public void clearTransIfRequired() {
|
public void clearTransIfRequired() {
|
||||||
if (createdTransaction) {
|
if (createdTransaction) {
|
||||||
ebeanServer.clearServerTransaction();
|
server.clearServerTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,45 +83,45 @@ public abstract class BeanRequest {
|
|||||||
* BeanController and BeanFinder.
|
* BeanController and BeanFinder.
|
||||||
*/
|
*/
|
||||||
public EbeanServer getEbeanServer() {
|
public EbeanServer getEbeanServer() {
|
||||||
return ebeanServer;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpiEbeanServer getServer() {
|
public SpiEbeanServer server() {
|
||||||
return ebeanServer;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Transaction associated with this request.
|
* Return the Transaction associated with this request.
|
||||||
*/
|
*/
|
||||||
public SpiTransaction getTransaction() {
|
public SpiTransaction transaction() {
|
||||||
return transaction;
|
return transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the transaction to use for this request.
|
* Set the transaction to use for this request.
|
||||||
*/
|
*/
|
||||||
public void setTransaction(SpiTransaction transaction) {
|
public void transaction(SpiTransaction transaction) {
|
||||||
this.transaction = transaction;
|
this.transaction = transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if SQL should be logged for this transaction.
|
* Return true if SQL should be logged for this transaction.
|
||||||
*/
|
*/
|
||||||
public boolean isLogSql() {
|
public boolean logSql() {
|
||||||
return transaction.isLogSql();
|
return transaction.isLogSql();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if SUMMARY information should be logged for this transaction.
|
* Return true if SUMMARY information should be logged for this transaction.
|
||||||
*/
|
*/
|
||||||
public boolean isLogSummary() {
|
public boolean logSummary() {
|
||||||
return transaction.isLogSummary();
|
return transaction.isLogSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the DataTimeZone to use.
|
* Return the DataTimeZone to use.
|
||||||
*/
|
*/
|
||||||
public DataTimeZone getDataTimeZone() {
|
public DataTimeZone dataTimeZone() {
|
||||||
return ebeanServer.getDataTimeZone();
|
return server.dataTimeZone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ final class DScriptRunner implements ScriptRunner {
|
|||||||
|
|
||||||
DScriptRunner(SpiEbeanServer server) {
|
DScriptRunner(SpiEbeanServer server) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.platformName = this.server.getDatabasePlatform().getPlatform().base().name();
|
this.platformName = this.server.platform().base().name();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -102,7 +102,7 @@ final class DScriptRunner implements ScriptRunner {
|
|||||||
|
|
||||||
private Connection obtainConnection() {
|
private Connection obtainConnection() {
|
||||||
try {
|
try {
|
||||||
return server.getDataSource().getConnection();
|
return server.dataSource().getConnection();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new PersistenceException("Failed to obtain connection to run script", e);
|
throw new PersistenceException("Failed to obtain connection to run script", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,19 +35,16 @@ final class DefaultBeanLoader {
|
|||||||
|
|
||||||
DefaultBeanLoader(DefaultServer server) {
|
DefaultBeanLoader(DefaultServer server) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.onIterateUseExtraTxn = server.getDatabasePlatform().useExtraTransactionOnIterateSecondaryQueries();
|
this.onIterateUseExtraTxn = server.databasePlatform().useExtraTransactionOnIterateSecondaryQueries();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadMany(LoadManyRequest loadRequest) {
|
void loadMany(LoadManyRequest loadRequest) {
|
||||||
SpiQuery<?> query = loadRequest.createQuery(server);
|
executeQuery(loadRequest, loadRequest.createQuery(server));
|
||||||
executeQuery(loadRequest, query);
|
|
||||||
loadRequest.postLoad();
|
loadRequest.postLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadMany(BeanCollection<?> bc, boolean onlyIds) {
|
void loadMany(BeanCollection<?> bc, boolean onlyIds) {
|
||||||
EntityBean parentBean = bc.getOwnerBean();
|
loadManyInternal(bc.getOwnerBean(), bc.getPropertyName(), null, false, onlyIds);
|
||||||
String propertyName = bc.getPropertyName();
|
|
||||||
loadManyInternal(parentBean, propertyName, null, false, onlyIds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void refreshMany(EntityBean parentBean, String propertyName) {
|
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) {
|
private void loadManyInternal(EntityBean parentBean, String propertyName, Transaction t, boolean refresh, boolean onlyIds) {
|
||||||
EntityBeanIntercept ebi = parentBean._ebean_getIntercept();
|
EntityBeanIntercept ebi = parentBean._ebean_getIntercept();
|
||||||
PersistenceContext pc = ebi.getPersistenceContext();
|
PersistenceContext pc = ebi.getPersistenceContext();
|
||||||
BeanDescriptor<?> parentDesc = server.getBeanDescriptor(parentBean.getClass());
|
BeanDescriptor<?> parentDesc = server.descriptor(parentBean.getClass());
|
||||||
BeanPropertyAssocMany<?> many = (BeanPropertyAssocMany<?>) parentDesc.getBeanProperty(propertyName);
|
BeanPropertyAssocMany<?> many = (BeanPropertyAssocMany<?>) parentDesc.beanProperty(propertyName);
|
||||||
BeanCollection<?> beanCollection = null;
|
BeanCollection<?> beanCollection = null;
|
||||||
ExpressionList<?> filterMany = null;
|
ExpressionList<?> filterMany = null;
|
||||||
|
|
||||||
@@ -69,12 +66,10 @@ final class DefaultBeanLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Object parentId = parentDesc.getId(parentBean);
|
Object parentId = parentDesc.getId(parentBean);
|
||||||
|
|
||||||
if (pc == null) {
|
if (pc == null) {
|
||||||
pc = new DefaultPersistenceContext();
|
pc = new DefaultPersistenceContext();
|
||||||
parentDesc.contextPut(pc, parentId, parentBean);
|
parentDesc.contextPut(pc, parentId, parentBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean useManyIdCache = beanCollection != null && parentDesc.isManyPropCaching() && many.isUseCache();
|
boolean useManyIdCache = beanCollection != null && parentDesc.isManyPropCaching() && many.isUseCache();
|
||||||
if (useManyIdCache) {
|
if (useManyIdCache) {
|
||||||
Boolean readOnly = null;
|
Boolean readOnly = null;
|
||||||
@@ -86,8 +81,7 @@ final class DefaultBeanLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SpiQuery<?> query = server.createQuery(parentDesc.getBeanType());
|
SpiQuery<?> query = server.createQuery(parentDesc.type());
|
||||||
|
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
// populate a new collection
|
// populate a new collection
|
||||||
BeanCollection<?> emptyCollection = many.createEmpty(parentBean);
|
BeanCollection<?> emptyCollection = many.createEmpty(parentBean);
|
||||||
@@ -97,23 +91,21 @@ final class DefaultBeanLoader {
|
|||||||
query.setLoadDescription("+lazy", null);
|
query.setLoadDescription("+lazy", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
query.select(parentDesc.getIdBinder().getIdProperty());
|
query.select(parentDesc.idBinder().getIdProperty());
|
||||||
|
|
||||||
if (onlyIds) {
|
if (onlyIds) {
|
||||||
query.fetch(many.getName(), many.getTargetIdProperty());
|
query.fetch(many.name(), many.targetIdProperty());
|
||||||
} else {
|
} else {
|
||||||
query.fetch(many.getName());
|
query.fetch(many.name());
|
||||||
}
|
}
|
||||||
if (filterMany != null) {
|
if (filterMany != null) {
|
||||||
query.setFilterMany(many.getName(), filterMany);
|
query.setFilterMany(many.name(), filterMany);
|
||||||
}
|
}
|
||||||
|
|
||||||
query.where().idEq(parentId);
|
query.where().idEq(parentId);
|
||||||
query.setUseCache(false);
|
query.setBeanCacheMode(CacheMode.OFF);
|
||||||
query.setMode(Mode.LAZYLOAD_MANY);
|
query.setMode(Mode.LAZYLOAD_MANY);
|
||||||
query.setLazyLoadManyPath(many.getName());
|
query.setLazyLoadManyPath(many.name());
|
||||||
query.setPersistenceContext(pc);
|
query.setPersistenceContext(pc);
|
||||||
|
|
||||||
if (ebi.isReadOnly()) {
|
if (ebi.isReadOnly()) {
|
||||||
query.setReadOnly(true);
|
query.setReadOnly(true);
|
||||||
}
|
}
|
||||||
@@ -134,7 +126,7 @@ final class DefaultBeanLoader {
|
|||||||
* Load a batch of beans for +query or +lazy loading.
|
* Load a batch of beans for +query or +lazy loading.
|
||||||
*/
|
*/
|
||||||
void loadBean(LoadBeanRequest loadRequest) {
|
void loadBean(LoadBeanRequest loadRequest) {
|
||||||
List<EntityBeanIntercept> batch = loadRequest.getBatch();
|
List<EntityBeanIntercept> batch = loadRequest.batch();
|
||||||
if (batch.isEmpty()) {
|
if (batch.isEmpty()) {
|
||||||
throw new RuntimeException("Nothing in batch?");
|
throw new RuntimeException("Nothing in batch?");
|
||||||
}
|
}
|
||||||
@@ -145,12 +137,8 @@ final class DefaultBeanLoader {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpiQuery<?> query = server.createQuery(loadRequest.getBeanType());
|
SpiQuery<?> query = server.createQuery(loadRequest.beanType());
|
||||||
loadRequest.configureQuery(query, idList);
|
loadRequest.configureQuery(query, idList);
|
||||||
if (loadRequest.isLoadedFromCache()) {
|
|
||||||
query.setBeanCacheMode(CacheMode.PUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<?> list = executeQuery(loadRequest, query);
|
List<?> list = executeQuery(loadRequest, query);
|
||||||
loadRequest.postLoad(list);
|
loadRequest.postLoad(list);
|
||||||
}
|
}
|
||||||
@@ -168,7 +156,7 @@ final class DefaultBeanLoader {
|
|||||||
extraTxn.end();
|
extraTxn.end();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return server.findList(query, loadRequest.getTransaction());
|
return server.findList(query, loadRequest.transaction());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,12 +176,11 @@ final class DefaultBeanLoader {
|
|||||||
pc = null;
|
pc = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
BeanDescriptor<?> desc = server.getBeanDescriptor(bean.getClass());
|
BeanDescriptor<?> desc = server.descriptor(bean.getClass());
|
||||||
if (EntityType.EMBEDDED == desc.getEntityType()) {
|
if (EntityType.EMBEDDED == desc.entityType()) {
|
||||||
// lazy loading on an embedded bean property
|
// lazy loading on an embedded bean property
|
||||||
EntityBean embeddedOwner = (EntityBean) ebi.getEmbeddedOwner();
|
EntityBean embeddedOwner = (EntityBean) ebi.getEmbeddedOwner();
|
||||||
int ownerIndex = ebi.getEmbeddedOwnerIndex();
|
refreshBeanInternal(embeddedOwner, mode, ebi.getEmbeddedOwnerIndex());
|
||||||
refreshBeanInternal(embeddedOwner, mode, ownerIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object id = desc.getId(bean);
|
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());
|
query.setLazyLoadProperty(ebi.getLazyLoadProperty());
|
||||||
if (draft) {
|
if (draft) {
|
||||||
query.asDraft();
|
query.asDraft();
|
||||||
@@ -235,7 +222,7 @@ final class DefaultBeanLoader {
|
|||||||
query.setId(id);
|
query.setId(id);
|
||||||
if (embeddedOwnerIndex > -1 || mode == Mode.REFRESH_BEAN) {
|
if (embeddedOwnerIndex > -1 || mode == Mode.REFRESH_BEAN) {
|
||||||
// make sure the query doesn't use the cache
|
// make sure the query doesn't use the cache
|
||||||
query.setUseCache(false);
|
query.setBeanCacheMode(CacheMode.OFF);
|
||||||
}
|
}
|
||||||
if (ebi.isReadOnly()) {
|
if (ebi.isReadOnly()) {
|
||||||
query.setReadOnly(true);
|
query.setReadOnly(true);
|
||||||
@@ -249,8 +236,7 @@ final class DefaultBeanLoader {
|
|||||||
|
|
||||||
Object dbBean = query.findOne();
|
Object dbBean = query.findOne();
|
||||||
if (dbBean == null) {
|
if (dbBean == null) {
|
||||||
String msg = "Bean not found during lazy load or refresh." + " id[" + id + "] type[" + desc.getBeanType() + "]";
|
throw new EntityNotFoundException("Bean not found during lazy load or refresh." + " id[" + id + "] type[" + desc.type() + "]");
|
||||||
throw new EntityNotFoundException(msg);
|
|
||||||
}
|
}
|
||||||
desc.resetManyProperties(dbBean);
|
desc.resetManyProperties(dbBean);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,17 +45,17 @@ public final class DefaultBeanState implements BeanState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getLoadedProps() {
|
public Set<String> loadedProps() {
|
||||||
return intercept.getLoadedPropertyNames();
|
return intercept.getLoadedPropertyNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getChangedProps() {
|
public Set<String> changedProps() {
|
||||||
return intercept.getDirtyPropertyNames();
|
return intercept.getDirtyPropertyNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ValuePair> getDirtyValues() {
|
public Map<String, ValuePair> dirtyValues() {
|
||||||
return intercept.getDirtyValues();
|
return intercept.getDirtyValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,12 +90,12 @@ public final class DefaultBeanState implements BeanState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Exception> getLoadErrors() {
|
public Map<String, Exception> loadErrors() {
|
||||||
return intercept.getLoadErrors();
|
return intercept.getLoadErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSortOrder() {
|
public int sortOrder() {
|
||||||
return intercept.getSortOrder();
|
return intercept.getSortOrder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package io.ebeaninternal.server.core;
|
package io.ebeaninternal.server.core;
|
||||||
|
|
||||||
import io.ebean.CallableSql;
|
import io.ebean.CallableSql;
|
||||||
import io.ebean.EbeanServer;
|
import io.ebean.Database;
|
||||||
import io.ebeaninternal.api.BindParams;
|
import io.ebeaninternal.api.BindParams;
|
||||||
import io.ebeaninternal.api.BindParams.Param;
|
import io.ebeaninternal.api.BindParams.Param;
|
||||||
import io.ebeaninternal.api.SpiCallableSql;
|
import io.ebeaninternal.api.SpiCallableSql;
|
||||||
@@ -9,39 +9,23 @@ import io.ebeaninternal.api.TransactionEventTable;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.sql.CallableStatement;
|
import java.sql.CallableStatement;
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
|
final class DefaultCallableSql implements Serializable, SpiCallableSql {
|
||||||
public final class DefaultCallableSql implements Serializable, SpiCallableSql {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 8984272253185424701L;
|
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
|
* Holds the table modification information. On commit this information is
|
||||||
* used to manage the cache etc.
|
* used to manage the cache etc.
|
||||||
*/
|
*/
|
||||||
private final TransactionEventTable transactionEvent = new TransactionEventTable();
|
private final TransactionEventTable transactionEvent = new TransactionEventTable();
|
||||||
|
|
||||||
private final BindParams bindParameters = new BindParams();
|
private final BindParams bindParameters = new BindParams();
|
||||||
|
private transient final Database server;
|
||||||
|
private String sql;
|
||||||
|
private String label;
|
||||||
|
private int timeout;
|
||||||
|
|
||||||
/**
|
DefaultCallableSql(Database server, String sql) {
|
||||||
* Create with callable sql.
|
|
||||||
*/
|
|
||||||
public DefaultCallableSql(EbeanServer server, String sql) {
|
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.sql = sql;
|
this.sql = sql;
|
||||||
}
|
}
|
||||||
@@ -108,13 +92,12 @@ public final class DefaultCallableSql implements Serializable, SpiCallableSql {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeOverride(CallableStatement cstmt) throws SQLException {
|
public boolean executeOverride(CallableStatement statement) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CallableSql addModification(String tableName, boolean inserts, boolean updates, boolean deletes) {
|
public CallableSql addModification(String tableName, boolean inserts, boolean updates, boolean deletes) {
|
||||||
|
|
||||||
transactionEvent.add(tableName, inserts, updates, deletes);
|
transactionEvent.add(tableName, inserts, updates, deletes);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -122,7 +105,7 @@ public final class DefaultCallableSql implements Serializable, SpiCallableSql {
|
|||||||
/**
|
/**
|
||||||
* Return the TransactionEvent which holds the table modification
|
* Return the TransactionEvent which holds the table modification
|
||||||
* information for this CallableSql. This information is merged into the
|
* information for this CallableSql. This information is merged into the
|
||||||
* transaction after the transaction is commited.
|
* transaction after the transaction is committed.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TransactionEventTable getTransactionEventTable() {
|
public TransactionEventTable getTransactionEventTable() {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ final class DefaultQueryPlanListener implements QueryPlanListener {
|
|||||||
@Override
|
@Override
|
||||||
public void process(QueryPlanCapture capture) {
|
public void process(QueryPlanCapture capture) {
|
||||||
// better to log this in JSON form?
|
// better to log this in JSON form?
|
||||||
String dbName = capture.getDatabase().getName();
|
String dbName = capture.getDatabase().name();
|
||||||
for (MetaQueryPlan plan : capture.getPlans()) {
|
for (MetaQueryPlan plan : capture.getPlans()) {
|
||||||
log.info("queryPlan db:{} label:{} queryTimeMicros:{} loc:{} sql:{} bind:{} plan:{}",
|
log.info("queryPlan db:{} label:{} queryTimeMicros:{} loc:{} sql:{} bind:{} plan:{}",
|
||||||
dbName, plan.label(), plan.queryTimeMicros(), plan.profileLocation(),
|
dbName, plan.label(), plan.queryTimeMicros(), plan.profileLocation(),
|
||||||
|
|||||||
@@ -129,16 +129,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
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.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
@@ -295,7 +286,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLazyLoadBatchSize() {
|
public int lazyLoadBatchSize() {
|
||||||
return lazyLoadBatchSize;
|
return lazyLoadBatchSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,12 +296,12 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatabaseConfig getServerConfig() {
|
public DatabaseConfig config() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatabasePlatform getDatabasePlatform() {
|
public DatabasePlatform databasePlatform() {
|
||||||
return databasePlatform;
|
return databasePlatform;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,57 +311,57 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataTimeZone getDataTimeZone() {
|
public DataTimeZone dataTimeZone() {
|
||||||
return dataTimeZone;
|
return dataTimeZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MetaInfoManager getMetaInfoManager() {
|
public MetaInfoManager metaInfo() {
|
||||||
return metaInfoManager;
|
return metaInfoManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Platform getPlatform() {
|
public Platform platform() {
|
||||||
return databasePlatform.getPlatform();
|
return databasePlatform.getPlatform();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SpiServer getPluginApi() {
|
public SpiServer pluginApi() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BackgroundExecutor getBackgroundExecutor() {
|
public BackgroundExecutor backgroundExecutor() {
|
||||||
return backgroundExecutor;
|
return backgroundExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExpressionFactory getExpressionFactory() {
|
public ExpressionFactory expressionFactory() {
|
||||||
return expressionFactory;
|
return expressionFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoTune getAutoTune() {
|
public AutoTune autoTune() {
|
||||||
return autoTuneService;
|
return autoTuneService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSource getDataSource() {
|
public DataSource dataSource() {
|
||||||
return transactionManager.getDataSource();
|
return transactionManager.getDataSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSource getReadOnlyDataSource() {
|
public DataSource readOnlyDataSource() {
|
||||||
return transactionManager.getReadOnlyDataSource();
|
return transactionManager.getReadOnlyDataSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReadAuditPrepare getReadAuditPrepare() {
|
public ReadAuditPrepare readAuditPrepare() {
|
||||||
return readAuditPrepare;
|
return readAuditPrepare;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReadAuditLogger getReadAuditLogger() {
|
public ReadAuditLogger readAuditLogger() {
|
||||||
return readAuditLogger;
|
return readAuditLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +372,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
if (encryptKeyManager != null) {
|
if (encryptKeyManager != null) {
|
||||||
encryptKeyManager.initialise();
|
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.
|
* Return the server name.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String name() {
|
||||||
return serverName;
|
return serverName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -519,7 +510,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BeanState getBeanState(Object bean) {
|
public BeanState beanState(Object bean) {
|
||||||
if (bean instanceof EntityBean) {
|
if (bean instanceof EntityBean) {
|
||||||
return new DefaultBeanState((EntityBean) bean);
|
return new DefaultBeanState((EntityBean) bean);
|
||||||
}
|
}
|
||||||
@@ -538,7 +529,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerCacheManager getServerCacheManager() {
|
public ServerCacheManager cacheManager() {
|
||||||
return serverCacheManager;
|
return serverCacheManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -595,7 +586,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
if (a == null) {
|
if (a == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
BeanDescriptor<?> desc = getBeanDescriptor(a.getClass());
|
BeanDescriptor<?> desc = descriptor(a.getClass());
|
||||||
return DiffHelp.diff(a, b, desc);
|
return DiffHelp.diff(a, b, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -628,14 +619,14 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
public void truncate(Class<?>... types) {
|
public void truncate(Class<?>... types) {
|
||||||
List<String> tableNames = new ArrayList<>();
|
List<String> tableNames = new ArrayList<>();
|
||||||
for (Class<?> type : types) {
|
for (Class<?> type : types) {
|
||||||
tableNames.add(getBeanDescriptor(type).getBaseTable());
|
tableNames.add(descriptor(type).baseTable());
|
||||||
}
|
}
|
||||||
truncate(tableNames.toArray(new String[0]));
|
truncate(tableNames.toArray(new String[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void truncate(String... tables) {
|
public void truncate(String... tables) {
|
||||||
try (Connection connection = getDataSource().getConnection()) {
|
try (Connection connection = dataSource().getConnection()) {
|
||||||
for (String table : tables) {
|
for (String table : tables) {
|
||||||
executeSql(connection, databasePlatform.truncateStatement(table));
|
executeSql(connection, databasePlatform.truncateStatement(table));
|
||||||
}
|
}
|
||||||
@@ -659,7 +650,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void clearQueryStatistics() {
|
public void clearQueryStatistics() {
|
||||||
for (BeanDescriptor<?> desc : getBeanDescriptors()) {
|
for (BeanDescriptor<?> desc : descriptors()) {
|
||||||
desc.clearQueryStatistics();
|
desc.clearQueryStatistics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -674,7 +665,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public <T> T createEntityBean(Class<T> type) {
|
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
|
@Override
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
public <T> T getReference(Class<T> type, Object id) {
|
public <T> T reference(Class<T> type, Object id) {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
throw new NullPointerException("The id is null");
|
throw new NullPointerException("The id is null");
|
||||||
}
|
}
|
||||||
BeanDescriptor desc = getBeanDescriptor(type);
|
BeanDescriptor desc = descriptor(type);
|
||||||
id = desc.convertId(id);
|
id = desc.convertId(id);
|
||||||
PersistenceContext pc = null;
|
PersistenceContext pc = null;
|
||||||
SpiTransaction t = transactionManager.getActive();
|
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()) {
|
if (inheritInfo == null || inheritInfo.isConcrete()) {
|
||||||
return (T) desc.contextRef(pc, null, false, id);
|
return (T) desc.contextRef(pc, null, false, id);
|
||||||
}
|
}
|
||||||
BeanProperty idProp = desc.getIdProperty();
|
BeanProperty idProp = desc.idProperty();
|
||||||
if (idProp == null) {
|
if (idProp == null) {
|
||||||
throw new PersistenceException("No ID properties for this type? " + desc);
|
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
|
// 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)
|
// 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
|
@Override
|
||||||
@@ -852,7 +843,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object nextId(Class<?> beanType) {
|
public Object nextId(Class<?> beanType) {
|
||||||
BeanDescriptor<?> desc = getBeanDescriptor(beanType);
|
BeanDescriptor<?> desc = descriptor(beanType);
|
||||||
return desc.nextId(null);
|
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
|
// use first bean in the list as the correct type
|
||||||
Class<T> beanType = (Class<T>) list.get(0).getClass();
|
Class<T> beanType = (Class<T>) list.get(0).getClass();
|
||||||
BeanDescriptor<T> beanDescriptor = getBeanDescriptor(beanType);
|
BeanDescriptor<T> beanDescriptor = descriptor(beanType);
|
||||||
if (beanDescriptor == null) {
|
if (beanDescriptor == null) {
|
||||||
throw new PersistenceException("BeanDescriptor not found, is [" + beanType + "] an entity bean?");
|
throw new PersistenceException("BeanDescriptor not found, is [" + beanType + "] an entity bean?");
|
||||||
}
|
}
|
||||||
@@ -880,7 +871,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> Set<String> validateQuery(Query<T> query) {
|
public <T> Set<String> validateQuery(Query<T> query) {
|
||||||
BeanDescriptor<T> beanDescriptor = getBeanDescriptor(query.getBeanType());
|
BeanDescriptor<T> beanDescriptor = descriptor(query.getBeanType());
|
||||||
if (beanDescriptor == null) {
|
if (beanDescriptor == null) {
|
||||||
throw new PersistenceException("BeanDescriptor not found, is [" + query.getBeanType() + "] an entity bean?");
|
throw new PersistenceException("BeanDescriptor not found, is [" + query.getBeanType() + "] an entity bean?");
|
||||||
}
|
}
|
||||||
@@ -889,7 +880,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> Filter<T> filter(Class<T> beanType) {
|
public <T> Filter<T> filter(Class<T> beanType) {
|
||||||
BeanDescriptor<T> desc = getBeanDescriptor(beanType);
|
BeanDescriptor<T> desc = descriptor(beanType);
|
||||||
if (desc == null) {
|
if (desc == null) {
|
||||||
String m = beanType.getName() + " is NOT an Entity Bean registered with this server?";
|
String m = beanType.getName() + " is NOT an Entity Bean registered with this server?";
|
||||||
throw new PersistenceException(m);
|
throw new PersistenceException(m);
|
||||||
@@ -899,7 +890,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> CsvReader<T> createCsvReader(Class<T> beanType) {
|
public <T> CsvReader<T> createCsvReader(Class<T> beanType) {
|
||||||
BeanDescriptor<T> descriptor = getBeanDescriptor(beanType);
|
BeanDescriptor<T> descriptor = descriptor(beanType);
|
||||||
if (descriptor == null) {
|
if (descriptor == null) {
|
||||||
throw new NullPointerException("BeanDescriptor for " + beanType.getName() + " not found");
|
throw new NullPointerException("BeanDescriptor for " + beanType.getName() + " not found");
|
||||||
}
|
}
|
||||||
@@ -923,13 +914,27 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void merge(Object bean, MergeOptions options, Transaction transaction) {
|
public void merge(Object bean, MergeOptions options, Transaction transaction) {
|
||||||
BeanDescriptor<?> desc = getBeanDescriptor(bean.getClass());
|
BeanDescriptor<?> desc = descriptor(bean.getClass());
|
||||||
if (desc == null) {
|
if (desc == null) {
|
||||||
throw new PersistenceException(bean.getClass().getName() + " is NOT an Entity Bean registered with this server?");
|
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);
|
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
|
@Override
|
||||||
public <T> Query<T> find(Class<T> beanType) {
|
public <T> Query<T> find(Class<T> beanType) {
|
||||||
return createQuery(beanType);
|
return createQuery(beanType);
|
||||||
@@ -937,7 +942,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> Query<T> findNative(Class<T> beanType, String nativeSql) {
|
public <T> Query<T> findNative(Class<T> beanType, String nativeSql) {
|
||||||
BeanDescriptor<T> desc = getBeanDescriptor(beanType);
|
BeanDescriptor<T> desc = descriptor(beanType);
|
||||||
if (desc == null) {
|
if (desc == null) {
|
||||||
throw new PersistenceException(beanType.getName() + " is NOT an Entity Bean registered with this server?");
|
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
|
@Override
|
||||||
public <T> Query<T> createNamedQuery(Class<T> beanType, String namedQuery) {
|
public <T> Query<T> createNamedQuery(Class<T> beanType, String namedQuery) {
|
||||||
BeanDescriptor<T> desc = getBeanDescriptor(beanType);
|
BeanDescriptor<T> desc = descriptor(beanType);
|
||||||
if (desc == null) {
|
if (desc == null) {
|
||||||
throw new PersistenceException(beanType.getName() + " is NOT an Entity Bean registered with this server?");
|
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) {
|
if (named != null) {
|
||||||
return createQuery(beanType, named);
|
return createQuery(beanType, named);
|
||||||
}
|
}
|
||||||
SpiRawSql rawSql = desc.getNamedRawSql(namedQuery);
|
SpiRawSql rawSql = desc.namedRawSql(namedQuery);
|
||||||
if (rawSql != null) {
|
if (rawSql != null) {
|
||||||
DefaultOrmQuery<T> query = createQuery(beanType);
|
DefaultOrmQuery<T> query = createQuery(beanType);
|
||||||
query.setRawSql(rawSql);
|
query.setRawSql(rawSql);
|
||||||
@@ -974,7 +979,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> DefaultOrmQuery<T> createQuery(Class<T> beanType) {
|
public <T> DefaultOrmQuery<T> createQuery(Class<T> beanType) {
|
||||||
BeanDescriptor<T> desc = getBeanDescriptor(beanType);
|
BeanDescriptor<T> desc = descriptor(beanType);
|
||||||
if (desc == null) {
|
if (desc == null) {
|
||||||
throw new PersistenceException(beanType.getName() + " is NOT an Entity Bean registered with this server?");
|
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
|
@Override
|
||||||
public <T> Update<T> createUpdate(Class<T> beanType, String ormUpdate) {
|
public <T> Update<T> createUpdate(Class<T> beanType, String ormUpdate) {
|
||||||
BeanDescriptor<?> desc = getBeanDescriptor(beanType);
|
BeanDescriptor<?> desc = descriptor(beanType);
|
||||||
if (desc == null) {
|
if (desc == null) {
|
||||||
String m = beanType.getName() + " is NOT an Entity Bean registered with this server?";
|
String m = beanType.getName() + " is NOT an Entity Bean registered with this server?";
|
||||||
throw new PersistenceException(m);
|
throw new PersistenceException(m);
|
||||||
}
|
}
|
||||||
return new DefaultOrmUpdate<>(beanType, this, desc.getBaseTable(), ormUpdate);
|
return new DefaultOrmUpdate<>(beanType, this, desc.baseTable(), ormUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1134,14 +1139,14 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
* Return true if transactions PersistenceContext should be used.
|
* Return true if transactions PersistenceContext should be used.
|
||||||
*/
|
*/
|
||||||
private <T> boolean useTransactionPersistenceContext(SpiQuery<T> query) {
|
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.
|
* Return the PersistenceContextScope to use defined at query or server level.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PersistenceContextScope getPersistenceContextScope(SpiQuery<?> query) {
|
public PersistenceContextScope persistenceContextScope(SpiQuery<?> query) {
|
||||||
PersistenceContextScope scope = query.getPersistenceContextScope();
|
PersistenceContextScope scope = query.getPersistenceContextScope();
|
||||||
return (scope != null) ? scope : defaultPersistenceContextScope;
|
return (scope != null) ? scope : defaultPersistenceContextScope;
|
||||||
}
|
}
|
||||||
@@ -1227,7 +1232,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
request.resetBeanCacheAutoMode(false);
|
request.resetBeanCacheAutoMode(false);
|
||||||
if ((t == null || !t.isSkipCache()) && request.getFromBeanCache()) {
|
if ((t == null || !t.isSkipCache()) && request.getFromBeanCache()) {
|
||||||
// hit bean cache and got all results from cache
|
// hit bean cache and got all results from cache
|
||||||
return request.getBeanCacheHitsAsMap();
|
return request.beanCacheHitsAsMap();
|
||||||
}
|
}
|
||||||
Object result = request.getFromQueryCache();
|
Object result = request.getFromQueryCache();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
@@ -1312,7 +1317,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
SpiOrmQueryRequest<?> request = createQueryRequest(Type.ID_LIST, query, t);
|
SpiOrmQueryRequest<?> request = createQueryRequest(Type.ID_LIST, query, t);
|
||||||
Object result = request.getFromQueryCache();
|
Object result = request.getFromQueryCache();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
if (Boolean.FALSE.equals(request.getQuery().isReadOnly())) {
|
if (Boolean.FALSE.equals(request.query().isReadOnly())) {
|
||||||
return new CopyOnFirstWriteList<>((List<A>) result);
|
return new CopyOnFirstWriteList<>((List<A>) result);
|
||||||
} else {
|
} else {
|
||||||
return (List<A>) result;
|
return (List<A>) result;
|
||||||
@@ -1341,7 +1346,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
if (ids.isEmpty()) {
|
if (ids.isEmpty()) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return persister.deleteByIds(request.getBeanDescriptor(), ids, request.getTransaction(), false);
|
return persister.deleteByIds(request.descriptor(), ids, request.transaction(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -1391,7 +1396,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
// FutureList query always run in it's own persistence content
|
// FutureList query always run in it's own persistence content
|
||||||
spiQuery.setPersistenceContext(new DefaultPersistenceContext());
|
spiQuery.setPersistenceContext(new DefaultPersistenceContext());
|
||||||
if (!spiQuery.isDisableReadAudit()) {
|
if (!spiQuery.isDisableReadAudit()) {
|
||||||
BeanDescriptor<T> desc = beanDescriptorManager.getBeanDescriptor(spiQuery.getBeanType());
|
BeanDescriptor<T> desc = beanDescriptorManager.descriptor(spiQuery.getBeanType());
|
||||||
desc.readAuditFutureList(spiQuery);
|
desc.readAuditFutureList(spiQuery);
|
||||||
}
|
}
|
||||||
// Create a new transaction solely to execute the findList() at some future time
|
// 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);
|
request.resetBeanCacheAutoMode(findOne);
|
||||||
if ((t == null || !t.isSkipCache()) && request.getFromBeanCache()) {
|
if ((t == null || !t.isSkipCache()) && request.getFromBeanCache()) {
|
||||||
// hit bean cache and got all results from cache
|
// hit bean cache and got all results from cache
|
||||||
return request.getBeanCacheHits();
|
return request.beanCacheHits();
|
||||||
}
|
}
|
||||||
request.prepareQuery();
|
request.prepareQuery();
|
||||||
Object result = request.getFromQueryCache();
|
Object result = request.getFromQueryCache();
|
||||||
@@ -2048,26 +2053,26 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
* Return all the BeanDescriptors.
|
* Return all the BeanDescriptors.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<BeanDescriptor<?>> getBeanDescriptors() {
|
public List<BeanDescriptor<?>> descriptors() {
|
||||||
return beanDescriptorManager.getBeanDescriptorList();
|
return beanDescriptorManager.descriptorList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the transaction manager.
|
* Return the transaction manager.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SpiTransactionManager getTransactionManager() {
|
public SpiTransactionManager transactionManager() {
|
||||||
return transactionManager;
|
return transactionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(BeanPersistController controller) {
|
public void register(BeanPersistController controller) {
|
||||||
for (BeanDescriptor<?> desc : beanDescriptorManager.getBeanDescriptorList()) {
|
for (BeanDescriptor<?> desc : beanDescriptorManager.descriptorList()) {
|
||||||
desc.register(controller);
|
desc.register(controller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deregister(BeanPersistController c) {
|
public void deregister(BeanPersistController c) {
|
||||||
for (BeanDescriptor<?> desc : beanDescriptorManager.getBeanDescriptorList()) {
|
for (BeanDescriptor<?> desc : beanDescriptorManager.descriptorList()) {
|
||||||
desc.deregister(c);
|
desc.deregister(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2075,13 +2080,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isSupportedType(java.lang.reflect.Type genericType) {
|
public boolean isSupportedType(java.lang.reflect.Type genericType) {
|
||||||
TypeInfo typeInfo = ParamTypeHelper.getTypeInfo(genericType);
|
TypeInfo typeInfo = ParamTypeHelper.getTypeInfo(genericType);
|
||||||
return typeInfo != null && getBeanDescriptor(typeInfo.getBeanType()) != null;
|
return typeInfo != null && descriptor(typeInfo.getBeanType()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object setBeanId(Object bean, Object id) {
|
public Object beanId(Object bean, Object id) {
|
||||||
EntityBean eb = checkEntityBean(bean);
|
EntityBean eb = checkEntityBean(bean);
|
||||||
BeanDescriptor<?> desc = getBeanDescriptor(bean.getClass());
|
BeanDescriptor<?> desc = descriptor(bean.getClass());
|
||||||
if (desc == null) {
|
if (desc == null) {
|
||||||
throw new PersistenceException(bean.getClass().getName() + " is NOT an Entity Bean registered with this server?");
|
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
|
@Override
|
||||||
public Object getBeanId(Object bean) {
|
public Object beanId(Object bean) {
|
||||||
EntityBean eb = checkEntityBean(bean);
|
EntityBean eb = checkEntityBean(bean);
|
||||||
BeanDescriptor<?> desc = getBeanDescriptor(bean.getClass());
|
BeanDescriptor<?> desc = descriptor(bean.getClass());
|
||||||
if (desc == null) {
|
if (desc == null) {
|
||||||
throw new PersistenceException(bean.getClass().getName() + " is NOT an Entity Bean registered with this server?");
|
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.
|
* Return the BeanDescriptor for a given type of bean.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public <T> BeanDescriptor<T> getBeanDescriptor(Class<T> beanClass) {
|
public <T> BeanDescriptor<T> descriptor(Class<T> beanClass) {
|
||||||
return beanDescriptorManager.getBeanDescriptor(beanClass);
|
return beanDescriptorManager.descriptor(beanClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the BeanDescriptor's for a given table name.
|
* Return the BeanDescriptor's for a given table name.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<BeanDescriptor<?>> getBeanDescriptors(String tableName) {
|
public List<BeanDescriptor<?>> descriptors(String tableName) {
|
||||||
return beanDescriptorManager.getBeanDescriptors(tableName);
|
return beanDescriptorManager.descriptors(tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all the SPI BeanTypes.
|
* Return all the SPI BeanTypes.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<? extends BeanType<?>> getBeanTypes() {
|
public List<? extends BeanType<?>> beanTypes() {
|
||||||
return getBeanDescriptors();
|
return descriptors();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the SPI bean types mapped to the given table.
|
* Return the SPI bean types mapped to the given table.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<? extends BeanType<?>> getBeanTypes(String tableName) {
|
public List<? extends BeanType<?>> beanTypes(String tableName) {
|
||||||
return beanDescriptorManager.getBeanTypes(tableName);
|
return beanDescriptorManager.beanTypes(tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BeanType<?> getBeanTypeForQueueId(String queueId) {
|
public BeanType<?> beanTypeForQueueId(String queueId) {
|
||||||
return getBeanDescriptorByQueueId(queueId);
|
return descriptorByQueueId(queueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BeanDescriptor<?> getBeanDescriptorByQueueId(String queueId) {
|
public BeanDescriptor<?> descriptorByQueueId(String queueId) {
|
||||||
return beanDescriptorManager.getBeanDescriptorByQueueId(queueId);
|
return beanDescriptorManager.descriptorByQueueId(queueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the SPI bean types for the given bean class.
|
* Return the SPI bean types for the given bean class.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public <T> BeanType<T> getBeanType(Class<T> beanType) {
|
public <T> BeanType<T> beanType(Class<T> beanType) {
|
||||||
return getBeanDescriptor(beanType);
|
return descriptor(beanType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the BeanDescriptor using its class name.
|
* Return the BeanDescriptor using its class name.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public BeanDescriptor<?> getBeanDescriptorById(String beanClassName) {
|
public BeanDescriptor<?> descriptorById(String beanClassName) {
|
||||||
return beanDescriptorManager.getBeanDescriptorByClassName(beanClassName);
|
return beanDescriptorManager.descriptorByClassName(beanClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2278,13 +2283,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
@Override
|
@Override
|
||||||
public Set<Property> checkUniqueness(Object bean, Transaction transaction) {
|
public Set<Property> checkUniqueness(Object bean, Transaction transaction) {
|
||||||
EntityBean entityBean = checkEntityBean(bean);
|
EntityBean entityBean = checkEntityBean(bean);
|
||||||
BeanDescriptor<?> beanDesc = getBeanDescriptor(entityBean.getClass());
|
BeanDescriptor<?> beanDesc = descriptor(entityBean.getClass());
|
||||||
BeanProperty idProperty = beanDesc.getIdProperty();
|
BeanProperty idProperty = beanDesc.idProperty();
|
||||||
// if the ID of the Property is null we are unable to check uniqueness
|
// if the ID of the Property is null we are unable to check uniqueness
|
||||||
if (idProperty == null) {
|
if (idProperty == null) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
Object id = idProperty.getVal(entityBean);
|
Object id = idProperty.value(entityBean);
|
||||||
if (entityBean._ebean_getIntercept().isNew() && id != null) {
|
if (entityBean._ebean_getIntercept().isNew() && id != null) {
|
||||||
// Primary Key is changeable only on new models - so skip check if we are not new
|
// Primary Key is changeable only on new models - so skip check if we are not new
|
||||||
Query<?> query = new DefaultOrmQuery<>(beanDesc, this, expressionFactory);
|
Query<?> query = new DefaultOrmQuery<>(beanDesc, this, expressionFactory);
|
||||||
@@ -2293,7 +2298,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
return Collections.singleton(idProperty);
|
return Collections.singleton(idProperty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (BeanProperty[] props : beanDesc.getUniqueProps()) {
|
for (BeanProperty[] props : beanDesc.uniqueProps()) {
|
||||||
Set<Property> ret = checkUniqueness(entityBean, beanDesc, props, transaction);
|
Set<Property> ret = checkUniqueness(entityBean, beanDesc, props, transaction);
|
||||||
if (ret != null) {
|
if (ret != null) {
|
||||||
return ret;
|
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).
|
* 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) {
|
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);
|
Query<?> query = new DefaultOrmQuery<>(beanDesc, this, expressionFactory);
|
||||||
ExpressionList<?> exprList = query.where();
|
ExpressionList<?> exprList = query.where();
|
||||||
if (!entityBean._ebean_getIntercept().isNew()) {
|
if (!entityBean._ebean_getIntercept().isNew()) {
|
||||||
// if model is not new, exclude ourself.
|
// 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) {
|
for (Property prop : props) {
|
||||||
Object value = prop.getVal(entityBean);
|
Object value = prop.value(entityBean);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
exprList.eq(prop.getName(), value);
|
exprList.eq(prop.name(), value);
|
||||||
}
|
}
|
||||||
if (findCount(query, transaction) > 0) {
|
if (findCount(query, transaction) > 0) {
|
||||||
Set<Property> ret = new LinkedHashSet<>();
|
Set<Property> ret = new LinkedHashSet<>();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package io.ebeaninternal.server.core;
|
package io.ebeaninternal.server.core;
|
||||||
|
|
||||||
import io.ebean.Ebean;
|
import io.ebean.DB;
|
||||||
import io.ebean.SqlUpdate;
|
import io.ebean.SqlUpdate;
|
||||||
import io.ebean.Update;
|
import io.ebean.Update;
|
||||||
import io.ebeaninternal.api.BindParams;
|
import io.ebeaninternal.api.BindParams;
|
||||||
@@ -143,7 +143,7 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
|
|||||||
return server.execute(this);
|
return server.execute(this);
|
||||||
} else {
|
} else {
|
||||||
// Hopefully this doesn't catch anyone out...
|
// 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);
|
return server.executeBatch(this, transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch() {
|
public void addBatch() {
|
||||||
if (server == null) {
|
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()");
|
throw new IllegalStateException("No current transaction? Must have a transaction to use addBatch()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
batched = true;
|
batched = true;
|
||||||
server.addBatch(this, transaction);
|
server.addBatch(this, transaction);
|
||||||
}
|
}
|
||||||
@@ -287,8 +285,7 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
|
|||||||
return this;
|
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);
|
StringBuilder sqlExpand = new StringBuilder(values.size() * 2);
|
||||||
position = position + bindExpansion;
|
position = position + bindExpansion;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
@@ -310,10 +307,9 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
|
|||||||
String bindLiteral = "?" + position;
|
String bindLiteral = "?" + position;
|
||||||
int pos = baseSql.indexOf(bindLiteral);
|
int pos = baseSql.indexOf(bindLiteral);
|
||||||
if (pos > -1) {
|
if (pos > -1) {
|
||||||
return setParamWithBindExpansion(position, (Collection) value, bindLiteral);
|
return setParamWithBindExpansion(position, (Collection<?>) value, bindLiteral);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bindParams.setParameter(bindExpansion + position, value);
|
bindParams.setParameter(bindExpansion + position, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public final class DtoQueryRequest<T> extends AbstractSqlQueryRequest {
|
|||||||
@Override
|
@Override
|
||||||
protected void setResultSet(ResultSet resultSet, Object queryPlanKey) throws SQLException {
|
protected void setResultSet(ResultSet resultSet, Object queryPlanKey) throws SQLException {
|
||||||
this.resultSet = resultSet;
|
this.resultSet = resultSet;
|
||||||
this.dataReader = new RsetDataReader(server.getDataTimeZone(), resultSet);
|
this.dataReader = new RsetDataReader(server.dataTimeZone(), resultSet);
|
||||||
obtainPlan(queryPlanKey);
|
obtainPlan(queryPlanKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +114,7 @@ public final class DtoQueryRequest<T> extends AbstractSqlQueryRequest {
|
|||||||
return queryEngine.findList(this);
|
return queryEngine.findList(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean next() throws SQLException {
|
public boolean next() throws SQLException {
|
||||||
query.checkCancelled();
|
query.checkCancelled();
|
||||||
return dataReader.next();
|
return dataReader.next();
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ final class DumpMetrics {
|
|||||||
|
|
||||||
void dump() {
|
void dump() {
|
||||||
|
|
||||||
out("-- Dumping metrics for " + server.getName() + " -- ");
|
out("-- Dumping metrics for " + server.name() + " -- ");
|
||||||
ServerMetrics serverMetrics = server.getMetaInfoManager().collectMetrics();
|
ServerMetrics serverMetrics = server.metaInfo().collectMetrics();
|
||||||
|
|
||||||
for (MetaTimedMetric metric : serverMetrics.timedMetrics()) {
|
for (MetaTimedMetric metric : serverMetrics.timedMetrics()) {
|
||||||
log(metric);
|
log(metric);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ final class DumpMetricsData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<MetricData> data() {
|
List<MetricData> data() {
|
||||||
collect(database.getMetaInfoManager().collectMetrics());
|
collect(database.metaInfo().collectMetrics());
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,14 +66,14 @@ final class DumpMetricsJson implements ServerMetricsAsJson {
|
|||||||
@Override
|
@Override
|
||||||
public String json() {
|
public String json() {
|
||||||
writer = new StringWriter();
|
writer = new StringWriter();
|
||||||
collect(database.getMetaInfoManager().collectMetrics());
|
collect(database.metaInfo().collectMetrics());
|
||||||
return writer.toString();
|
return writer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(Appendable buffer) {
|
public void write(Appendable buffer) {
|
||||||
writer = buffer;
|
writer = buffer;
|
||||||
collect(database.getMetaInfoManager().collectMetrics());
|
collect(database.metaInfo().collectMetrics());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collect(ServerMetrics serverMetrics) {
|
private void collect(ServerMetrics serverMetrics) {
|
||||||
@@ -112,7 +112,7 @@ final class DumpMetricsJson implements ServerMetricsAsJson {
|
|||||||
if (withHeader) {
|
if (withHeader) {
|
||||||
objStart();
|
objStart();
|
||||||
key("db");
|
key("db");
|
||||||
val(database.getName());
|
val(database.name());
|
||||||
key("metrics");
|
key("metrics");
|
||||||
listStart();
|
listStart();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public final class InternalConfiguration {
|
|||||||
this.dtoBeanManager = new DtoBeanManager(typeManager, xmlMap.readDtoMapping());
|
this.dtoBeanManager = new DtoBeanManager(typeManager, xmlMap.readDtoMapping());
|
||||||
this.beanDescriptorManager = new BeanDescriptorManager(this);
|
this.beanDescriptorManager = new BeanDescriptorManager(this);
|
||||||
Map<String, String> asOfTableMapping = beanDescriptorManager.deploy(xmlMap.xmlDeployment());
|
Map<String, String> asOfTableMapping = beanDescriptorManager.deploy(xmlMap.xmlDeployment());
|
||||||
Map<String, String> draftTableMap = beanDescriptorManager.getDraftTableMap();
|
Map<String, String> draftTableMap = beanDescriptorManager.draftTableMap();
|
||||||
beanDescriptorManager.scheduleBackgroundTrim();
|
beanDescriptorManager.scheduleBackgroundTrim();
|
||||||
this.dataTimeZone = initDataTimeZone();
|
this.dataTimeZone = initDataTimeZone();
|
||||||
this.binder = getBinder(typeManager, databasePlatform, dataTimeZone);
|
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 static final Logger log = LoggerFactory.getLogger(OrmQueryRequest.class);
|
||||||
|
|
||||||
private final BeanDescriptor<T> beanDescriptor;
|
private final BeanDescriptor<T> beanDescriptor;
|
||||||
|
|
||||||
private final OrmQueryEngine queryEngine;
|
private final OrmQueryEngine queryEngine;
|
||||||
|
|
||||||
private final SpiQuery<T> query;
|
private final SpiQuery<T> query;
|
||||||
|
|
||||||
private final BeanFindController finder;
|
private final BeanFindController finder;
|
||||||
|
|
||||||
private final Boolean readOnly;
|
private final Boolean readOnly;
|
||||||
|
|
||||||
private LoadContext loadContext;
|
private LoadContext loadContext;
|
||||||
|
|
||||||
private PersistenceContext persistenceContext;
|
private PersistenceContext persistenceContext;
|
||||||
|
|
||||||
private JsonReadOptions jsonRead;
|
private JsonReadOptions jsonRead;
|
||||||
|
|
||||||
private HashQuery cacheKey;
|
private HashQuery cacheKey;
|
||||||
|
|
||||||
private CQueryPlanKey queryPlanKey;
|
private CQueryPlanKey queryPlanKey;
|
||||||
|
|
||||||
private SpiQuerySecondary secondaryQueries;
|
private SpiQuerySecondary secondaryQueries;
|
||||||
|
|
||||||
private List<T> cacheBeans;
|
private List<T> cacheBeans;
|
||||||
|
|
||||||
private BeanPropertyAssocMany<?> manyProperty;
|
private BeanPropertyAssocMany<?> manyProperty;
|
||||||
|
|
||||||
private boolean inlineCountDistinct;
|
private boolean inlineCountDistinct;
|
||||||
|
|
||||||
private Set<String> dependentTables;
|
private Set<String> dependentTables;
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the InternalQueryRequest.
|
|
||||||
*/
|
|
||||||
public OrmQueryRequest(SpiEbeanServer server, OrmQueryEngine queryEngine, SpiQuery<T> query, SpiTransaction t) {
|
public OrmQueryRequest(SpiEbeanServer server, OrmQueryEngine queryEngine, SpiQuery<T> query, SpiTransaction t) {
|
||||||
super(server, t);
|
super(server, t);
|
||||||
this.beanDescriptor = query.getBeanDescriptor();
|
this.beanDescriptor = query.getBeanDescriptor();
|
||||||
this.finder = beanDescriptor.getBeanFinder();
|
this.finder = beanDescriptor.beanFinder();
|
||||||
this.queryEngine = queryEngine;
|
this.queryEngine = queryEngine;
|
||||||
this.query = query;
|
this.query = query;
|
||||||
this.readOnly = query.isReadOnly();
|
this.readOnly = query.isReadOnly();
|
||||||
@@ -145,8 +128,8 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
* Return the database platform like clause.
|
* Return the database platform like clause.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDBLikeClause(boolean rawLikeExpression) {
|
public String dbLikeClause(boolean rawLikeExpression) {
|
||||||
return ebeanServer.getDatabasePlatform().getLikeClause(rawLikeExpression);
|
return server.databasePlatform().getLikeClause(rawLikeExpression);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -154,7 +137,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String escapeLikeString(String value) {
|
public String escapeLikeString(String value) {
|
||||||
return ebeanServer.getDatabasePlatform().escapeLikeString(value);
|
return server.databasePlatform().escapeLikeString(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -171,9 +154,8 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
* <p>
|
* <p>
|
||||||
* If -1 is returned then NO secondary queries are registered and simple
|
* If -1 is returned then NO secondary queries are registered and simple
|
||||||
* iteration is fine.
|
* iteration is fine.
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
public int getSecondaryQueriesMinBatchSize() {
|
public int secondaryQueriesMinBatchSize() {
|
||||||
return loadContext.getSecondaryQueriesMinBatchSize();
|
return loadContext.getSecondaryQueriesMinBatchSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,14 +170,14 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
* Return the BeanDescriptor for the associated bean.
|
* Return the BeanDescriptor for the associated bean.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public BeanDescriptor<T> getBeanDescriptor() {
|
public BeanDescriptor<T> descriptor() {
|
||||||
return beanDescriptor;
|
return beanDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the graph context for this query.
|
* Return the graph context for this query.
|
||||||
*/
|
*/
|
||||||
public LoadContext getGraphContext() {
|
public LoadContext loadContext() {
|
||||||
return loadContext;
|
return loadContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +190,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
* Run BeanQueryAdapter preQuery() if needed.
|
* Run BeanQueryAdapter preQuery() if needed.
|
||||||
*/
|
*/
|
||||||
private void adapterPreQuery() {
|
private void adapterPreQuery() {
|
||||||
BeanQueryAdapter queryAdapter = beanDescriptor.getQueryAdapter();
|
BeanQueryAdapter queryAdapter = beanDescriptor.queryAdapter();
|
||||||
if (queryAdapter != null) {
|
if (queryAdapter != null) {
|
||||||
queryAdapter.preQuery(this);
|
queryAdapter.preQuery(this);
|
||||||
}
|
}
|
||||||
@@ -244,7 +226,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
/**
|
/**
|
||||||
* Return the PersistenceContext used for this request.
|
* Return the PersistenceContext used for this request.
|
||||||
*/
|
*/
|
||||||
public PersistenceContext getPersistenceContext() {
|
public PersistenceContext persistenceContext() {
|
||||||
return persistenceContext;
|
return persistenceContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,15 +253,15 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
if (transaction == null) {
|
if (transaction == null) {
|
||||||
if (query.getType().isUpdate()) {
|
if (query.getType().isUpdate()) {
|
||||||
// bulk update or delete query
|
// bulk update or delete query
|
||||||
transaction = ebeanServer.beginServerTransaction();
|
transaction = server.beginServerTransaction();
|
||||||
} else {
|
} else {
|
||||||
// create an implicit transaction to execute this query
|
// create an implicit transaction to execute this query
|
||||||
// potentially using read-only DataSource with autoCommit
|
// potentially using read-only DataSource with autoCommit
|
||||||
transaction = ebeanServer.createReadOnlyTransaction(query.getTenantId());
|
transaction = server.createReadOnlyTransaction(query.getTenantId());
|
||||||
}
|
}
|
||||||
createdTransaction = true;
|
createdTransaction = true;
|
||||||
}
|
}
|
||||||
persistenceContext = getPersistenceContext(query, transaction);
|
persistenceContext = persistenceContext(query, transaction);
|
||||||
loadContext = new DLoadContext(this, secondaryQueries);
|
loadContext = new DLoadContext(this, secondaryQueries);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +287,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public JsonReadOptions createJsonReadOptions() {
|
public JsonReadOptions createJsonReadOptions() {
|
||||||
persistenceContext = getPersistenceContext(query, transaction);
|
persistenceContext = persistenceContext(query, transaction);
|
||||||
if (query.getPersistenceContext() == null) {
|
if (query.getPersistenceContext() == null) {
|
||||||
query.setPersistenceContext(persistenceContext);
|
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
|
* Get the TransactionContext either explicitly set on the query or
|
||||||
* transaction scoped.
|
* 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
|
// check if there is already a persistence context set which is the case
|
||||||
// when lazy loading or query joins are executed
|
// when lazy loading or query joins are executed
|
||||||
PersistenceContext ctx = query.getPersistenceContext();
|
PersistenceContext ctx = query.getPersistenceContext();
|
||||||
if (ctx != null) return ctx;
|
if (ctx != null) return ctx;
|
||||||
|
|
||||||
// determine the scope (from the query and then server)
|
// 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) {
|
if (scope == PersistenceContextScope.QUERY || t == null) {
|
||||||
return new DefaultPersistenceContext();
|
return new DefaultPersistenceContext();
|
||||||
}
|
}
|
||||||
@@ -365,7 +347,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
transaction.commit();
|
transaction.commit();
|
||||||
if (query.getType().isUpdate()) {
|
if (query.getType().isUpdate()) {
|
||||||
// for implicit update/delete queries clear the thread local
|
// 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() {
|
public <K> Map<K, T> findMap() {
|
||||||
String mapKey = query.getMapKey();
|
String mapKey = query.getMapKey();
|
||||||
if (mapKey == null) {
|
if (mapKey == null) {
|
||||||
BeanProperty idProp = beanDescriptor.getIdProperty();
|
BeanProperty idProp = beanDescriptor.idProperty();
|
||||||
if (idProp != null) {
|
if (idProp != null) {
|
||||||
query.setMapKey(idProp.getName());
|
query.setMapKey(idProp.name());
|
||||||
} else {
|
} else {
|
||||||
throw new PersistenceException("No mapKey specified for query");
|
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.
|
* Return a bean specific finder if one has been set.
|
||||||
*/
|
*/
|
||||||
public BeanFindController getBeanFinder() {
|
public BeanFindController finder() {
|
||||||
return finder;
|
return finder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SpiQuery<T> getQuery() {
|
public SpiQuery<T> query() {
|
||||||
return 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.
|
* Determine and return the ToMany property that is included in the query.
|
||||||
*/
|
*/
|
||||||
public BeanPropertyAssocMany<?> determineMany() {
|
public BeanPropertyAssocMany<?> determineMany() {
|
||||||
manyProperty = beanDescriptor.getManyProperty(query);
|
manyProperty = beanDescriptor.manyProperty(query);
|
||||||
return manyProperty;
|
return manyProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the many property that is fetched in the query or null if there is not one.
|
* 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;
|
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
|
* Return a queryPlan for the current query if one exists. Returns null if no
|
||||||
* query plan for this query exists.
|
* query plan for this query exists.
|
||||||
*/
|
*/
|
||||||
public CQueryPlan getQueryPlan() {
|
public CQueryPlan queryPlan() {
|
||||||
return beanDescriptor.getQueryPlan(queryPlanKey);
|
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
|
* 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
|
* matches a SQL statement with ? bind variables. A query plan can be reused
|
||||||
* with just the bind variables changing.
|
* with just the bind variables changing.
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
public CQueryPlanKey getQueryPlanKey() {
|
public CQueryPlanKey queryPlanKey() {
|
||||||
return queryPlanKey;
|
return queryPlanKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,7 +533,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
* Put the QueryPlan into the cache.
|
* Put the QueryPlan into the cache.
|
||||||
*/
|
*/
|
||||||
public void putQueryPlan(CQueryPlan queryPlan) {
|
public void putQueryPlan(CQueryPlan queryPlan) {
|
||||||
beanDescriptor.putQueryPlan(queryPlanKey, queryPlan);
|
beanDescriptor.queryPlan(queryPlanKey, queryPlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -608,7 +589,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> getBeanCacheHits() {
|
public List<T> beanCacheHits() {
|
||||||
OrderBy<T> orderBy = query.getOrderBy();
|
OrderBy<T> orderBy = query.getOrderBy();
|
||||||
if (orderBy != null) {
|
if (orderBy != null) {
|
||||||
beanDescriptor.sort(cacheBeans, orderBy.toStringFormat());
|
beanDescriptor.sort(cacheBeans, orderBy.toStringFormat());
|
||||||
@@ -617,7 +598,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <K> Map<K, T> getBeanCacheHitsAsMap() {
|
public <K> Map<K, T> beanCacheHitsAsMap() {
|
||||||
OrderBy<T> orderBy = query.getOrderBy();
|
OrderBy<T> orderBy = query.getOrderBy();
|
||||||
if (orderBy != null) {
|
if (orderBy != null) {
|
||||||
beanDescriptor.sort(cacheBeans, orderBy.toStringFormat());
|
beanDescriptor.sort(cacheBeans, orderBy.toStringFormat());
|
||||||
@@ -636,7 +617,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ElPropertyValue mapProperty() {
|
private ElPropertyValue mapProperty() {
|
||||||
ElPropertyValue property = beanDescriptor.getElGetValue(query.getMapKey());
|
ElPropertyValue property = beanDescriptor.elGetValue(query.getMapKey());
|
||||||
if (property == null) {
|
if (property == null) {
|
||||||
throw new IllegalStateException("Unknown map key property "+query.getMapKey());
|
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()) {
|
if (!beanDescriptor.isNaturalKeyCaching()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
NaturalKeyQueryData<T> data = query.naturalKey();
|
NaturalKeyQueryData<T> data = query.naturalKey();
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
NaturalKeySet naturalKeySet = data.buildKeys();
|
NaturalKeySet naturalKeySet = data.buildKeys();
|
||||||
@@ -688,30 +668,27 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
public Object getFromQueryCache() {
|
public Object getFromQueryCache() {
|
||||||
if (query.getUseQueryCache() == CacheMode.OFF
|
if (query.getUseQueryCache() == CacheMode.OFF
|
||||||
|| (transaction != null && transaction.isSkipCache())
|
|| (transaction != null && transaction.isSkipCache())
|
||||||
|| ebeanServer.isDisableL2Cache()) {
|
|| server.isDisableL2Cache()) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
cacheKey = query.queryHash();
|
cacheKey = query.queryHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!query.getUseQueryCache().isGet()) {
|
if (!query.getUseQueryCache().isGet()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object cached = beanDescriptor.queryCacheGet(cacheKey);
|
Object cached = beanDescriptor.queryCacheGet(cacheKey);
|
||||||
|
|
||||||
if (cached != null && isAuditReads() && readAuditQueryType()) {
|
if (cached != null && isAuditReads() && readAuditQueryType()) {
|
||||||
if (cached instanceof BeanCollection) {
|
if (cached instanceof BeanCollection) {
|
||||||
// raw sql can't use L2 cache so normal queries only in here
|
// raw sql can't use L2 cache so normal queries only in here
|
||||||
Collection<T> actualDetails = ((BeanCollection<T>)cached).getActualDetails();
|
Collection<T> actualDetails = ((BeanCollection<T>)cached).getActualDetails();
|
||||||
List<Object> ids = new ArrayList<>(actualDetails.size());
|
List<Object> ids = new ArrayList<>(actualDetails.size());
|
||||||
for (T bean : actualDetails) {
|
for (T bean : actualDetails) {
|
||||||
ids.add(beanDescriptor.getIdForJson(bean));
|
ids.add(beanDescriptor.idForJson(bean));
|
||||||
}
|
}
|
||||||
beanDescriptor.readAuditMany(queryPlanKey.getPartialKey(), "l2-query-cache", ids);
|
beanDescriptor.readAuditMany(queryPlanKey.getPartialKey(), "l2-query-cache", ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Boolean.FALSE.equals(query.isReadOnly())) {
|
if (Boolean.FALSE.equals(query.isReadOnly())) {
|
||||||
// return shallow copies if readonly is explicitly set to false
|
// return shallow copies if readonly is explicitly set to false
|
||||||
if (cached instanceof BeanCollection) {
|
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) {
|
public void setCancelableQuery(CancelableQuery cancelableQuery) {
|
||||||
query.setCancelableQuery(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.
|
* Return the batch size for lazy loading on this bean query request.
|
||||||
*/
|
*/
|
||||||
public int getLazyLoadBatchSize() {
|
public int lazyLoadBatchSize() {
|
||||||
int batchSize = query.getLazyLoadBatchSize();
|
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.
|
* Return true if read auditing is on for this query request.
|
||||||
* <p>
|
* <p>
|
||||||
* This means that read audit is on for this bean type and that query has not explicitly disabled it.
|
* This means that read audit is on for this bean type and that query has not explicitly disabled it.
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
public boolean isAuditReads() {
|
public boolean isAuditReads() {
|
||||||
return beanDescriptor.isReadAuditing() && !query.isDisableReadAudit();
|
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.
|
* Return the base table alias for this query.
|
||||||
*/
|
*/
|
||||||
public String getBaseTableAlias() {
|
public String baseTableAlias() {
|
||||||
return query.getAlias(beanDescriptor.getBaseTableAlias());
|
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.
|
* Return the tenantId associated with this request.
|
||||||
*/
|
*/
|
||||||
public Object getTenantId() {
|
public Object tenantId() {
|
||||||
return (transaction == null) ? null : transaction.getTenantId();
|
return (transaction == null) ? null : transaction.getTenantId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -806,7 +782,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
* Check for slow query event.
|
* Check for slow query event.
|
||||||
*/
|
*/
|
||||||
public void slowQueryCheck(long executionTimeMicros, int rowCount) {
|
public void slowQueryCheck(long executionTimeMicros, int rowCount) {
|
||||||
ebeanServer.slowQueryCheck(executionTimeMicros, rowCount, query);
|
server.slowQueryCheck(executionTimeMicros, rowCount, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInlineCountDistinct() {
|
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.
|
* Return true if no MaxRows or use LIMIT in SQL update.
|
||||||
*/
|
*/
|
||||||
public boolean isInlineSqlUpdateLimit() {
|
public boolean isInlineSqlUpdateLimit() {
|
||||||
return query.getMaxRows() < 1 || ebeanServer.getDatabasePlatform().isInlineSqlUpdateLimit();
|
return query.getMaxRows() < 1 || server.databasePlatform().isInlineSqlUpdateLimit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -35,13 +35,13 @@ public final class PersistDeferredRelationship {
|
|||||||
*/
|
*/
|
||||||
public void execute(SpiTransaction transaction) {
|
public void execute(SpiTransaction transaction) {
|
||||||
|
|
||||||
String sql = beanDescriptor.getUpdateImportedIdSql(importedId);
|
String sql = beanDescriptor.updateImportedIdSql(importedId);
|
||||||
SqlUpdate sqlUpdate = ebeanServer.sqlUpdate(sql);
|
SqlUpdate sqlUpdate = ebeanServer.sqlUpdate(sql);
|
||||||
|
|
||||||
// bind the set clause for the importedId
|
// bind the set clause for the importedId
|
||||||
int pos = importedId.bind(1, sqlUpdate, assocBean);
|
int pos = importedId.bind(1, sqlUpdate, assocBean);
|
||||||
// bind the where clause for the bean
|
// 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++) {
|
for (int j = 0; j < idValues.length; j++) {
|
||||||
sqlUpdate.setParameter(pos + j, idValues[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;
|
protected Type type;
|
||||||
|
boolean persistCascade;
|
||||||
final PersistExecute persistExecute;
|
final PersistExecute persistExecute;
|
||||||
|
|
||||||
protected String label;
|
protected String label;
|
||||||
|
|
||||||
protected long startNanos;
|
protected long startNanos;
|
||||||
|
|
||||||
PersistRequest(SpiEbeanServer server, SpiTransaction t, PersistExecute persistExecute) {
|
PersistRequest(SpiEbeanServer server, SpiTransaction t, PersistExecute persistExecute) {
|
||||||
@@ -95,12 +88,12 @@ public abstract class PersistRequest extends BeanRequest implements BatchPostExe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLogSql() {
|
public boolean logSql() {
|
||||||
return transaction.isLogSql();
|
return transaction.isLogSql();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLogSummary() {
|
public boolean logSummary() {
|
||||||
return transaction.isLogSummary();
|
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
|
* Return the type of this request. One of INSERT, UPDATE, DELETE, UPDATESQL or CALLABLESQL.
|
||||||
* or CALLABLESQL.
|
|
||||||
*/
|
*/
|
||||||
public Type getType() {
|
public Type type() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,142 +50,94 @@ import java.util.Set;
|
|||||||
public final class PersistRequestBean<T> extends PersistRequest implements BeanPersistRequest<T>, DocStoreUpdate, PreGetterCallback, SpiProfileTransactionEvent {
|
public final class PersistRequestBean<T> extends PersistRequest implements BeanPersistRequest<T>, DocStoreUpdate, PreGetterCallback, SpiProfileTransactionEvent {
|
||||||
|
|
||||||
private final BeanManager<T> beanManager;
|
private final BeanManager<T> beanManager;
|
||||||
|
|
||||||
private final BeanDescriptor<T> beanDescriptor;
|
private final BeanDescriptor<T> beanDescriptor;
|
||||||
|
|
||||||
private final BeanPersistListener beanPersistListener;
|
private final BeanPersistListener beanPersistListener;
|
||||||
|
|
||||||
/**
|
|
||||||
* For per post insert update delete control.
|
|
||||||
*/
|
|
||||||
private final BeanPersistController controller;
|
private final BeanPersistController controller;
|
||||||
|
|
||||||
/**
|
|
||||||
* The bean being persisted.
|
|
||||||
*/
|
|
||||||
private final T bean;
|
private final T bean;
|
||||||
|
|
||||||
private final EntityBean entityBean;
|
private final EntityBean entityBean;
|
||||||
|
|
||||||
/**
|
|
||||||
* The associated intercept.
|
|
||||||
*/
|
|
||||||
private final EntityBeanIntercept intercept;
|
private final EntityBeanIntercept intercept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parent bean for unidirectional save.
|
* The parent bean for unidirectional save.
|
||||||
*/
|
*/
|
||||||
private final Object parentBean;
|
private final Object parentBean;
|
||||||
|
|
||||||
private final boolean dirty;
|
private final boolean dirty;
|
||||||
|
|
||||||
private final boolean publish;
|
private final boolean publish;
|
||||||
|
|
||||||
private int flags;
|
private int flags;
|
||||||
|
|
||||||
private boolean saveRecurse;
|
private boolean saveRecurse;
|
||||||
|
|
||||||
private DocStoreMode docStoreMode;
|
private DocStoreMode docStoreMode;
|
||||||
|
|
||||||
private final ConcurrencyMode concurrencyMode;
|
private final ConcurrencyMode concurrencyMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The unique id used for logging summary.
|
* The unique id used for logging summary.
|
||||||
*/
|
*/
|
||||||
private Object idValue;
|
private Object idValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash value used to handle cascade delete both ways in a relationship.
|
* Hash value used to handle cascade delete both ways in a relationship.
|
||||||
*/
|
*/
|
||||||
private Integer beanHash;
|
private Integer beanHash;
|
||||||
|
|
||||||
/**
|
|
||||||
* Flag set if this is a stateless update.
|
|
||||||
*/
|
|
||||||
private boolean statelessUpdate;
|
private boolean statelessUpdate;
|
||||||
|
|
||||||
private boolean notifyCache;
|
private boolean notifyCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag used to detect when only many properties where updated via a cascade. Used to ensure
|
* Flag used to detect when only many properties where updated via a cascade. Used to ensure
|
||||||
* appropriate caches are updated in that case.
|
* appropriate caches are updated in that case.
|
||||||
*/
|
*/
|
||||||
private boolean updatedManysOnly;
|
private boolean updatedManysOnly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Element collection change as part of bean cache.
|
* Element collection change as part of bean cache.
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> collectionChanges;
|
private Map<String, Object> collectionChanges;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set true when the request includes cascade save to a many.
|
* Set true when the request includes cascade save to a many.
|
||||||
*/
|
*/
|
||||||
private boolean updatedMany;
|
private boolean updatedMany;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Many properties that were cascade saved (and hence might need caches updated later).
|
* Many properties that were cascade saved (and hence might need caches updated later).
|
||||||
*/
|
*/
|
||||||
private List<BeanPropertyAssocMany<?>> updatedManys;
|
private List<BeanPropertyAssocMany<?>> updatedManys;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Need to get and store the updated properties because the persist listener is notified
|
* 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.
|
* later on a different thread and the bean has been reset at that point.
|
||||||
*/
|
*/
|
||||||
private Set<String> updatedProperties;
|
private Set<String> updatedProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flags indicating the dirty properties on the bean.
|
* Flags indicating the dirty properties on the bean.
|
||||||
*/
|
*/
|
||||||
private boolean[] dirtyProperties;
|
private boolean[] dirtyProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Imported OneToOne orphan that needs to be deleted.
|
* Imported OneToOne orphan that needs to be deleted.
|
||||||
*/
|
*/
|
||||||
private EntityBean orphanBean;
|
private EntityBean orphanBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag set when request is added to JDBC batch.
|
* Flag set when request is added to JDBC batch.
|
||||||
*/
|
*/
|
||||||
private boolean batched;
|
private boolean batched;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag set when batchOnCascade to avoid using batch on the top bean.
|
* Flag set when batchOnCascade to avoid using batch on the top bean.
|
||||||
*/
|
*/
|
||||||
private boolean skipBatchForTopLevel;
|
private boolean skipBatchForTopLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag set when batch mode is turned on for a persist cascade.
|
* Flag set when batch mode is turned on for a persist cascade.
|
||||||
*/
|
*/
|
||||||
private boolean batchOnCascadeSet;
|
private boolean batchOnCascadeSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set for updates to determine if all loaded properties are included in the update.
|
* Set for updates to determine if all loaded properties are included in the update.
|
||||||
*/
|
*/
|
||||||
private boolean requestUpdateAllLoadedProps;
|
private boolean requestUpdateAllLoadedProps;
|
||||||
|
|
||||||
private long version;
|
private long version;
|
||||||
|
|
||||||
private long now;
|
private long now;
|
||||||
|
|
||||||
private long profileOffset;
|
private long profileOffset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag set when request is added to JDBC batch registered as a "getter callback" to automatically flush batch.
|
* Flag set when request is added to JDBC batch registered as a "getter callback" to automatically flush batch.
|
||||||
*/
|
*/
|
||||||
private boolean getterCallback;
|
private boolean getterCallback;
|
||||||
|
|
||||||
private boolean pendingPostUpdateNotify;
|
private boolean pendingPostUpdateNotify;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to true when post execute has occurred (so includes batch flush).
|
* Set to true when post execute has occurred (so includes batch flush).
|
||||||
*/
|
*/
|
||||||
private boolean postExecute;
|
private boolean postExecute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to true after many properties have been persisted (so includes element collections).
|
* Set to true after many properties have been persisted (so includes element collections).
|
||||||
*/
|
*/
|
||||||
private boolean complete;
|
private boolean complete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Many to many intersection table changes that are held for later batch processing.
|
* 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.intercept = entityBean._ebean_getIntercept();
|
||||||
this.beanManager = mgr;
|
this.beanManager = mgr;
|
||||||
this.beanDescriptor = mgr.getBeanDescriptor();
|
this.beanDescriptor = mgr.getBeanDescriptor();
|
||||||
this.beanPersistListener = beanDescriptor.getPersistListener();
|
this.beanPersistListener = beanDescriptor.persistListener();
|
||||||
this.bean = bean;
|
this.bean = bean;
|
||||||
this.parentBean = parentBean;
|
this.parentBean = parentBean;
|
||||||
this.controller = beanDescriptor.getPersistController();
|
this.controller = beanDescriptor.persistController();
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.docStoreMode = calcDocStoreMode(transaction, type);
|
this.docStoreMode = calcDocStoreMode(transaction, type);
|
||||||
this.flags = flags;
|
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
|
// Mark Mutable scalar properties (like Hstore) as dirty where necessary
|
||||||
beanDescriptor.checkMutableProperties(intercept);
|
beanDescriptor.checkMutableProperties(intercept);
|
||||||
}
|
}
|
||||||
this.concurrencyMode = beanDescriptor.getConcurrencyMode(intercept);
|
this.concurrencyMode = beanDescriptor.concurrencyMode(intercept);
|
||||||
this.publish = Flags.isPublish(flags);
|
this.publish = Flags.isPublish(flags);
|
||||||
if (isMarkDraftDirty(publish)) {
|
if (isMarkDraftDirty(publish)) {
|
||||||
beanDescriptor.setDraftDirty(entityBean, true);
|
beanDescriptor.setDraftDirty(entityBean, true);
|
||||||
@@ -247,7 +199,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void profile(long offset, int flushCount) {
|
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) {
|
private DocStoreMode calcDocStoreMode(SpiTransaction txn, Type type) {
|
||||||
DocStoreMode txnMode = (txn == null) ? null : txn.getDocStoreMode();
|
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() {
|
private void onUpdateGeneratedProperties() {
|
||||||
for (BeanProperty prop : beanDescriptor.propertiesGenUpdate()) {
|
for (BeanProperty prop : beanDescriptor.propertiesGenUpdate()) {
|
||||||
GeneratedProperty generatedProperty = prop.getGeneratedProperty();
|
GeneratedProperty generatedProperty = prop.generatedProperty();
|
||||||
if (prop.isVersion()) {
|
if (prop.isVersion()) {
|
||||||
if (isLoadedProperty(prop)) {
|
if (isLoadedProperty(prop)) {
|
||||||
// @Version property must be loaded to be involved
|
// @Version property must be loaded to be involved
|
||||||
Object value = generatedProperty.getUpdateValue(prop, entityBean, now());
|
Object value = generatedProperty.getUpdateValue(prop, entityBean, now());
|
||||||
Object oldVal = prop.getValue(entityBean);
|
Object oldVal = prop.getValue(entityBean);
|
||||||
setVersionValue(value);
|
setVersionValue(value);
|
||||||
intercept.setOldValue(prop.getPropertyIndex(), oldVal);
|
intercept.setOldValue(prop.propertyIndex(), oldVal);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// @WhenModified set without invoking interception
|
// @WhenModified set without invoking interception
|
||||||
Object oldVal = prop.getValue(entityBean);
|
Object oldVal = prop.getValue(entityBean);
|
||||||
Object value = generatedProperty.getUpdateValue(prop, entityBean, now());
|
Object value = generatedProperty.getUpdateValue(prop, entityBean, now());
|
||||||
prop.setValueChanged(entityBean, value);
|
prop.setValueChanged(entityBean, value);
|
||||||
intercept.setOldValue(prop.getPropertyIndex(), oldVal);
|
intercept.setOldValue(prop.propertyIndex(), oldVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onInsertGeneratedProperties() {
|
private void onInsertGeneratedProperties() {
|
||||||
for (BeanProperty prop : beanDescriptor.propertiesGenInsert()) {
|
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);
|
prop.setValueChanged(entityBean, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -424,12 +376,12 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getLoadedProperties() {
|
public Set<String> loadedProperties() {
|
||||||
return intercept.getLoadedPropertyNames();
|
return intercept.getLoadedPropertyNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getUpdatedProperties() {
|
public Set<String> updatedProperties() {
|
||||||
return intercept.getDirtyPropertyNames();
|
return intercept.getDirtyPropertyNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,7 +389,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
* Return the dirty properties on this request.
|
* Return the dirty properties on this request.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean[] getDirtyProperties() {
|
public boolean[] dirtyProperties() {
|
||||||
return dirtyProperties;
|
return dirtyProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,7 +414,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ValuePair> getUpdatedValues() {
|
public Map<String, ValuePair> updatedValues() {
|
||||||
return intercept.getDirtyValues();
|
return intercept.getDirtyValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,10 +495,10 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
case INSERT:
|
case INSERT:
|
||||||
case UPDATE:
|
case UPDATE:
|
||||||
case DELETE_SOFT:
|
case DELETE_SOFT:
|
||||||
docStoreUpdates.queueIndex(beanDescriptor.getDocStoreQueueId(), idValue);
|
docStoreUpdates.queueIndex(beanDescriptor.docStoreQueueId(), idValue);
|
||||||
break;
|
break;
|
||||||
case DELETE:
|
case DELETE:
|
||||||
docStoreUpdates.queueDelete(beanDescriptor.getDocStoreQueueId(), idValue);
|
docStoreUpdates.queueDelete(beanDescriptor.docStoreQueueId(), idValue);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Invalid type " + type);
|
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
|
* Return true if this bean has been already been persisted (inserted or updated) in this transaction.
|
||||||
* transaction.
|
|
||||||
*/
|
*/
|
||||||
public boolean isRegisteredBean() {
|
public boolean isRegisteredBean() {
|
||||||
return transaction.isRegisteredBean(bean);
|
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.
|
* The hash used to register the bean with the transaction.
|
||||||
* <p>
|
* <p>
|
||||||
* Takes into account the class type and id value.
|
* Takes into account the class type and id value.
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
private Integer getBeanHash() {
|
private Integer getBeanHash() {
|
||||||
if (beanHash == null) {
|
if (beanHash == null) {
|
||||||
@@ -631,7 +581,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
/**
|
/**
|
||||||
* Return the BeanDescriptor for the associated bean.
|
* Return the BeanDescriptor for the associated bean.
|
||||||
*/
|
*/
|
||||||
public BeanDescriptor<T> getBeanDescriptor() {
|
public BeanDescriptor<T> descriptor() {
|
||||||
return beanDescriptor;
|
return beanDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,7 +606,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
/**
|
/**
|
||||||
* Return the concurrency mode used for this persist.
|
* Return the concurrency mode used for this persist.
|
||||||
*/
|
*/
|
||||||
public ConcurrencyMode getConcurrencyMode() {
|
public ConcurrencyMode concurrencyMode() {
|
||||||
return 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.
|
* Used to determine common persist requests for queueing and statement batching.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public String getFullName() {
|
public String fullName() {
|
||||||
return beanDescriptor.getFullName();
|
return beanDescriptor.fullName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the bean associated with this request.
|
* Return the bean associated with this request.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public T getBean() {
|
public T bean() {
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityBean getEntityBean() {
|
public EntityBean entityBean() {
|
||||||
return entityBean;
|
return entityBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Id value for the bean.
|
* Return the Id value for the bean.
|
||||||
*/
|
*/
|
||||||
public Object getBeanId() {
|
public Object beanId() {
|
||||||
return beanDescriptor.getId(entityBean);
|
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.
|
* Create and return a new reference bean matching this beans Id value.
|
||||||
*/
|
*/
|
||||||
public T createReference() {
|
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.
|
* Return the parent bean for cascading save with unidirectional relationship.
|
||||||
*/
|
*/
|
||||||
public Object getParentBean() {
|
public Object parentBean() {
|
||||||
return parentBean;
|
return parentBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the intercept if there is one.
|
* Return the intercept if there is one.
|
||||||
*/
|
*/
|
||||||
public EntityBeanIntercept getEntityBeanIntercept() {
|
public EntityBeanIntercept intercept() {
|
||||||
return 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).
|
* Return true if this property is loaded (full bean or included in partial bean).
|
||||||
*/
|
*/
|
||||||
public boolean isLoadedProperty(BeanProperty prop) {
|
public boolean isLoadedProperty(BeanProperty prop) {
|
||||||
return intercept.isLoadedProperty(prop.getPropertyIndex());
|
return intercept.isLoadedProperty(prop.propertyIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the property is dirty.
|
* Return true if the property is dirty.
|
||||||
*/
|
*/
|
||||||
public boolean isDirtyProperty(BeanProperty prop) {
|
public boolean isDirtyProperty(BeanProperty prop) {
|
||||||
return intercept.isDirtyProperty(prop.getPropertyIndex());
|
return intercept.isDirtyProperty(prop.propertyIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the original / old value for the given property.
|
* Return the original / old value for the given property.
|
||||||
*/
|
*/
|
||||||
public Object getOrigValue(BeanProperty prop) {
|
public Object getOrigValue(BeanProperty prop) {
|
||||||
return intercept.getOrigValue(prop.getPropertyIndex());
|
return intercept.getOrigValue(prop.propertyIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -783,7 +733,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
case UPDATE:
|
case UPDATE:
|
||||||
if (beanPersistListener != null) {
|
if (beanPersistListener != null) {
|
||||||
// store the updated properties for sending later
|
// store the updated properties for sending later
|
||||||
updatedProperties = getUpdatedProperties();
|
updatedProperties = updatedProperties();
|
||||||
}
|
}
|
||||||
executeUpdate();
|
executeUpdate();
|
||||||
return -1;
|
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.
|
* Soft delete is executed as update so we want to set deleted=true property.
|
||||||
*/
|
*/
|
||||||
private void prepareForSoftDelete() {
|
private void prepareForSoftDelete() {
|
||||||
beanDescriptor.setSoftDeleteValue(entityBean);
|
beanDescriptor.softDeleteValue(entityBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -854,7 +804,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
* Check for optimistic concurrency exception.
|
* Check for optimistic concurrency exception.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void checkRowCount(int rowCount) {
|
public void checkRowCount(int rowCount) {
|
||||||
if (rowCount != 1 && rowCount != Statement.SUCCESS_NO_INFO) {
|
if (rowCount != 1 && rowCount != Statement.SUCCESS_NO_INFO) {
|
||||||
if (ConcurrencyMode.VERSION == concurrencyMode) {
|
if (ConcurrencyMode.VERSION == concurrencyMode) {
|
||||||
throw new OptimisticLockException("Data has changed. updated row count " + rowCount, null, bean);
|
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() {
|
private void changeLog() {
|
||||||
BeanChange changeLogBean = beanDescriptor.getChangeLogBean(this);
|
BeanChange changeLogBean = beanDescriptor.changeLogBean(this);
|
||||||
if (changeLogBean != null) {
|
if (changeLogBean != null) {
|
||||||
transaction.addBeanChange(changeLogBean);
|
transaction.addBeanChange(changeLogBean);
|
||||||
}
|
}
|
||||||
@@ -937,8 +887,8 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
}
|
}
|
||||||
addPostCommitListeners();
|
addPostCommitListeners();
|
||||||
notifyCacheOnPostExecute();
|
notifyCacheOnPostExecute();
|
||||||
if (isLogSummary()) {
|
if (logSummary()) {
|
||||||
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 draft = (beanDescriptor.isDraftable() && !publish) ? " draft[true]" : "";
|
||||||
String name = beanDescriptor.getName();
|
String name = beanDescriptor.name();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case INSERT:
|
case INSERT:
|
||||||
transaction.logSummary("Inserted [" + name + "] [" + idValue + "]" + draft);
|
transaction.logSummary("Inserted [" + name + "] [" + idValue + "]" + draft);
|
||||||
@@ -1021,9 +971,9 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
*/
|
*/
|
||||||
public boolean isAddToUpdate(BeanProperty prop) {
|
public boolean isAddToUpdate(BeanProperty prop) {
|
||||||
if (requestUpdateAllLoadedProps) {
|
if (requestUpdateAllLoadedProps) {
|
||||||
return intercept.isLoadedProperty(prop.getPropertyIndex());
|
return intercept.isLoadedProperty(prop.propertyIndex());
|
||||||
} else {
|
} 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).
|
* Register the derived relationships to get executed later (on JDBC batch flush or commit).
|
||||||
*/
|
*/
|
||||||
public void deferredRelationship(EntityBean assocBean, ImportedId importedId, EntityBean bean) {
|
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() {
|
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).
|
* Return the list of updated many properties for L2 cache update (can be null).
|
||||||
*/
|
*/
|
||||||
public List<BeanPropertyAssocMany<?>> getUpdatedManyForL2Cache() {
|
public List<BeanPropertyAssocMany<?>> updatedManyForL2Cache() {
|
||||||
return updatedManys;
|
return updatedManys;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1151,9 +1101,9 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
}
|
}
|
||||||
case QUEUE: {
|
case QUEUE: {
|
||||||
if (type == Type.DELETE) {
|
if (type == Type.DELETE) {
|
||||||
docStoreUpdates.queueDelete(beanDescriptor.getDocStoreQueueId(), idValue);
|
docStoreUpdates.queueDelete(beanDescriptor.docStoreQueueId(), idValue);
|
||||||
} else {
|
} else {
|
||||||
docStoreUpdates.queueIndex(beanDescriptor.getDocStoreQueueId(), idValue);
|
docStoreUpdates.queueIndex(beanDescriptor.docStoreQueueId(), idValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1175,7 +1125,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
requestUpdateAllLoadedProps = txnUpdateAll;
|
requestUpdateAllLoadedProps = txnUpdateAll;
|
||||||
} else {
|
} else {
|
||||||
// if using batch use the server default setting
|
// if using batch use the server default setting
|
||||||
requestUpdateAllLoadedProps = isBatchThisRequest() && ebeanServer.isUpdateAllPropertiesInBatch();
|
requestUpdateAllLoadedProps = isBatchThisRequest() && server.isUpdateAllPropertiesInBatch();
|
||||||
}
|
}
|
||||||
return requestUpdateAllLoadedProps;
|
return requestUpdateAllLoadedProps;
|
||||||
}
|
}
|
||||||
@@ -1183,7 +1133,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
/**
|
/**
|
||||||
* Return the flags set on this persist request.
|
* Return the flags set on this persist request.
|
||||||
*/
|
*/
|
||||||
public int getFlags() {
|
public int flags() {
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1197,16 +1147,16 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
/**
|
/**
|
||||||
* Return the key for an update persist request.
|
* Return the key for an update persist request.
|
||||||
*/
|
*/
|
||||||
public String getUpdatePlanHash() {
|
public String updatePlanHash() {
|
||||||
StringBuilder key;
|
StringBuilder key;
|
||||||
if (determineUpdateAllLoadedProperties()) {
|
if (determineUpdateAllLoadedProperties()) {
|
||||||
key = intercept.getLoadedPropertyKey();
|
key = intercept.getLoadedPropertyKey();
|
||||||
} else {
|
} else {
|
||||||
key = intercept.getDirtyPropertyKey();
|
key = intercept.getDirtyPropertyKey();
|
||||||
}
|
}
|
||||||
BeanProperty versionProperty = beanDescriptor.getVersionProperty();
|
BeanProperty versionProperty = beanDescriptor.versionProperty();
|
||||||
if (versionProperty != null) {
|
if (versionProperty != null) {
|
||||||
if (intercept.isLoadedProperty(versionProperty.getPropertyIndex())) {
|
if (intercept.isLoadedProperty(versionProperty.propertyIndex())) {
|
||||||
key.append('v');
|
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.
|
* Return the table to update depending if the request is a 'publish' one or normal.
|
||||||
*/
|
*/
|
||||||
public String getUpdateTable() {
|
public String updateTable() {
|
||||||
return publish ? beanDescriptor.getBaseTable() : beanDescriptor.getDraftTable();
|
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).
|
* Return the version in long form (if set).
|
||||||
*/
|
*/
|
||||||
public long getVersion() {
|
public long version() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1313,7 +1263,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
*/
|
*/
|
||||||
public long now() {
|
public long now() {
|
||||||
if (now == 0) {
|
if (now == 0) {
|
||||||
now = ebeanServer.clockNow();
|
now = server.clockNow();
|
||||||
}
|
}
|
||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
@@ -1330,7 +1280,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void profile() {
|
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);
|
String key = beanDescriptor.cacheKey(idValue);
|
||||||
Map<String, Object> changes = new LinkedHashMap<>();
|
Map<String, Object> changes = new LinkedHashMap<>();
|
||||||
EntityBean bean = getEntityBean();
|
EntityBean bean = entityBean();
|
||||||
boolean[] dirtyProperties = getDirtyProperties();
|
boolean[] dirtyProperties = dirtyProperties();
|
||||||
if (dirtyProperties != null) {
|
if (dirtyProperties != null) {
|
||||||
for (int i = 0; i < dirtyProperties.length; i++) {
|
for (int i = 0; i < dirtyProperties.length; i++) {
|
||||||
if (dirtyProperties[i]) {
|
if (dirtyProperties[i]) {
|
||||||
BeanProperty property = beanDescriptor.propertyByIndex(i);
|
BeanProperty property = beanDescriptor.propertyByIndex(i);
|
||||||
if (property.isCacheDataInclude()) {
|
if (property.isCacheDataInclude()) {
|
||||||
Object val = property.getCacheDataValue(bean);
|
Object val = property.getCacheDataValue(bean);
|
||||||
changes.put(property.getName(), val);
|
changes.put(property.name(), val);
|
||||||
if (property.isNaturalKey()) {
|
if (property.isNaturalKey()) {
|
||||||
updateNaturalKey = true;
|
updateNaturalKey = true;
|
||||||
String valStr = (val == null) ? null : val.toString();
|
String valStr = (val == null) ? null : val.toString();
|
||||||
@@ -1405,7 +1355,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
|||||||
// add element collection update
|
// add element collection update
|
||||||
changes.putAll(collectionChanges);
|
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;
|
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.
|
* Return the SQL used to fetch the last inserted id value.
|
||||||
*/
|
*/
|
||||||
public String getSelectLastInsertedId() {
|
public String getSelectLastInsertedId() {
|
||||||
return beanDescriptor.getSelectLastInsertedId(publish);
|
return beanDescriptor.selectLastInsertedId(publish);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-15
@@ -19,20 +19,15 @@ import java.util.List;
|
|||||||
public final class PersistRequestCallableSql extends PersistRequest {
|
public final class PersistRequestCallableSql extends PersistRequest {
|
||||||
|
|
||||||
private final SpiCallableSql callableSql;
|
private final SpiCallableSql callableSql;
|
||||||
|
|
||||||
private int rowCount;
|
private int rowCount;
|
||||||
|
|
||||||
private String bindLog;
|
private String bindLog;
|
||||||
|
|
||||||
private CallableStatement cstmt;
|
private CallableStatement cstmt;
|
||||||
|
|
||||||
private BindParams bindParam;
|
private BindParams bindParam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create.
|
* Create.
|
||||||
*/
|
*/
|
||||||
public PersistRequestCallableSql(SpiEbeanServer server, CallableSql cs, SpiTransaction t, PersistExecute persistExecute) {
|
public PersistRequestCallableSql(SpiEbeanServer server, CallableSql cs, SpiTransaction t, PersistExecute persistExecute) {
|
||||||
|
|
||||||
super(server, t, persistExecute, cs.getLabel());
|
super(server, t, persistExecute, cs.getLabel());
|
||||||
this.type = PersistRequest.Type.CALLABLESQL;
|
this.type = PersistRequest.Type.CALLABLESQL;
|
||||||
this.callableSql = (SpiCallableSql) cs;
|
this.callableSql = (SpiCallableSql) cs;
|
||||||
@@ -56,7 +51,7 @@ public final class PersistRequestCallableSql extends PersistRequest {
|
|||||||
/**
|
/**
|
||||||
* Return the CallableSql.
|
* Return the CallableSql.
|
||||||
*/
|
*/
|
||||||
public SpiCallableSql getCallableSql() {
|
public SpiCallableSql callableSql() {
|
||||||
return callableSql;
|
return callableSql;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,13 +92,11 @@ public final class PersistRequestCallableSql extends PersistRequest {
|
|||||||
|
|
||||||
// register table modifications with the transaction event
|
// register table modifications with the transaction event
|
||||||
TransactionEventTable tableEvents = callableSql.getTransactionEventTable();
|
TransactionEventTable tableEvents = callableSql.getTransactionEventTable();
|
||||||
|
|
||||||
if (tableEvents != null && !tableEvents.isEmpty()) {
|
if (tableEvents != null && !tableEvents.isEmpty()) {
|
||||||
transaction.getEvent().add(tableEvents);
|
transaction.getEvent().add(tableEvents);
|
||||||
} else {
|
} else {
|
||||||
transaction.markNotQueryOnly();
|
transaction.markNotQueryOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,7 +113,6 @@ public final class PersistRequestCallableSql extends PersistRequest {
|
|||||||
* Execute the statement in normal non batch mode.
|
* Execute the statement in normal non batch mode.
|
||||||
*/
|
*/
|
||||||
public int executeUpdate() throws SQLException {
|
public int executeUpdate() throws SQLException {
|
||||||
|
|
||||||
// check to see if the execution has been overridden
|
// check to see if the execution has been overridden
|
||||||
// only works in non-batch mode
|
// only works in non-batch mode
|
||||||
if (callableSql.executeOverride(cstmt)) {
|
if (callableSql.executeOverride(cstmt)) {
|
||||||
@@ -129,20 +121,15 @@ public final class PersistRequestCallableSql extends PersistRequest {
|
|||||||
// rowCount = callableSql.getRowCount();
|
// rowCount = callableSql.getRowCount();
|
||||||
// return rowCount;
|
// return rowCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
rowCount = cstmt.executeUpdate();
|
rowCount = cstmt.executeUpdate();
|
||||||
|
|
||||||
// only read in non-batch mode
|
// only read in non-batch mode
|
||||||
readOutParams();
|
readOutParams();
|
||||||
|
|
||||||
return rowCount;
|
return rowCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readOutParams() throws SQLException {
|
private void readOutParams() throws SQLException {
|
||||||
|
|
||||||
List<Param> list = bindParam.positionedParameters();
|
List<Param> list = bindParam.positionedParameters();
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
for (Param param : list) {
|
for (Param param : list) {
|
||||||
pos++;
|
pos++;
|
||||||
if (param.isOutParam()) {
|
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 {
|
public final class PersistRequestOrmUpdate extends PersistRequest {
|
||||||
|
|
||||||
private final BeanDescriptor<?> beanDescriptor;
|
private final BeanDescriptor<?> beanDescriptor;
|
||||||
|
|
||||||
private final SpiUpdate<?> ormUpdate;
|
private final SpiUpdate<?> ormUpdate;
|
||||||
|
|
||||||
private int rowCount;
|
private int rowCount;
|
||||||
|
|
||||||
private String bindLog;
|
private String bindLog;
|
||||||
|
|
||||||
/**
|
public PersistRequestOrmUpdate(SpiEbeanServer server, BeanManager<?> mgr, SpiUpdate<?> ormUpdate, SpiTransaction t, PersistExecute persistExecute) {
|
||||||
* Create.
|
|
||||||
*/
|
|
||||||
public PersistRequestOrmUpdate(SpiEbeanServer server, BeanManager<?> mgr, SpiUpdate<?> ormUpdate,
|
|
||||||
SpiTransaction t, PersistExecute persistExecute) {
|
|
||||||
|
|
||||||
super(server, t, persistExecute, ormUpdate.getLabel());
|
super(server, t, persistExecute, ormUpdate.getLabel());
|
||||||
this.beanDescriptor = mgr.getBeanDescriptor();
|
this.beanDescriptor = mgr.getBeanDescriptor();
|
||||||
this.ormUpdate = ormUpdate;
|
this.ormUpdate = ormUpdate;
|
||||||
@@ -34,10 +26,10 @@ public final class PersistRequestOrmUpdate extends PersistRequest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void profile(long offset, int flushCount) {
|
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;
|
return beanDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,11 +43,10 @@ public final class PersistRequestOrmUpdate extends PersistRequest {
|
|||||||
return executeStatement();
|
return executeStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the UpdateSql.
|
* Return the UpdateSql.
|
||||||
*/
|
*/
|
||||||
public SpiUpdate<?> getOrmUpdate() {
|
public SpiUpdate<?> ormUpdate() {
|
||||||
return ormUpdate;
|
return ormUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,14 +82,11 @@ public final class PersistRequestOrmUpdate extends PersistRequest {
|
|||||||
}
|
}
|
||||||
OrmUpdateType ormUpdateType = ormUpdate.getOrmUpdateType();
|
OrmUpdateType ormUpdateType = ormUpdate.getOrmUpdateType();
|
||||||
String tableName = ormUpdate.getBaseTable();
|
String tableName = ormUpdate.getBaseTable();
|
||||||
|
|
||||||
if (transaction.isLogSummary()) {
|
if (transaction.isLogSummary()) {
|
||||||
String m = ormUpdateType + " table[" + tableName + "] rows[" + rowCount + "] bind[" + bindLog + "]";
|
String m = ormUpdateType + " table[" + tableName + "] rows[" + rowCount + "] bind[" + bindLog + "]";
|
||||||
transaction.logSummary(m);
|
transaction.logSummary(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ormUpdate.isNotifyCache()) {
|
if (ormUpdate.isNotifyCache()) {
|
||||||
|
|
||||||
// add the modification info to the TransactionEvent
|
// add the modification info to the TransactionEvent
|
||||||
// this is used to invalidate cached objects etc
|
// this is used to invalidate cached objects etc
|
||||||
switch (ormUpdateType) {
|
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 final SpiSqlUpdate updateSql;
|
||||||
|
|
||||||
private int rowCount;
|
private int rowCount;
|
||||||
|
|
||||||
private String bindLog;
|
private String bindLog;
|
||||||
|
|
||||||
private SqlType sqlType;
|
private SqlType sqlType;
|
||||||
|
|
||||||
private String tableName;
|
private String tableName;
|
||||||
|
|
||||||
private boolean addBatch;
|
private boolean addBatch;
|
||||||
|
|
||||||
private final boolean forceNoBatch;
|
private final boolean forceNoBatch;
|
||||||
|
|
||||||
private boolean batchThisRequest;
|
private boolean batchThisRequest;
|
||||||
private boolean flushQueue;
|
private boolean flushQueue;
|
||||||
|
|
||||||
public PersistRequestUpdateSql(SpiEbeanServer server, SpiSqlUpdate sqlUpdate,
|
public PersistRequestUpdateSql(SpiEbeanServer server, SpiSqlUpdate sqlUpdate,
|
||||||
SpiTransaction t, PersistExecute persistExecute, boolean forceNoBatch) {
|
SpiTransaction t, PersistExecute persistExecute, boolean forceNoBatch) {
|
||||||
|
|
||||||
super(server, t, persistExecute, sqlUpdate.getLabel());
|
super(server, t, persistExecute, sqlUpdate.getLabel());
|
||||||
this.type = Type.UPDATESQL;
|
this.type = Type.UPDATESQL;
|
||||||
this.updateSql = sqlUpdate;
|
this.updateSql = sqlUpdate;
|
||||||
@@ -105,7 +97,7 @@ public final class PersistRequestUpdateSql extends PersistRequest {
|
|||||||
/**
|
/**
|
||||||
* Return the UpdateSql.
|
* Return the UpdateSql.
|
||||||
*/
|
*/
|
||||||
public SpiSqlUpdate getUpdateSql() {
|
public SpiSqlUpdate updateSql() {
|
||||||
return updateSql;
|
return updateSql;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,6 +137,7 @@ public final class PersistRequestUpdateSql extends PersistRequest {
|
|||||||
this.bindLog = bindLog;
|
this.bindLog = bindLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void startBind(boolean batchThisRequest) {
|
public void startBind(boolean batchThisRequest) {
|
||||||
this.batchThisRequest = batchThisRequest;
|
this.batchThisRequest = batchThisRequest;
|
||||||
super.startBind(batchThisRequest);
|
super.startBind(batchThisRequest);
|
||||||
@@ -170,7 +163,6 @@ public final class PersistRequestUpdateSql extends PersistRequest {
|
|||||||
if (transaction.isLogSql() && !batchThisRequest) {
|
if (transaction.isLogSql() && !batchThisRequest) {
|
||||||
transaction.logSql(Str.add(TrimLogSql.trim(updateSql.getGeneratedSql()), "; -- bind(", bindLog, ") rows(", String.valueOf(rowCount), ")"));
|
transaction.logSql(Str.add(TrimLogSql.trim(updateSql.getGeneratedSql()), "; -- bind(", bindLog, ") rows(", String.valueOf(rowCount), ")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updateSql.isAutoTableMod()) {
|
if (updateSql.isAutoTableMod()) {
|
||||||
// add the modification info to the TransactionEvent
|
// add the modification info to the TransactionEvent
|
||||||
// this is used to invalidate cached objects etc
|
// this is used to invalidate cached objects etc
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ public interface SpiOrmQueryRequest<T> extends BeanQueryRequest<T>, DocQueryRequ
|
|||||||
* Return the query.
|
* Return the query.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
SpiQuery<T> getQuery();
|
SpiQuery<T> query();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the associated BeanDescriptor.
|
* Return the associated BeanDescriptor.
|
||||||
*/
|
*/
|
||||||
BeanDescriptor<T> getBeanDescriptor();
|
BeanDescriptor<T> descriptor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the query for execution.
|
* 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).
|
* 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).
|
* 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().
|
* 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.
|
* 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.
|
* Escapes a string to use it as exact match in Like clause.
|
||||||
|
|||||||
+3
-3
@@ -13,7 +13,7 @@ final class AssocOneHelpRefExported extends AssocOneHelp {
|
|||||||
AssocOneHelpRefExported(BeanPropertyAssocOne<?> property) {
|
AssocOneHelpRefExported(BeanPropertyAssocOne<?> property) {
|
||||||
super(property);
|
super(property);
|
||||||
this.softDelete = property.targetDescriptor.isSoftDelete();
|
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
|
@Override
|
||||||
void appendSelect(DbSqlContext ctx, boolean subQuery) {
|
void appendSelect(DbSqlContext ctx, boolean subQuery) {
|
||||||
// set appropriate tableAlias for the exported id columns
|
// set appropriate tableAlias for the exported id columns
|
||||||
String relativePrefix = ctx.getRelativePrefix(property.getName());
|
String relativePrefix = ctx.getRelativePrefix(property.name());
|
||||||
ctx.pushTableAlias(relativePrefix);
|
ctx.pushTableAlias(relativePrefix);
|
||||||
property.targetIdBinder.appendSelect(ctx, subQuery);
|
property.targetIdBinder.appendSelect(ctx, subQuery);
|
||||||
ctx.popTableAlias();
|
ctx.popTableAlias();
|
||||||
@@ -30,7 +30,7 @@ final class AssocOneHelpRefExported extends AssocOneHelp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void appendFrom(DbSqlContext ctx, SqlJoinType joinType) {
|
void appendFrom(DbSqlContext ctx, SqlJoinType joinType) {
|
||||||
String relativePrefix = ctx.getRelativePrefix(property.getName());
|
String relativePrefix = ctx.getRelativePrefix(property.name());
|
||||||
if (softDelete && !ctx.isIncludeSoftDelete()) {
|
if (softDelete && !ctx.isIncludeSoftDelete()) {
|
||||||
property.tableJoin.addJoin(joinType, relativePrefix, ctx, softDeletePredicate);
|
property.tableJoin.addJoin(joinType, relativePrefix, ctx, softDeletePredicate);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
|
|||||||
void appendSelect(DbSqlContext ctx, boolean subQuery) {
|
void appendSelect(DbSqlContext ctx, boolean subQuery) {
|
||||||
if (!subQuery) {
|
if (!subQuery) {
|
||||||
// add discriminator column
|
// add discriminator column
|
||||||
String relativePrefix = ctx.getRelativePrefix(property.getName());
|
String relativePrefix = ctx.getRelativePrefix(property.name());
|
||||||
String tableAlias = ctx.getTableAlias(relativePrefix);
|
String tableAlias = ctx.getTableAlias(relativePrefix);
|
||||||
ctx.appendColumn(tableAlias, property.targetInheritInfo.getDiscriminatorColumn());
|
ctx.appendColumn(tableAlias, property.targetInheritInfo.getDiscriminatorColumn());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ abstract class BaseCollectionHelp<T> implements BeanCollectionHelp<T> {
|
|||||||
|
|
||||||
BaseCollectionHelp(BeanPropertyAssocMany<T> many) {
|
BaseCollectionHelp(BeanPropertyAssocMany<T> many) {
|
||||||
this.many = many;
|
this.many = many;
|
||||||
this.targetDescriptor = many.getTargetDescriptor();
|
this.targetDescriptor = many.targetDescriptor();
|
||||||
this.propertyName = many.getName();
|
this.propertyName = many.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseCollectionHelp() {
|
BaseCollectionHelp() {
|
||||||
|
|||||||
@@ -54,10 +54,10 @@ final class BeanChangeJson implements BeanDiffVisitor {
|
|||||||
public void visitPush(int position) {
|
public void visitPush(int position) {
|
||||||
stack.push(descriptor);
|
stack.push(descriptor);
|
||||||
BeanPropertyAssocOne<?> embedded = (BeanPropertyAssocOne<?>)descriptor.propertiesIndex[position];
|
BeanPropertyAssocOne<?> embedded = (BeanPropertyAssocOne<?>)descriptor.propertiesIndex[position];
|
||||||
descriptor = embedded.getTargetDescriptor();
|
descriptor = embedded.targetDescriptor();
|
||||||
newJson.writeStartObject(embedded.getName());
|
newJson.writeStartObject(embedded.name());
|
||||||
if (oldJson != null) {
|
if (oldJson != null) {
|
||||||
oldJson.writeStartObject(embedded.getName());
|
oldJson.writeStartObject(embedded.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -22,7 +22,7 @@ public final class BeanCollectionHelpFactory {
|
|||||||
*/
|
*/
|
||||||
public static <T> BeanCollectionHelp<T> create(BeanPropertyAssocMany<T> many) {
|
public static <T> BeanCollectionHelp<T> create(BeanPropertyAssocMany<T> many) {
|
||||||
boolean elementCollection = many.isElementCollection();
|
boolean elementCollection = many.isElementCollection();
|
||||||
ManyType manyType = many.getManyType();
|
ManyType manyType = many.manyType();
|
||||||
switch (manyType) {
|
switch (manyType) {
|
||||||
case LIST:
|
case LIST:
|
||||||
return elementCollection ? new BeanListHelpElement<>(many) : new BeanListHelp<>(many);
|
return elementCollection ? new BeanListHelpElement<>(many) : new BeanListHelp<>(many);
|
||||||
@@ -44,8 +44,8 @@ public final class BeanCollectionHelpFactory {
|
|||||||
return SET_HELP;
|
return SET_HELP;
|
||||||
|
|
||||||
} else if (manyType == SpiQuery.Type.MAP) {
|
} else if (manyType == SpiQuery.Type.MAP) {
|
||||||
BeanDescriptor<T> target = request.getBeanDescriptor();
|
BeanDescriptor<T> target = request.descriptor();
|
||||||
ElPropertyValue elProperty = target.getElGetValue(request.getQuery().getMapKey());
|
ElPropertyValue elProperty = target.elGetValue(request.query().getMapKey());
|
||||||
return new BeanMapQueryHelp<>(elProperty);
|
return new BeanMapQueryHelp<>(elProperty);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
+15
-15
@@ -124,7 +124,7 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
if (cacheNotifyOnAll || cacheNotifyOnDelete) {
|
if (cacheNotifyOnAll || cacheNotifyOnDelete) {
|
||||||
String notifyMode = cacheNotifyOnAll ? "All" : "Delete";
|
String notifyMode = cacheNotifyOnAll ? "All" : "Delete";
|
||||||
logger.debug("l2 caching on {} - beanCaching:{} queryCaching:{} notifyMode:{} ",
|
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
|
// held as part of the bean cache so skip
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CachedManyIds entry = manyPropGet(parentId, many.getName());
|
CachedManyIds entry = manyPropGet(parentId, many.name());
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
// not in cache so return unsuccessful
|
// not in cache so return unsuccessful
|
||||||
return false;
|
return false;
|
||||||
@@ -290,7 +290,7 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
EntityBean ownerBean = bc.getOwnerBean();
|
EntityBean ownerBean = bc.getOwnerBean();
|
||||||
EntityBeanIntercept ebi = ownerBean._ebean_getIntercept();
|
EntityBeanIntercept ebi = ownerBean._ebean_getIntercept();
|
||||||
PersistenceContext persistenceContext = ebi.getPersistenceContext();
|
PersistenceContext persistenceContext = ebi.getPersistenceContext();
|
||||||
BeanDescriptor<?> targetDescriptor = many.getTargetDescriptor();
|
BeanDescriptor<?> targetDescriptor = many.targetDescriptor();
|
||||||
|
|
||||||
List<Object> idList = entry.getIdList();
|
List<Object> idList = entry.getIdList();
|
||||||
bc.checkEmptyLazyLoad();
|
bc.checkEmptyLazyLoad();
|
||||||
@@ -316,7 +316,7 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
// add as JSON to bean cache
|
// add as JSON to bean cache
|
||||||
String asJson = many.jsonWriteCollection(details);
|
String asJson = many.jsonWriteCollection(details);
|
||||||
Map<String, Object> changes = new HashMap<>();
|
Map<String, Object> changes = new HashMap<>();
|
||||||
changes.put(many.getName(), asJson);
|
changes.put(many.name(), asJson);
|
||||||
|
|
||||||
CachedBeanData newData = data.update(changes, data.getVersion());
|
CachedBeanData newData = data.update(changes, data.getVersion());
|
||||||
if (beanLog.isDebugEnabled()) {
|
if (beanLog.isDebugEnabled()) {
|
||||||
@@ -330,7 +330,7 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
} else {
|
} else {
|
||||||
CachedManyIds entry = createManyIds(many, details);
|
CachedManyIds entry = createManyIds(many, details);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
cachePutManyIds(parentId, many.getName(), entry);
|
cachePutManyIds(parentId, many.name(), entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -349,10 +349,10 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
BeanDescriptor<?> targetDescriptor = many.getTargetDescriptor();
|
BeanDescriptor<?> targetDescriptor = many.targetDescriptor();
|
||||||
List<Object> idList = new ArrayList<>(actualDetails.size());
|
List<Object> idList = new ArrayList<>(actualDetails.size());
|
||||||
for (Object bean : actualDetails) {
|
for (Object bean : actualDetails) {
|
||||||
idList.add(targetDescriptor.getId((EntityBean) bean));
|
idList.add(targetDescriptor.id(bean));
|
||||||
}
|
}
|
||||||
return new CachedManyIds(idList);
|
return new CachedManyIds(idList);
|
||||||
}
|
}
|
||||||
@@ -375,7 +375,7 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
for (Map.Entry<Object, Object> entry : beanDataMap.entrySet()) {
|
for (Map.Entry<Object, Object> entry : beanDataMap.entrySet()) {
|
||||||
CachedBeanData cachedBeanData = (CachedBeanData) entry.getValue();
|
CachedBeanData cachedBeanData = (CachedBeanData) entry.getValue();
|
||||||
T bean = convertToBean(entry.getKey(), false, context, cachedBeanData);
|
T bean = convertToBean(entry.getKey(), false, context, cachedBeanData);
|
||||||
result.add(bean, desc.getBeanId(bean));
|
result.add(bean, desc.id(bean));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -773,7 +773,7 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
|
|
||||||
void cacheUpdateQuery(boolean update, SpiTransaction transaction) {
|
void cacheUpdateQuery(boolean update, SpiTransaction transaction) {
|
||||||
if (invalidateQueryCache || cacheNotifyOnAll || (!update && cacheNotifyOnDelete)) {
|
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) {
|
if (beanCache != null) {
|
||||||
changeSet.addBeanRemove(desc, id);
|
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);
|
changeSet.addInvalidate(desc);
|
||||||
} else {
|
} else {
|
||||||
queryCacheClear(changeSet);
|
queryCacheClear(changeSet);
|
||||||
cacheDeleteImported(false, insertRequest.getEntityBean(), changeSet);
|
cacheDeleteImported(false, insertRequest.entityBean(), changeSet);
|
||||||
changeSet.addBeanInsert(desc.getBaseTable());
|
changeSet.addBeanInsert(desc.baseTable());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -839,13 +839,13 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
// query caching only
|
// query caching only
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<BeanPropertyAssocMany<?>> manyCollections = updateRequest.getUpdatedManyForL2Cache();
|
List<BeanPropertyAssocMany<?>> manyCollections = updateRequest.updatedManyForL2Cache();
|
||||||
if (manyCollections != null) {
|
if (manyCollections != null) {
|
||||||
for (BeanPropertyAssocMany<?> many : manyCollections) {
|
for (BeanPropertyAssocMany<?> many : manyCollections) {
|
||||||
Object details = many.getValue(updateRequest.getEntityBean());
|
Object details = many.getValue(updateRequest.entityBean());
|
||||||
CachedManyIds entry = createManyIds(many, details);
|
CachedManyIds entry = createManyIds(many, details);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
changeSet.addManyPut(desc, many.getName(), id, entry);
|
changeSet.addManyPut(desc, many.name(), id, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -19,7 +19,7 @@ final class BeanDescriptorDraftHelp<T> {
|
|||||||
|
|
||||||
BeanDescriptorDraftHelp(BeanDescriptor<T> desc) {
|
BeanDescriptorDraftHelp(BeanDescriptor<T> desc) {
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
this.draftDirty = desc.getDraftDirty();
|
this.draftDirty = desc.draftDirty();
|
||||||
this.resetProperties = resetProperties();
|
this.resetProperties = resetProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ final class BeanDescriptorDraftHelp<T> {
|
|||||||
}
|
}
|
||||||
EntityBean draft = (EntityBean) draftBean;
|
EntityBean draft = (EntityBean) draftBean;
|
||||||
EntityBean live = (EntityBean) liveBean;
|
EntityBean live = (EntityBean) liveBean;
|
||||||
BeanProperty idProperty = desc.getIdProperty();
|
BeanProperty idProperty = desc.idProperty();
|
||||||
if (idProperty != null) {
|
if (idProperty != null) {
|
||||||
idProperty.publish(draft, live);
|
idProperty.publish(draft, live);
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ final class BeanDescriptorDraftHelp<T> {
|
|||||||
prop.publish(draft, live);
|
prop.publish(draft, live);
|
||||||
}
|
}
|
||||||
for (BeanPropertyAssocMany<?> many : desc.propertiesMany()) {
|
for (BeanPropertyAssocMany<?> many : desc.propertiesMany()) {
|
||||||
if (many.getTargetDescriptor().isDraftable()) {
|
if (many.targetDescriptor().isDraftable()) {
|
||||||
many.publishMany(draft, live);
|
many.publishMany(draft, live);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,13 +86,13 @@ final class BeanDescriptorDraftHelp<T> {
|
|||||||
*/
|
*/
|
||||||
void draftQueryOptimise(Query<T> query) {
|
void draftQueryOptimise(Query<T> query) {
|
||||||
for (BeanPropertyAssocOne<?> anOne : desc.propertiesOne()) {
|
for (BeanPropertyAssocOne<?> anOne : desc.propertiesOne()) {
|
||||||
if (anOne.getTargetDescriptor().isDraftableElement()) {
|
if (anOne.targetDescriptor().isDraftableElement()) {
|
||||||
query.fetch(anOne.getName());
|
query.fetch(anOne.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (BeanPropertyAssocMany<?> aMany : desc.propertiesMany()) {
|
for (BeanPropertyAssocMany<?> aMany : desc.propertiesMany()) {
|
||||||
if (aMany.getTargetDescriptor().isDraftableElement()) {
|
if (aMany.targetDescriptor().isDraftableElement()) {
|
||||||
query.fetch(aMany.getName());
|
query.fetch(aMany.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ abstract class BeanDescriptorElement<T> extends BeanDescriptor<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSimpleName() {
|
public String simpleName() {
|
||||||
return simpleName;
|
return simpleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ abstract class BeanDescriptorElement<T> extends BeanDescriptor<T> {
|
|||||||
if (props.length != 1) {
|
if (props.length != 1) {
|
||||||
throw new IllegalStateException("Expecting 1 property for element scalar but got " + Arrays.toString(props));
|
throw new IllegalStateException("Expecting 1 property for element scalar but got " + Arrays.toString(props));
|
||||||
}
|
}
|
||||||
return props[0].getScalarType();
|
return props[0].scalarType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ class BeanDescriptorElementEmbedded<T> extends BeanDescriptorElement<T> {
|
|||||||
@Override
|
@Override
|
||||||
public void initialiseOther(BeanDescriptorInitContext initContext) {
|
public void initialiseOther(BeanDescriptorInitContext initContext) {
|
||||||
super.initialiseOther(initContext);
|
super.initialiseOther(initContext);
|
||||||
this.targetDescriptor = embeddedProperty.getTargetDescriptor();
|
this.targetDescriptor = embeddedProperty.targetDescriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+2
-2
@@ -26,8 +26,8 @@ class BeanDescriptorElementScalarMap<T> extends BeanDescriptorElement<T> {
|
|||||||
if (props.length != 2) {
|
if (props.length != 2) {
|
||||||
throw new IllegalStateException("Expecting 2 properties for key and value but got " + Arrays.toString(props));
|
throw new IllegalStateException("Expecting 2 properties for key and value but got " + Arrays.toString(props));
|
||||||
}
|
}
|
||||||
this.scalarTypeKey = props[0].getScalarType();
|
this.scalarTypeKey = props[0].scalarType();
|
||||||
this.scalarTypeVal = props[1].getScalarType();
|
this.scalarTypeVal = props[1].scalarType();
|
||||||
this.stringKey = String.class.equals(scalarTypeKey.getType());
|
this.stringKey = String.class.equals(scalarTypeKey.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ final class BeanDescriptorJsonHelp<T> {
|
|||||||
// render the dirty properties
|
// render the dirty properties
|
||||||
BeanProperty[] props = desc.propertiesNonTransient();
|
BeanProperty[] props = desc.propertiesNonTransient();
|
||||||
for (BeanProperty prop : props) {
|
for (BeanProperty prop : props) {
|
||||||
if (dirtyProps[prop.getPropertyIndex()]) {
|
if (dirtyProps[prop.propertyIndex()]) {
|
||||||
prop.jsonWrite(writeJson, bean);
|
prop.jsonWrite(writeJson, bean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ final class BeanDescriptorJsonHelp<T> {
|
|||||||
JsonToken event = parser.nextToken();
|
JsonToken event = parser.nextToken();
|
||||||
if (JsonToken.FIELD_NAME == event) {
|
if (JsonToken.FIELD_NAME == event) {
|
||||||
String key = parser.getCurrentName();
|
String key = parser.getCurrentName();
|
||||||
BeanProperty p = desc.getBeanProperty(key);
|
BeanProperty p = desc.beanProperty(key);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
p.jsonRead(readJson, bean);
|
p.jsonRead(readJson, bean);
|
||||||
} else {
|
} else {
|
||||||
@@ -145,7 +145,7 @@ final class BeanDescriptorJsonHelp<T> {
|
|||||||
desc.setUnmappedJson(bean, unmappedProperties);
|
desc.setUnmappedJson(bean, unmappedProperties);
|
||||||
}
|
}
|
||||||
Object contextBean = null;
|
Object contextBean = null;
|
||||||
Object id = desc.beanId(bean);
|
Object id = desc.id(bean);
|
||||||
if (!isNullOrZero(id)) {
|
if (!isNullOrZero(id)) {
|
||||||
// check if the bean has already been loaded
|
// check if the bean has already been loaded
|
||||||
contextBean = readJson.persistenceContextPutIfAbsent(id, bean, desc);
|
contextBean = readJson.persistenceContextPutIfAbsent(id, bean, desc);
|
||||||
|
|||||||
+51
-51
@@ -136,8 +136,8 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
this.multiValueBind = config.getMultiValueBind();
|
this.multiValueBind = config.getMultiValueBind();
|
||||||
this.idBinderFactory = new IdBinderFactory(databasePlatform.isIdInExpandedForm(), multiValueBind);
|
this.idBinderFactory = new IdBinderFactory(databasePlatform.isIdInExpandedForm(), multiValueBind);
|
||||||
this.queryPlanTTLSeconds = this.config.getQueryPlanTTLSeconds();
|
this.queryPlanTTLSeconds = this.config.getQueryPlanTTLSeconds();
|
||||||
this.asOfViewSuffix = getAsOfViewSuffix(databasePlatform, this.config);
|
this.asOfViewSuffix = asOfViewSuffix(databasePlatform, this.config);
|
||||||
String versionsBetweenSuffix = getVersionsBetweenSuffix(databasePlatform, this.config);
|
String versionsBetweenSuffix = versionsBetweenSuffix(databasePlatform, this.config);
|
||||||
this.readAnnotations = new ReadAnnotations(config.getGeneratedPropertyFactory(), asOfViewSuffix, versionsBetweenSuffix, this.config);
|
this.readAnnotations = new ReadAnnotations(config.getGeneratedPropertyFactory(), asOfViewSuffix, versionsBetweenSuffix, this.config);
|
||||||
this.bootupClasses = config.getBootupClasses();
|
this.bootupClasses = config.getBootupClasses();
|
||||||
this.createProperties = config.getDeployCreateProperties();
|
this.createProperties = config.getDeployCreateProperties();
|
||||||
@@ -183,19 +183,19 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ScalarType<?> getScalarType(String cast) {
|
public ScalarType<?> scalarType(String cast) {
|
||||||
return typeManager.getScalarType(cast);
|
return typeManager.getScalarType(cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ScalarType<?> getScalarType(int jdbcType) {
|
public ScalarType<?> scalarType(int jdbcType) {
|
||||||
return typeManager.getScalarType(jdbcType);
|
return typeManager.getScalarType(jdbcType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the AsOfViewSuffix based on the DbHistorySupport.
|
* 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();
|
DbHistorySupport historySupport = databasePlatform.getHistorySupport();
|
||||||
// with historySupport returns a simple view suffix or the sql2011 as of timestamp suffix
|
// with historySupport returns a simple view suffix or the sql2011 as of timestamp suffix
|
||||||
return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getAsOfViewSuffix(serverConfig.getAsOfViewSuffix());
|
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.
|
* 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();
|
DbHistorySupport historySupport = databasePlatform.getHistorySupport();
|
||||||
// with historySupport returns a simple view suffix or the sql2011 versions between timestamp suffix
|
// with historySupport returns a simple view suffix or the sql2011 versions between timestamp suffix
|
||||||
return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getVersionsBetweenSuffix(serverConfig.getAsOfViewSuffix());
|
return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getVersionsBetweenSuffix(serverConfig.getAsOfViewSuffix());
|
||||||
@@ -216,7 +216,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatabaseConfig getConfig() {
|
public DatabaseConfig config() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,38 +225,38 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
return docStoreFactory.createAdapter(descriptor, deploy);
|
return docStoreFactory.createAdapter(descriptor, deploy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeanDescriptor<?> getBeanDescriptorByQueueId(String queueId) {
|
public BeanDescriptor<?> descriptorByQueueId(String queueId) {
|
||||||
return descQueueMap.get(queueId);
|
return descQueueMap.get(queueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SpiBeanType getBeanType(Class<?> entityType) {
|
public SpiBeanType beanType(Class<?> entityType) {
|
||||||
return getBeanDescriptor(entityType);
|
return descriptor(entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@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());
|
return (BeanDescriptor<T>) descMap.get(entityType.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> BeanDescriptor<T> getBeanDescriptorByClassName(String entityClassName) {
|
public <T> BeanDescriptor<T> descriptorByClassName(String entityClassName) {
|
||||||
return (BeanDescriptor<T>) descMap.get(entityClassName);
|
return (BeanDescriptor<T>) descMap.get(entityClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getServerName() {
|
public String name() {
|
||||||
return serverName;
|
return serverName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SpiCacheManager getCacheManager() {
|
public SpiCacheManager cacheManager() {
|
||||||
return cacheManager;
|
return cacheManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NamingConvention getNamingConvention() {
|
public NamingConvention namingConvention() {
|
||||||
return namingConvention;
|
return namingConvention;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
/**
|
/**
|
||||||
* Return the map of base tables to draft tables.
|
* Return the map of base tables to draft tables.
|
||||||
*/
|
*/
|
||||||
public Map<String, String> getDraftTableMap() {
|
public Map<String, String> draftTableMap() {
|
||||||
return draftTableMap;
|
return draftTableMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
* Return the Encrypt key given the table and column name.
|
* Return the Encrypt key given the table and column name.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public EncryptKey getEncryptKey(String tableName, String columnName) {
|
public EncryptKey encryptKey(String tableName, String columnName) {
|
||||||
return encryptKeyManager.getEncryptKey(tableName, 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.
|
* For SQL based modifications we need to invalidate appropriate parts of the cache.
|
||||||
*/
|
*/
|
||||||
public void cacheNotify(TransactionEventTable.TableIUD tableIUD, CacheChangeSet changeSet) {
|
public void cacheNotify(TransactionEventTable.TableIUD tableIUD, CacheChangeSet changeSet) {
|
||||||
String tableName = tableIUD.getTableName().toLowerCase();
|
String tableName = tableIUD.tableName().toLowerCase();
|
||||||
List<BeanDescriptor<?>> normalBeanTypes = tableToDescMap.get(tableName);
|
List<BeanDescriptor<?>> normalBeanTypes = tableToDescMap.get(tableName);
|
||||||
if (normalBeanTypes != null) {
|
if (normalBeanTypes != null) {
|
||||||
// 'normal' entity beans based on a "base table"
|
// '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.
|
* 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 tableToDescMap.get(tableName.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the BeanDescriptors mapped to the table.
|
* 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());
|
return tableToDescMap.get(tableName.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,16 +433,16 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
*/
|
*/
|
||||||
private void readTableToDescriptor() {
|
private void readTableToDescriptor() {
|
||||||
for (BeanDescriptor<?> desc : descMap.values()) {
|
for (BeanDescriptor<?> desc : descMap.values()) {
|
||||||
String baseTable = desc.getBaseTable();
|
String baseTable = desc.baseTable();
|
||||||
if (baseTable != null) {
|
if (baseTable != null) {
|
||||||
baseTable = baseTable.toLowerCase();
|
baseTable = baseTable.toLowerCase();
|
||||||
List<BeanDescriptor<?>> list = tableToDescMap.computeIfAbsent(baseTable, k -> new ArrayList<>(1));
|
List<BeanDescriptor<?>> list = tableToDescMap.computeIfAbsent(baseTable, k -> new ArrayList<>(1));
|
||||||
list.add(desc);
|
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
|
// build map of tables to view entities dependent on those tables
|
||||||
// for the purpose of invalidating appropriate query caches
|
// for the purpose of invalidating appropriate query caches
|
||||||
String[] dependentTables = desc.getDependentTables();
|
String[] dependentTables = desc.dependentTables();
|
||||||
if (dependentTables != null && dependentTables.length > 0) {
|
if (dependentTables != null && dependentTables.length > 0) {
|
||||||
for (String depTable : dependentTables) {
|
for (String depTable : dependentTables) {
|
||||||
depTable = depTable.toLowerCase();
|
depTable = depTable.toLowerCase();
|
||||||
@@ -508,23 +508,23 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
for (BeanDescriptor<?> d : descMap.values()) {
|
for (BeanDescriptor<?> d : descMap.values()) {
|
||||||
d.initLast();
|
d.initLast();
|
||||||
if (!d.isEmbedded()) {
|
if (!d.isEmbedded()) {
|
||||||
beanManagerMap.put(d.getFullName(), beanManagerFactory.create(d));
|
beanManagerMap.put(d.fullName(), beanManagerFactory.create(d));
|
||||||
checkForValidEmbeddedId(d);
|
checkForValidEmbeddedId(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForValidEmbeddedId(BeanDescriptor<?> d) {
|
private void checkForValidEmbeddedId(BeanDescriptor<?> d) {
|
||||||
IdBinder idBinder = d.getIdBinder();
|
IdBinder idBinder = d.idBinder();
|
||||||
if (idBinder instanceof IdBinderEmbedded) {
|
if (idBinder instanceof IdBinderEmbedded) {
|
||||||
IdBinderEmbedded embId = (IdBinderEmbedded) idBinder;
|
IdBinderEmbedded embId = (IdBinderEmbedded) idBinder;
|
||||||
BeanDescriptor<?> idBeanDescriptor = embId.getIdBeanDescriptor();
|
BeanDescriptor<?> idBeanDescriptor = embId.getIdBeanDescriptor();
|
||||||
Class<?> idType = idBeanDescriptor.getBeanType();
|
Class<?> idType = idBeanDescriptor.type();
|
||||||
try {
|
try {
|
||||||
idType.getDeclaredMethod("hashCode");
|
idType.getDeclaredMethod("hashCode");
|
||||||
idType.getDeclaredMethod("equals", Object.class);
|
idType.getDeclaredMethod("equals", Object.class);
|
||||||
} catch (NoSuchMethodException e) {
|
} 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.
|
* Return an immutable list of all the BeanDescriptors.
|
||||||
*/
|
*/
|
||||||
public List<BeanDescriptor<?>> getBeanDescriptorList() {
|
public List<BeanDescriptor<?>> descriptorList() {
|
||||||
return immutableDescriptorList;
|
return immutableDescriptorList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeanTable getBeanTable(Class<?> type) {
|
public BeanTable beanTable(Class<?> type) {
|
||||||
return beanTableMap.get(type);
|
return beanTableMap.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,11 +562,11 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> BeanManager<T> getBeanManager(Class<T> entityType) {
|
public <T> BeanManager<T> beanManager(Class<T> entityType) {
|
||||||
return (BeanManager<T>) getBeanManager(entityType.getName());
|
return (BeanManager<T>) beanManager(entityType.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private BeanManager<?> getBeanManager(String beanClassName) {
|
private BeanManager<?> beanManager(String beanClassName) {
|
||||||
return beanManagerMap.get(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.
|
* Return the bean deploy info for the given class.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> DeployBeanInfo<T> getDeploy(Class<T> cls) {
|
public <T> DeployBeanInfo<T> deploy(Class<T> cls) {
|
||||||
return (DeployBeanInfo<T>) deployInfoMap.get(cls);
|
return (DeployBeanInfo<T>) deployInfoMap.get(cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerBeanDescriptor(DeployBeanInfo<?> info) {
|
private void registerDescriptor(DeployBeanInfo<?> info) {
|
||||||
BeanDescriptor<?> desc = new BeanDescriptor<>(this, info.getDescriptor());
|
BeanDescriptor<?> desc = new BeanDescriptor<>(this, info.getDescriptor());
|
||||||
descMap.put(desc.getBeanType().getName(), desc);
|
descMap.put(desc.type().getName(), desc);
|
||||||
if (desc.isDocStoreMapped()) {
|
if (desc.isDocStoreMapped()) {
|
||||||
descQueueMap.put(desc.getDocStoreQueueId(), desc);
|
descQueueMap.put(desc.docStoreQueueId(), desc);
|
||||||
}
|
}
|
||||||
for (BeanPropertyAssocMany<?> many : desc.propertiesMany()) {
|
for (BeanPropertyAssocMany<?> many : desc.propertiesMany()) {
|
||||||
if (many.isElementCollection()) {
|
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) {
|
private void registerEmbeddedBean(DeployBeanInfo<?> info) {
|
||||||
readDeployAssociations(info);
|
readDeployAssociations(info);
|
||||||
registerBeanDescriptor(info);
|
registerDescriptor(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -711,7 +711,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
}
|
}
|
||||||
for (DeployBeanInfo<?> info : deployInfoMap.values()) {
|
for (DeployBeanInfo<?> info : deployInfoMap.values()) {
|
||||||
if (!info.isEmbedded()) {
|
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();
|
Class<?> targetType = prop.getTargetType();
|
||||||
DeployBeanInfo<?> info = deployInfoMap.get(targetType);
|
DeployBeanInfo<?> info = deployInfoMap.get(targetType);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
@@ -805,7 +805,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
Set<String> matchSet = new HashSet<>();
|
Set<String> matchSet = new HashSet<>();
|
||||||
|
|
||||||
// get the bean descriptor that holds the mappedBy property
|
// get the bean descriptor that holds the mappedBy property
|
||||||
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(prop);
|
DeployBeanDescriptor<?> targetDesc = targetDescriptor(prop);
|
||||||
List<DeployBeanPropertyAssocOne<?>> ones = targetDesc.propertiesAssocOne();
|
List<DeployBeanPropertyAssocOne<?>> ones = targetDesc.propertiesAssocOne();
|
||||||
for (DeployBeanPropertyAssocOne<?> possibleMappedBy : ones) {
|
for (DeployBeanPropertyAssocOne<?> possibleMappedBy : ones) {
|
||||||
Class<?> possibleMappedByType = possibleMappedBy.getTargetType();
|
Class<?> possibleMappedByType = possibleMappedBy.getTargetType();
|
||||||
@@ -866,7 +866,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void makeOrderColumn(DeployBeanPropertyAssocMany<?> oneToMany) {
|
private void makeOrderColumn(DeployBeanPropertyAssocMany<?> oneToMany) {
|
||||||
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(oneToMany);
|
DeployBeanDescriptor<?> targetDesc = targetDescriptor(oneToMany);
|
||||||
DeployOrderColumn orderColumn = oneToMany.getOrderColumn();
|
DeployOrderColumn orderColumn = oneToMany.getOrderColumn();
|
||||||
final ScalarType<?> scalarType = typeManager.getScalarType(Integer.class);
|
final ScalarType<?> scalarType = typeManager.getScalarType(Integer.class);
|
||||||
DeployBeanProperty orderProperty = new DeployBeanProperty(targetDesc, Integer.class, scalarType, null);
|
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).
|
* into the order_id column on the order_lines table).
|
||||||
*/
|
*/
|
||||||
private void makeUnidirectional(DeployBeanPropertyAssocMany<?> oneToMany) {
|
private void makeUnidirectional(DeployBeanPropertyAssocMany<?> oneToMany) {
|
||||||
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(oneToMany);
|
DeployBeanDescriptor<?> targetDesc = targetDescriptor(oneToMany);
|
||||||
Class<?> owningType = oneToMany.getOwningType();
|
Class<?> owningType = oneToMany.getOwningType();
|
||||||
if (!oneToMany.getCascadeInfo().isSave()) {
|
if (!oneToMany.getCascadeInfo().isSave()) {
|
||||||
// The property MUST have persist cascading so that inserts work.
|
// The property MUST have persist cascading so that inserts work.
|
||||||
@@ -915,7 +915,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
oneToMany.setUnidirectional();
|
oneToMany.setUnidirectional();
|
||||||
|
|
||||||
// specify table and table alias...
|
// specify table and table alias...
|
||||||
BeanTable beanTable = getBeanTable(owningType);
|
BeanTable beanTable = beanTable(owningType);
|
||||||
|
|
||||||
// define the TableJoin
|
// define the TableJoin
|
||||||
DeployTableJoin oneToManyJoin = oneToMany.getTableJoin();
|
DeployTableJoin oneToManyJoin = oneToMany.getTableJoin();
|
||||||
@@ -951,7 +951,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
// its associated join information if it is available
|
// its associated join information if it is available
|
||||||
String mappedBy = prop.getMappedBy();
|
String mappedBy = prop.getMappedBy();
|
||||||
// get the mappedBy property
|
// get the mappedBy property
|
||||||
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(prop);
|
DeployBeanDescriptor<?> targetDesc = targetDescriptor(prop);
|
||||||
DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy);
|
DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy);
|
||||||
if (mappedProp == null) {
|
if (mappedProp == null) {
|
||||||
String m = "Error on " + prop.getFullBeanName();
|
String m = "Error on " + prop.getFullBeanName();
|
||||||
@@ -1008,7 +1008,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
// skip mapping check
|
// skip mapping check
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(prop);
|
DeployBeanDescriptor<?> targetDesc = targetDescriptor(prop);
|
||||||
|
|
||||||
if (targetDesc.isDraftableElement()) {
|
if (targetDesc.isDraftableElement()) {
|
||||||
// automatically turning on orphan removal and CascadeType.ALL
|
// 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
|
// get the bean descriptor that holds the mappedBy property
|
||||||
String mappedBy = prop.getMappedBy();
|
String mappedBy = prop.getMappedBy();
|
||||||
if (mappedBy == null) {
|
if (mappedBy == null) {
|
||||||
if (getTargetDescriptor(prop).isDraftable()) {
|
if (targetDescriptor(prop).isDraftable()) {
|
||||||
prop.setIntersectionDraftTable();
|
prop.setIntersectionDraftTable();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the mappedBy property
|
// get the mappedBy property
|
||||||
DeployBeanDescriptor<?> targetDesc = getTargetDescriptor(prop);
|
DeployBeanDescriptor<?> targetDesc = targetDescriptor(prop);
|
||||||
DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy);
|
DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy);
|
||||||
|
|
||||||
if (mappedProp == null) {
|
if (mappedProp == null) {
|
||||||
@@ -1433,14 +1433,14 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
* Return the changeLogPrepare (for setting user context into the ChangeSet
|
* Return the changeLogPrepare (for setting user context into the ChangeSet
|
||||||
* in the foreground thread).
|
* in the foreground thread).
|
||||||
*/
|
*/
|
||||||
public ChangeLogPrepare getChangeLogPrepare() {
|
public ChangeLogPrepare changeLogPrepare() {
|
||||||
return changeLogPrepare;
|
return changeLogPrepare;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the changeLogListener (that actually does the logging).
|
* Return the changeLogListener (that actually does the logging).
|
||||||
*/
|
*/
|
||||||
public ChangeLogListener getChangeLogListener() {
|
public ChangeLogListener changeLogListener() {
|
||||||
return changeLogListener;
|
return changeLogListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1517,7 +1517,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(BeanDescriptor<?> o1, BeanDescriptor<?> o2) {
|
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.
|
* Return the name of the server/database.
|
||||||
*/
|
*/
|
||||||
String getServerName();
|
String name();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the DatabaseConfig.
|
* Return the DatabaseConfig.
|
||||||
*/
|
*/
|
||||||
DatabaseConfig getConfig();
|
DatabaseConfig config();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Cache Manager.
|
* Return the Cache Manager.
|
||||||
*/
|
*/
|
||||||
SpiCacheManager getCacheManager();
|
SpiCacheManager cacheManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the naming convention.
|
* 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.
|
* 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.
|
* 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.
|
* 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.
|
* Create a IdBinder for this bean property.
|
||||||
@@ -65,12 +65,12 @@ public interface BeanDescriptorMap {
|
|||||||
/**
|
/**
|
||||||
* Return the scalarType for the given JDBC type.
|
* Return the scalarType for the given JDBC type.
|
||||||
*/
|
*/
|
||||||
ScalarType<?> getScalarType(int jdbcType);
|
ScalarType<?> scalarType(int jdbcType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the scalarType for the given logical type.
|
* 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.
|
* Return true if Jackson core is present on the classpath.
|
||||||
|
|||||||
+6
-6
@@ -19,7 +19,7 @@ final class BeanEmbeddedMetaFactory {
|
|||||||
// we can get a BeanDescriptor for an Embedded bean
|
// we can get a BeanDescriptor for an Embedded bean
|
||||||
// and know that it is NOT recursive, as Embedded beans are
|
// and know that it is NOT recursive, as Embedded beans are
|
||||||
// only allow to hold simple scalar types...
|
// only allow to hold simple scalar types...
|
||||||
BeanDescriptor<?> targetDesc = owner.getBeanDescriptor(prop.getTargetType());
|
BeanDescriptor<?> targetDesc = owner.descriptor(prop.getTargetType());
|
||||||
if (targetDesc == null) {
|
if (targetDesc == null) {
|
||||||
String msg = "Could not find BeanDescriptor for " + prop.getTargetType()
|
String msg = "Could not find BeanDescriptor for " + prop.getTargetType()
|
||||||
+ ". Perhaps the EmbeddedId class is not registered? See https://ebean.io/docs/trouble-shooting#not-registered";
|
+ ". Perhaps the EmbeddedId class is not registered? See https://ebean.io/docs/trouble-shooting#not-registered";
|
||||||
@@ -34,7 +34,7 @@ final class BeanEmbeddedMetaFactory {
|
|||||||
BeanProperty[] embeddedProperties = new BeanProperty[sourceProperties.length];
|
BeanProperty[] embeddedProperties = new BeanProperty[sourceProperties.length];
|
||||||
|
|
||||||
for (int i = 0; i < sourceProperties.length; i++) {
|
for (int i = 0; i < sourceProperties.length; i++) {
|
||||||
String propertyName = sourceProperties[i].getName();
|
String propertyName = sourceProperties[i].name();
|
||||||
Column column = propColMap.get(propertyName);
|
Column column = propColMap.get(propertyName);
|
||||||
String dbColumn = dbColumn(columnPrefix, column, sourceProperties[i]);
|
String dbColumn = dbColumn(columnPrefix, column, sourceProperties[i]);
|
||||||
boolean dbNullable = dbNullable(column, sourceProperties[i]);
|
boolean dbNullable = dbNullable(column, sourceProperties[i]);
|
||||||
@@ -49,7 +49,7 @@ final class BeanEmbeddedMetaFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String dbColumn(String prefix, Column override, BeanProperty source) {
|
private static String dbColumn(String prefix, Column override, BeanProperty source) {
|
||||||
String dbCol = (override != null && !override.name().isEmpty()) ? override.name() : source.getDbColumn();
|
String dbCol = (override != null && !override.name().isEmpty()) ? override.name() : source.dbColumn();
|
||||||
return prefix == null ? dbCol : prefix + dbCol;
|
return prefix == null ? dbCol : prefix + dbCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,15 +58,15 @@ final class BeanEmbeddedMetaFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int dbLength(Column override, BeanProperty source) {
|
private static int dbLength(Column override, BeanProperty source) {
|
||||||
return (override != null && (override.length() != 255)) ? override.length() : source.getDbLength();
|
return (override != null && (override.length() != 255)) ? override.length() : source.dbLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int dbScale(Column override, BeanProperty source) {
|
private static int dbScale(Column override, BeanProperty source) {
|
||||||
return (override != null && (override.scale() != 0)) ? override.scale() : source.getDbScale();
|
return (override != null && (override.scale() != 0)) ? override.scale() : source.dbScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getDbColumnDefn(Column override, BeanProperty source) {
|
private static String getDbColumnDefn(Column override, BeanProperty source) {
|
||||||
return (override != null && !override.columnDefinition().isEmpty()) ? override.columnDefinition() : source.getDbColumnDefn();
|
return (override != null && !override.columnDefinition().isEmpty()) ? override.columnDefinition() : source.dbColumnDefn();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFetchPreference() {
|
public int fetchPreference() {
|
||||||
// return some decently high value
|
// return some decently high value
|
||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
@@ -101,17 +101,17 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDbColumn() {
|
public String dbColumn() {
|
||||||
return dbColumn;
|
return dbColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String name() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getElName() {
|
public String elName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
|||||||
* Returns null as not an AssocOne.
|
* Returns null as not an AssocOne.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object[] getAssocIdValues(EntityBean value) {
|
public Object[] assocIdValues(EntityBean value) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
|||||||
* Returns null as not an AssocOne.
|
* Returns null as not an AssocOne.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getAssocIdExpression(String prefix, String operator) {
|
public String assocIdExpression(String prefix, String operator) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
|||||||
* Returns null as not an AssocOne.
|
* Returns null as not an AssocOne.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getAssocIdInExpr(String prefix) {
|
public String assocIdInExpr(String prefix) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,12 +143,12 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
|||||||
* Returns null as not an AssocOne.
|
* Returns null as not an AssocOne.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getAssocIdInValueExpr(boolean not, int size) {
|
public String assocIdInValueExpr(boolean not, int size) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAssocIsEmpty(SpiExpressionRequest request, String path) {
|
public String assocIsEmpty(SpiExpressionRequest request, String path) {
|
||||||
throw new RuntimeException("Not Supported or Expected");
|
throw new RuntimeException("Not Supported or Expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,12 +171,12 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getElPlaceholder(boolean encrypted) {
|
public String elPlaceholder(boolean encrypted) {
|
||||||
return placeHolder;
|
return placeHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getElPrefix() {
|
public String elPrefix() {
|
||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,12 +186,12 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getJdbcType() {
|
public int jdbcType() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BeanProperty getBeanProperty() {
|
public BeanProperty beanProperty() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringParser getStringParser() {
|
public StringParser stringParser() {
|
||||||
throw new RuntimeException("ElPropertyDeploy only - not implemented");
|
throw new RuntimeException("ElPropertyDeploy only - not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Property getProperty() {
|
public Property property() {
|
||||||
throw new RuntimeException("ElPropertyDeploy only - not implemented");
|
throw new RuntimeException("ElPropertyDeploy only - not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -208,7 +208,7 @@ final class BeanLifecycleAdapterFactory {
|
|||||||
|
|
||||||
private void invoke(Method[] methods, BeanPersistRequest<?> request) {
|
private void invoke(Method[] methods, BeanPersistRequest<?> request) {
|
||||||
for (Method method : methods) {
|
for (Method method : methods) {
|
||||||
invoke(method, request.getBean());
|
invoke(method, request.bean());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class BeanListHelp<T> extends BaseCollectionHelp<T> {
|
|||||||
public BeanCollection<T> createEmpty(EntityBean parentBean) {
|
public BeanCollection<T> createEmpty(EntityBean parentBean) {
|
||||||
BeanList<T> beanList = new BeanList<>(loader, parentBean, propertyName);
|
BeanList<T> beanList = new BeanList<>(loader, parentBean, propertyName);
|
||||||
if (many != null) {
|
if (many != null) {
|
||||||
beanList.setModifyListening(many.getModifyListenMode());
|
beanList.setModifyListening(many.modifyListenMode());
|
||||||
}
|
}
|
||||||
return beanList;
|
return beanList;
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ public class BeanListHelp<T> extends BaseCollectionHelp<T> {
|
|||||||
public BeanCollection<T> createReference(EntityBean parentBean) {
|
public BeanCollection<T> createReference(EntityBean parentBean) {
|
||||||
|
|
||||||
BeanList<T> beanList = new BeanList<>(loader, parentBean, propertyName);
|
BeanList<T> beanList = new BeanList<>(loader, parentBean, propertyName);
|
||||||
beanList.setModifyListening(many.getModifyListenMode());
|
beanList.setModifyListening(many.modifyListenMode());
|
||||||
return beanList;
|
return beanList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ public class BeanListHelp<T> extends BaseCollectionHelp<T> {
|
|||||||
|
|
||||||
List<?> currentList = (List<?>) many.getValue(parentBean);
|
List<?> currentList = (List<?>) many.getValue(parentBean);
|
||||||
|
|
||||||
newBeanList.setModifyListening(many.getModifyListenMode());
|
newBeanList.setModifyListening(many.modifyListenMode());
|
||||||
|
|
||||||
if (currentList == null) {
|
if (currentList == null) {
|
||||||
// the currentList is null? Not really expecting this...
|
// the currentList is null? Not really expecting this...
|
||||||
@@ -87,7 +87,7 @@ public class BeanListHelp<T> extends BaseCollectionHelp<T> {
|
|||||||
// normally this case, replace just the underlying list
|
// normally this case, replace just the underlying list
|
||||||
BeanList<?> currentBeanList = (BeanList<?>) currentList;
|
BeanList<?> currentBeanList = (BeanList<?>) currentList;
|
||||||
currentBeanList.setActualList(newBeanList.getActualList());
|
currentBeanList.setActualList(newBeanList.getActualList());
|
||||||
currentBeanList.setModifyListening(many.getModifyListenMode());
|
currentBeanList.setModifyListening(many.modifyListenMode());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// replace the entire list with the BeanList
|
// replace the entire list with the BeanList
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
|||||||
*/
|
*/
|
||||||
BeanMapHelp(BeanPropertyAssocMany<T> many) {
|
BeanMapHelp(BeanPropertyAssocMany<T> many) {
|
||||||
this.many = many;
|
this.many = many;
|
||||||
this.targetDescriptor = many.getTargetDescriptor();
|
this.targetDescriptor = many.targetDescriptor();
|
||||||
this.propertyName = many.getName();
|
this.propertyName = many.name();
|
||||||
this.beanProperty = targetDescriptor.getBeanProperty(many.getMapKey());
|
this.beanProperty = targetDescriptor.beanProperty(many.mapKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -39,9 +39,9 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
|||||||
public BeanCollectionAdd getBeanCollectionAdd(Object bc, String mapKey) {
|
public BeanCollectionAdd getBeanCollectionAdd(Object bc, String mapKey) {
|
||||||
|
|
||||||
if (mapKey == null) {
|
if (mapKey == null) {
|
||||||
mapKey = many.getMapKey();
|
mapKey = many.mapKey();
|
||||||
}
|
}
|
||||||
BeanProperty beanProp = targetDescriptor.getBeanProperty(mapKey);
|
BeanProperty beanProp = targetDescriptor.beanProperty(mapKey);
|
||||||
|
|
||||||
if (bc instanceof BeanMap<?, ?>) {
|
if (bc instanceof BeanMap<?, ?>) {
|
||||||
BeanMap<Object, Object> bm = (BeanMap<Object, Object>) bc;
|
BeanMap<Object, Object> bm = (BeanMap<Object, Object>) bc;
|
||||||
@@ -85,7 +85,7 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
|||||||
|
|
||||||
BeanMap<?, T> beanMap = new BeanMap<>(loader, ownerBean, propertyName);
|
BeanMap<?, T> beanMap = new BeanMap<>(loader, ownerBean, propertyName);
|
||||||
if (many != null) {
|
if (many != null) {
|
||||||
beanMap.setModifyListening(many.getModifyListenMode());
|
beanMap.setModifyListening(many.modifyListenMode());
|
||||||
}
|
}
|
||||||
return beanMap;
|
return beanMap;
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
|||||||
|
|
||||||
BeanMap beanMap = new BeanMap(loader, parentBean, propertyName);
|
BeanMap beanMap = new BeanMap(loader, parentBean, propertyName);
|
||||||
if (many != null) {
|
if (many != null) {
|
||||||
beanMap.setModifyListening(many.getModifyListenMode());
|
beanMap.setModifyListening(many.modifyListenMode());
|
||||||
}
|
}
|
||||||
return beanMap;
|
return beanMap;
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
|||||||
BeanMap<?, ?> newBeanMap = (BeanMap<?, ?>) bc;
|
BeanMap<?, ?> newBeanMap = (BeanMap<?, ?>) bc;
|
||||||
Map<?, ?> current = (Map<?, ?>) many.getValue(parentBean);
|
Map<?, ?> current = (Map<?, ?>) many.getValue(parentBean);
|
||||||
|
|
||||||
newBeanMap.setModifyListening(many.getModifyListenMode());
|
newBeanMap.setModifyListening(many.modifyListenMode());
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
// the currentMap is null? Not really expecting this...
|
// the currentMap is null? Not really expecting this...
|
||||||
many.setValue(parentBean, newBeanMap);
|
many.setValue(parentBean, newBeanMap);
|
||||||
@@ -134,7 +134,7 @@ public class BeanMapHelp<T> extends BaseCollectionHelp<T> {
|
|||||||
// normally this case, replace just the underlying list
|
// normally this case, replace just the underlying list
|
||||||
BeanMap<?, ?> currentBeanMap = (BeanMap<?, ?>) current;
|
BeanMap<?, ?> currentBeanMap = (BeanMap<?, ?>) current;
|
||||||
currentBeanMap.setActualMap(newBeanMap.getActualMap());
|
currentBeanMap.setActualMap(newBeanMap.getActualMap());
|
||||||
currentBeanMap.setModifyListening(many.getModifyListenMode());
|
currentBeanMap.setModifyListening(many.modifyListenMode());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// replace the entire set
|
// replace the entire set
|
||||||
|
|||||||
Loaded 100 of 2057 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user