Merge branch 'master' into wip/EntityBeanIntercept-interface

This commit is contained in:
Rob Bygrave
2022-04-12 21:09:58 +12:00
committed by GitHub
140 changed files with 1072 additions and 1581 deletions
@@ -74,40 +74,16 @@ public interface BeanState {
*/
Set<String> loadedProps();
/**
* Deprecated migrate to loadedProps().
*/
@Deprecated
default Set<String> getLoadedProps() {
return loadedProps();
}
/**
* Return the set of changed properties.
*/
Set<String> changedProps();
/**
* Deprecated migrate to changedProps().
*/
@Deprecated
default Set<String> getChangedProps() {
return changedProps();
}
/**
* Return a map of the updated properties and their new and old values.
*/
Map<String, ValuePair> dirtyValues();
/**
* Deprecated migrate to dirtyValues().
*/
@Deprecated
default Map<String, ValuePair> getDirtyValues() {
return dirtyValues();
}
/**
* Return true if the bean is readOnly.
* <p>
@@ -139,24 +115,9 @@ public interface BeanState {
*/
Map<String, Exception> loadErrors();
/**
* Deprecated migrate to loadErrors().
*/
@Deprecated
default Map<String, Exception> getLoadErrors() {
return loadErrors();
}
/**
* Return the sort order value for an order column.
*/
int sortOrder();
/**
* Deprecated migrate to sortOrder().
*/
@Deprecated
default int getSortOrder() {
return sortOrder();
}
}
+19 -133
View File
@@ -22,10 +22,9 @@ import java.util.concurrent.Callable;
* DB additionally provides a convenient way to use the 'default' Database.
* <p>
* <h3>Default database</h3>
* <p>
* One of the Database instances can be registered as the "default database"
* and can be obtained using <code>DB.getDefault()</code>
* </p>
*
* <pre>{@code
*
* Database database = DB.getDefault();
@@ -36,7 +35,7 @@ import java.util.concurrent.Callable;
* <p>
* Multiple database instances can be registered with DB and we can obtain them
* using <code>DB.byName()</code>
* </p>
*
* <pre>{@code
*
* Database hrDatabase = DB.byName("hr");
@@ -47,7 +46,6 @@ import java.util.concurrent.Callable;
* <p>
* DB has methods like {@link #find(Class)} and {@link #save(Object)} which are
* just convenience for using the default database.
* </p>
*
* <pre>{@code
*
@@ -117,39 +115,26 @@ public final class DB {
* build the WHERE and HAVING clauses. Alternatively you can use the
* ExpressionFactory directly to create expressions to add to the query where
* clause.
* </p>
* <p>
* Alternatively you can use the {@link Expr} as a shortcut to the
* ExpressionFactory of the 'Default' database.
* </p>
* <p>
* You generally need to the an ExpressionFactory (or {@link Expr}) to build
* an expression that uses OR like Expression e = Expr.or(..., ...);
* </p>
*/
public static ExpressionFactory expressionFactory() {
return getDefault().expressionFactory();
}
/**
* Deprecated migrate to expressionFactory().
*/
@Deprecated
public static ExpressionFactory getExpressionFactory() {
return expressionFactory();
}
/**
* Return the next identity value for a given bean type.
* <p>
* This will only work when a IdGenerator is on this bean type such as a DB
* sequence or UUID.
* </p>
* <p>
* For DB's supporting getGeneratedKeys and sequences such as Oracle10 you do
* not need to use this method generally. It is made available for more
* complex cases where it is useful to get an ID prior to some processing.
* </p>
*/
public static Object nextId(Class<?> beanType) {
return getDefault().nextId(beanType);
@@ -159,17 +144,14 @@ public final class DB {
* Start a transaction with 'REQUIRED' semantics.
* <p>
* With REQUIRED semantics if an active transaction already exists that transaction will be used.
* </p>
* <p>
* The transaction is stored in a ThreadLocal variable and typically you only
* need to use the returned Transaction <em>IF</em> you wish to do things like
* use batch mode, change the transaction isolation level, use savepoints or
* log comments to the transaction log.
* </p>
* <p>
* Example of using a transaction to span multiple calls to find(), save()
* etc.
* </p>
* Example of using a transaction to span multiple calls to find(), save() etc.
*
* <pre>{@code
*
* try (Transaction transaction = DB.beginTransaction()) {
@@ -187,7 +169,6 @@ public final class DB {
* With Database we can pass the transaction to the various find(), save() and execute()
* methods. This gives us the ability to create the transactions externally from Ebean
* and use the transaction explicitly via the various methods available on Database.
* </p>
*/
public static Transaction beginTransaction() {
return getDefault().beginTransaction();
@@ -199,7 +180,6 @@ public final class DB {
* You will want to do this if you want multiple Transactions in a single
* thread or generally use transactions outside of the TransactionThreadLocal
* management.
* </p>
*/
public static Transaction createTransaction() {
return getDefault().createTransaction();
@@ -219,7 +199,6 @@ public final class DB {
* <p>
* Note that this provides an try finally alternative to using {@link #executeCall(TxScope, Callable)} or
* {@link #execute(TxScope, Runnable)}.
* </p>
* <p>
* <h3>REQUIRES_NEW example:</h3>
* <pre>{@code
@@ -278,7 +257,7 @@ public final class DB {
/**
* Register a TransactionCallback on the currently active transaction.
* <p/>
* <p>
* If there is no currently active transaction then a PersistenceException is thrown.
*
* @param transactionCallback the transaction callback to be registered with the current transaction
@@ -307,14 +286,12 @@ public final class DB {
* rollback the transaction.
* <p>
* It is preferable to use <em>try with resources</em> rather than this.
* </p>
* <p>
* Useful to put in a finally block to ensure the transaction is ended, rather
* than a rollbackTransaction() in each catch block.
* </p>
* <p>
* Code example:
* </p>
*
* <pre>{@code
* DB.beginTransaction();
* try {
@@ -345,7 +322,6 @@ public final class DB {
* <p>
* When null is passed in for b, then the 'OldValues' of a is used for the
* difference comparison.
* </p>
*/
public static Map<String, ValuePair> diff(Object a, Object b) {
return getDefault().diff(a, b);
@@ -356,18 +332,15 @@ public final class DB {
* <p>
* If there is no current transaction one will be created and committed for
* you automatically.
* </p>
* <p>
* Save can cascade along relationships. For this to happen you need to
* specify a cascade of CascadeType.ALL or CascadeType.PERSIST on the
* OneToMany, OneToOne or ManyToMany annotation.
* </p>
* <p>
* When a save cascades via a OneToMany or ManyToMany Ebean will automatically
* set the 'parent' object to the 'detail' object. In the example below in
* saving the order and cascade saving the order details the 'parent' order
* will be set against each order detail when it is saved.
* </p>
*/
public static void save(Object bean) throws OptimisticLockException {
getDefault().save(bean);
@@ -418,11 +391,9 @@ public final class DB {
* <b>Stateless updates:</b> Note that the bean does not have to be previously fetched to call
* update().You can create a new instance and set some of its properties programmatically for via
* JSON/XML marshalling etc. This is described as a 'stateless update'.
* </p>
* <p>
* <b>Optimistic Locking: </b> Note that if the version property is not set when update() is
* called then no optimistic locking is performed (internally ConcurrencyMode.NONE is used).
* </p>
* <p>
* <pre>{@code
*
@@ -539,20 +510,16 @@ public final class DB {
* Delete the bean.
* <p>
* This will return true if the bean was deleted successfully or JDBC batch is being used.
* </p>
* <p>
* If there is no current transaction one will be created and committed for
* you automatically.
* </p>
* <p>
* If the bean is configured with <code>@SoftDelete</code> then this will perform a soft
* delete rather than a hard/permanent delete.
* </p>
* <p>
* If the Bean does not have a version property (or loaded version property) and
* the bean does not exist then this returns false indicating that nothing was
* deleted. Note that, if JDBC batch mode is used then this always returns true.
* </p>
*/
public static boolean delete(Object bean) throws OptimisticLockException {
return getDefault().delete(bean);
@@ -612,7 +579,6 @@ public final class DB {
* <p>
* Note that this resets OneToMany and ManyToMany properties so that if they
* are accessed a lazy load will refresh the many property.
* </p>
*/
public static void refresh(Object bean) {
getDefault().refresh(bean);
@@ -620,6 +586,7 @@ public final class DB {
/**
* Refresh a 'many' property of a bean.
*
* <pre>{@code
*
* Order order = ...;
@@ -640,7 +607,7 @@ public final class DB {
* Get a reference object.
* <p>
* This is sometimes described as a proxy (with lazy loading).
* </p>
*
* <pre>{@code
*
* Product product = DB.getReference(Product.class, 1);
@@ -661,14 +628,6 @@ public final class DB {
return getDefault().reference(beanType, id);
}
/**
* Deprecated migrate to beanId().
*/
@Deprecated
public static <T> T getReference(Class<T> beanType, Object id) {
return reference(beanType, id);
}
/**
* Sort the list using the sortByClause which can contain a comma delimited
* list of property names and keywords asc, desc, nullsHigh and nullsLow.
@@ -684,7 +643,7 @@ public final class DB {
* <p>
* Note that the sorting uses a Comparator and Collections.sort(); and does
* not invoke a DB query.
* </p>
*
* <pre>{@code
*
* // find orders and their customers
@@ -719,9 +678,8 @@ public final class DB {
*
* }</pre>
* <p>
* If you want more control over the query then you can use createQuery() and
* Query.findOne();
* </p>
* If you want more control over the query then you can use createQuery() and Query.findOne();
*
* <pre>{@code
*
* // ... additionally fetching customer, customer shipping address,
@@ -761,40 +719,25 @@ public final class DB {
}
/**
* Look to execute a native sql query that does not returns beans but instead
* returns SqlRow or direct access to ResultSet (see {@link SqlQuery#findList(RowMapper)}.
*
* Look to execute a native sql query that does not return beans but instead
* returns SqlRow or uses {@link RowMapper}.
* <p>
* Refer to {@link DtoQuery} for native sql queries returning DTO beans.
* </p>
* <p>
* Refer to {@link #findNative(Class, String)} for native sql queries returning entity beans.
* </p>
*/
public static SqlQuery sqlQuery(String sql) {
return getDefault().sqlQuery(sql);
}
/**
* Deprecated - migrate to sqlQuery().
* <p>
* This is an alias for {@link #sqlQuery(String)}.
*/
@Deprecated
public static SqlQuery createSqlQuery(String sql) {
return sqlQuery(sql);
}
/**
* Look to execute a native sql insert update or delete statement.
* <p>
* Use this to execute a Insert Update or Delete statement. The statement will
* be native to the database and contain database table and column names.
* </p>
*
* <p>
* See {@link SqlUpdate} for example usage.
* </p>
*
* @return The SqlUpdate instance to set parameters and execute
*/
@@ -802,16 +745,6 @@ public final class DB {
return getDefault().sqlUpdate(sql);
}
/**
* Deprecated - migrate to sqlUpdate().
* <p>
* This is an alias for {@link #sqlUpdate(String)}.
*/
@Deprecated
public static SqlUpdate createSqlUpdate(String sql) {
return sqlUpdate(sql);
}
/**
* Create a CallableSql to execute a given stored procedure.
*
@@ -828,10 +761,9 @@ public final class DB {
* <p>
* The orm update differs from the sql update in that it you can use the bean
* name and bean property names rather than table and column names.
* </p>
* <p>
* An example:
* </p>
*
* <pre>{@code
*
* // The bean name and properties - "topic","postCount" and "id"
@@ -864,7 +796,6 @@ public final class DB {
* Create a named query.
* <p>
* For RawSql the named query is expected to be in ebean.xml.
* </p>
*
* @param beanType The type of entity bean
* @param namedQuery The name of the query
@@ -880,15 +811,12 @@ public final class DB {
* <p>
* You can use the methods on the Query object to specify fetch paths,
* predicates, order by, limits etc.
* </p>
* <p>
* You then use findList(), findSet(), findMap() and findOne() to execute
* the query and return the collection or bean.
* </p>
* <p>
* Note that a query executed by {@link Query#findList()} etc will execute against
* the same database from which is was created.
* </p>
*
* @param beanType the class of entity to be fetched
* @return A ORM Query for this beanType
@@ -940,7 +868,6 @@ public final class DB {
* This is actually the same as {@link #createQuery(Class)}. The reason it
* exists is that people used to JPA will probably be looking for a
* createQuery method (the same as entityManager).
* </p>
*
* @param beanType the type of entity bean to find
* @return A ORM Query object for this beanType
@@ -953,7 +880,7 @@ public final class DB {
* Create a query using native SQL.
* <p>
* The native SQL can contain named parameters or positioned parameters.
* </p>
*
* <pre>{@code
*
* String sql = "select c.id, c.name from customer c where c.name like ? order by c.name";
@@ -978,7 +905,6 @@ public final class DB {
* <p>
* DTO beans are just normal bean like classes with public constructor(s) and setters.
* They do not need to be registered with Ebean before use.
* </p>
*
* @param dtoType The type of the DTO bean the rows will be mapped into.
* @param sql The SQL query to execute.
@@ -1015,10 +941,8 @@ public final class DB {
* going back to the database.
* <p>
* This produces and returns a new list with the sort and filters applied.
* </p>
* <p>
* Refer to {@link Filter} for an example of its use.
* </p>
*/
public static <T> Filter<T> filter(Class<T> beanType) {
return getDefault().filter(beanType);
@@ -1029,7 +953,7 @@ public final class DB {
* <p>
* The scope can control the transaction type, isolation and rollback
* semantics.
* </p>
*
* <pre>{@code
*
* // set specific transactional scope settings
@@ -1053,7 +977,7 @@ public final class DB {
* <p>
* The default scope runs with REQUIRED and by default will rollback on any
* exception (checked or runtime).
* </p>
*
* <pre>{@code
*
* DB.execute(() -> {
@@ -1078,7 +1002,7 @@ public final class DB {
* <p>
* The scope can control the transaction type, isolation and rollback
* semantics.
* </p>
*
* <pre>{@code
*
* // set specific transactional scope settings
@@ -1102,11 +1026,10 @@ public final class DB {
* <p>
* The default scope runs with REQUIRED and by default will rollback on any
* exception (checked or runtime).
* </p>
* <p>
* This is basically the same as TxRunnable except that it returns an Object
* (and you specify the return type via generics).
* </p>
*
* <pre>{@code
*
* DB.executeCall(() -> {
@@ -1135,23 +1058,19 @@ public final class DB {
* <p>
* If you use DB.execute(UpdateSql) then the table modification information
* is automatically deduced and you do not need to call this method yourself.
* </p>
* <p>
* This information is used to invalidate objects out of the cache and
* potentially text indexes. This information is also automatically broadcast
* across the cluster.
* </p>
* <p>
* If there is a transaction then this information is placed into the current
* transactions event information. When the transaction is committed this
* information is registered (with the transaction manager). If this
* transaction is rolled back then none of the transaction event information
* registers including the information you put in via this method.
* </p>
* <p>
* If there is NO current transaction when you call this method then this
* information is registered immediately (with the transaction manager).
* </p>
*
* @param tableName the name of the table that was modified
* @param inserts true if rows where inserted into the table
@@ -1166,20 +1085,11 @@ public final class DB {
* Return the BeanState for a given entity bean.
* <p>
* This will return null if the bean is not an enhanced entity bean.
* </p>
*/
public static BeanState beanState(Object bean) {
return getDefault().beanState(bean);
}
/**
* Deprecated migrate to beanState().
*/
@Deprecated
public static BeanState getBeanState(Object bean) {
return beanState(bean);
}
/**
* Return the value of the Id property for a given bean.
*/
@@ -1187,14 +1097,6 @@ public final class DB {
return getDefault().beanId(bean);
}
/**
* Deprecated migrate to beanId().
*/
@Deprecated
public static Object getBeanId(Object bean) {
return beanId(bean);
}
/**
* Load and lock the bean using {@code select for update}.
* <p>
@@ -1210,14 +1112,6 @@ public final class DB {
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).
*/
@@ -1233,14 +1127,6 @@ public final class DB {
return getDefault().backgroundExecutor();
}
/**
* Deprecated migrate to backgroundExecutor().
*/
@Deprecated
public static BackgroundExecutor getBackgroundExecutor() {
return backgroundExecutor();
}
/**
* Return the JsonContext for reading/writing JSON.
*/
@@ -123,81 +123,33 @@ public interface Database {
*/
AutoTune autoTune();
/**
* Deprecated migrate to autoTune().
*/
@Deprecated
default AutoTune getAutoTune() {
return autoTune();
}
/**
* Return the associated DataSource for this Database instance.
*/
DataSource dataSource();
/**
* Deprecated migrate to dataSource().
*/
@Deprecated
default DataSource getDataSource() {
return dataSource();
}
/**
* Return the associated read only DataSource for this Database instance (can be null).
*/
DataSource readOnlyDataSource();
/**
* Deprecated migrate to readOnlyDataSource().
*/
@Deprecated
default DataSource getReadOnlyDataSource() {
return readOnlyDataSource();
}
/**
* Return the name. This is used with {@link DB#byName(String)} to get a
* Database that was registered with the DB singleton.
*/
String name();
/**
* Deprecated migrate to name().
*/
@Deprecated
default String getName() {
return name();
}
/**
* Return the ExpressionFactory for this database.
*/
ExpressionFactory expressionFactory();
/**
* Deprecated migrate to expressionFactory().
*/
@Deprecated
default ExpressionFactory getExpressionFactory() {
return expressionFactory();
}
/**
* Return the MetaInfoManager which is used to get meta data from the Database
* such as query execution statistics.
*/
MetaInfoManager metaInfo();
/**
* Deprecated migrate to metaInfo().
*/
@Deprecated
default MetaInfoManager getMetaInfoManager() {
return metaInfo();
}
/**
* Return the platform used for this database instance.
* <p>
@@ -217,27 +169,11 @@ public interface Database {
*/
Platform platform();
/**
* Deprecated migrate to platform().
*/
@Deprecated
default Platform getPlatform() {
return platform();
}
/**
* Return the extended API intended for use by plugins.
*/
SpiServer pluginApi();
/**
* Deprecated migrate to pluginApi().
*/
@Deprecated
default SpiServer getPluginApi() {
return pluginApi();
}
/**
* Return the BeanState for a given entity bean.
* <p>
@@ -246,27 +182,11 @@ public interface Database {
*/
BeanState beanState(Object bean);
/**
* Deprecated migrate to beanState().
*/
@Deprecated
default BeanState getBeanState(Object bean) {
return beanState(bean);
}
/**
* Return the value of the Id property for a given bean.
*/
Object 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.
* <p>
@@ -279,14 +199,6 @@ public interface Database {
*/
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.
* <p>
@@ -588,14 +500,6 @@ public interface Database {
*/
SqlQuery sqlQuery(String sql);
/**
* Deprecated - migrate to sqlQuery().
* <p>
* This is an alias for {@link #sqlQuery(String)}.
*/
@Deprecated
SqlQuery createSqlQuery(String sql);
/**
* Look to execute a native sql insert update or delete statement.
* <p>
@@ -611,14 +515,6 @@ public interface Database {
*/
SqlUpdate sqlUpdate(String sql);
/**
* Deprecated - migrate to sqlUpdate().
* <p>
* This is an alias for {@link #sqlUpdate(String)}.
*/
@Deprecated
SqlUpdate createSqlUpdate(String sql);
/**
* Create a CallableSql to execute a given stored procedure.
*/
@@ -952,14 +848,6 @@ public interface Database {
*/
<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.
* <p>
@@ -1528,28 +1416,12 @@ public interface Database {
*/
ServerCacheManager cacheManager();
/**
* Deprecated migrate to cacheManager().
*/
@Deprecated
default ServerCacheManager getServerCacheManager() {
return cacheManager();
}
/**
* Return the BackgroundExecutor service for asynchronous processing of
* queries.
*/
BackgroundExecutor backgroundExecutor();
/**
* Deprecated migrate to backgroundExecutor().
*/
@Deprecated
default BackgroundExecutor getBackgroundExecutor() {
return backgroundExecutor();
}
/**
* Return the JsonContext for reading/writing JSON.
* <p>
@@ -26,7 +26,7 @@ import java.util.concurrent.locks.ReentrantLock;
* methods on the DB singleton such as {@link DB#find(Class)} are just a
* convenient way of using the 'default/primary' Database.
*/
public class DatabaseFactory {
public final class DatabaseFactory {
private static final ReentrantLock lock = new ReentrantLock();
private static SpiContainer container;
@@ -10,7 +10,7 @@ import java.util.concurrent.locks.ReentrantLock;
* <p/>
* Intended for internal use as part of bootup, construction, registration of the default database.
*/
class DbPrimary {
final class DbPrimary {
private static final ReentrantLock lock = new ReentrantLock();
private static String defaultServerName;
@@ -12,7 +12,7 @@ import java.util.Properties;
*
* @author Roland Praml, FOCONIS AG
*/
public class EbeanVersion {
public final class EbeanVersion {
private static final Logger log = LoggerFactory.getLogger("io.ebean");
+1 -1
View File
@@ -25,7 +25,7 @@ import java.util.Map;
*
* @see Query#where()
*/
public class Expr {
public final class Expr {
private Expr() {
}
@@ -112,19 +112,6 @@ public interface ExtendedServer {
*/
<T> Stream<T> findStream(Query<T> query, Transaction transaction);
/**
* Deprecated - migrate to findStream().
* <p>
* Execute the query returning the result as a Stream.
* <p>
* Note that this can support very large queries iterating any number of results.
* To do so internally it can use multiple persistence contexts.
* <p>
* Note that the stream needs to be closed so use with try with resources.
*/
@Deprecated
<T> Stream<T> findLargeStream(Query<T> query, Transaction transaction);
/**
* Execute the query visiting the each bean one at a time.
* <p>
@@ -31,7 +31,7 @@ import java.io.Serializable;
* @author mario
* @author rbygrave
*/
public class FetchConfig implements Serializable {
public final class FetchConfig implements Serializable {
private static final long serialVersionUID = 1L;
@@ -750,29 +750,6 @@ public interface Query<T> extends CancelableQuery {
*/
Stream<T> findStream();
/**
* Deprecated - migrate to findStream.
* <p>
* Execute the query returning the result as a Stream.
* <p>
* Note that this uses multiple persistence contexts such that we can use
* it with a large number of results.
* </p>
* <pre>{@code
*
* // use try with resources to ensure Stream is closed
*
* try (Stream<Customer> stream = query.findLargeStream()) {
* stream
* .map(...)
* .collect(...);
* }
*
* }</pre>
*/
@Deprecated
Stream<T> findLargeStream();
/**
* Execute the query processing the beans one at a time.
* <p>
@@ -74,18 +74,6 @@ public interface SqlQuery extends Serializable, CancelableQuery {
@Nullable
SqlRow findOne();
/**
* Deprecated migrate to use {@link #mapTo(RowMapper)}
*/
@Deprecated
<T> T findOne(RowMapper<T> mapper);
/**
* Deprecated migrate to use {@link #mapTo(RowMapper)}
*/
@Deprecated
<T> List<T> findList(RowMapper<T> mapper);
/**
* Execute the query reading each row from ResultSet using the RowConsumer.
* <p>
@@ -121,50 +109,6 @@ public interface SqlQuery extends Serializable, CancelableQuery {
*/
Optional<SqlRow> findOneOrEmpty();
/**
* Deprecated - migrate to <code>.mapToScalar(attributeType).findOne()</code>.
* <pre>{@code
*
* .mapToScalar(BigDecimal.class)
* .findOne();
* }
*/
@Deprecated
<T> T findSingleAttribute(Class<T> attributeType);
/**
* Deprecated - migrate to <code>.mapToScalar(BigDecimal.class).findOne()</code>.
* <pre>{@code
*
* .mapToScalar(BigDecimal.class)
* .findOne();
* }
*/
@Deprecated
BigDecimal findSingleDecimal();
/**
* Deprecated - migrate to <code>.mapToScalar(Long.class).findOne()</code>.
* <pre>{@code
*
* .mapToScalar(Long.class)
* .findOne();
* }
*/
@Deprecated
Long findSingleLong();
/**
* Deprecated - migrate to <code>.mapToScalar(Long.class).findList()</code>.
* <pre>{@code
*
* .mapToScalar(Long.class)
* .findList();
* }
*/
@Deprecated
<T> List<T> findSingleAttributeList(Class<T> attributeType);
/**
* Set one of more positioned parameters.
* <p>
@@ -194,12 +138,6 @@ public interface SqlQuery extends Serializable, CancelableQuery {
*/
SqlQuery setParameters(Object... values);
/**
* Deprecated migrate to setParameters(Object... values)
*/
@Deprecated
SqlQuery setParams(Object... values);
/**
* Set the next bind parameter by position.
* <pre>{@code
@@ -287,12 +287,6 @@ public interface SqlUpdate {
*/
SqlUpdate setParameters(Object... values);
/**
* Deprecated migrate to setParameters(Object... values).
*/
@Deprecated
SqlUpdate setParams(Object... values);
/**
* Set the next bind parameter by position.
*
@@ -300,12 +294,6 @@ public interface SqlUpdate {
*/
SqlUpdate setParameter(Object value);
/**
* Deprecated migrate to setParameter(value).
*/
@Deprecated
SqlUpdate setNextParameter(Object value);
/**
* Set a parameter via its index position.
*/
@@ -11,7 +11,7 @@ import java.util.ServiceLoader;
/**
* Lookup internal services.
*/
class XServiceProvider {
final class XServiceProvider {
private static SpiRawSqlService rawSqlService = initRawSql();
@@ -18,7 +18,7 @@ import java.util.Set;
* <em>java.util.Collection</em>. The reason being that java.util.Map is not a
* Collection. I realise this makes this name confusing so I apologise for that.
*/
public interface BeanCollection<E> extends Serializable {
public interface BeanCollection<E> extends Serializable, ToStringAware {
enum ModifyListenMode {
/**
@@ -11,7 +11,7 @@ import java.io.Serializable;
* general application consumption.
* </p>
*/
public interface EntityBean extends Serializable {
public interface EntityBean extends Serializable, ToStringAware {
/**
* Return all the property names in defined order.
@@ -116,4 +116,8 @@ public interface EntityBean extends Serializable {
throw new NotEnhancedException();
}
@Override
default void toString(ToStringBuilder builder) {
throw new NotEnhancedException();
}
}
@@ -0,0 +1,12 @@
package io.ebean.bean;
/**
* A type that can participate in building toString content with ToStringBuilder.
*/
public interface ToStringAware {
/**
* Append to the ToStringBuilder.
*/
void toString(ToStringBuilder builder);
}
@@ -0,0 +1,163 @@
package io.ebean.bean;
import java.util.Collection;
import java.util.IdentityHashMap;
/**
* Helps build toString content taking into account recursion.
* <p>
* That is, it detects and handles the case where there are relationships that recurse
* and would otherwise become an infinite loop (e.g. bidirectional parent child).
*/
public final class ToStringBuilder {
/**
* The max number of objects that we allow before stopping content being appended.
*/
private static final int MAX = 100;
/**
* Max length of content in string form added for any given value.
*/
private static final int TRIM_LENGTH = 500;
/**
* The max total content after which we stop content being appended.
*/
private static final int MAX_TOTAL_CONTENT = 2000;
private final IdentityHashMap<Object, Integer> id = new IdentityHashMap<>();
private final StringBuilder sb = new StringBuilder(50);
private boolean first = true;
private int counter;
@Override
public String toString() {
return sb.toString();
}
/**
* Set of an object being added.
*/
public void start(Object bean) {
if (counter == 0) {
id.putIfAbsent(bean, 0);
}
if (counter <= MAX) {
sb.append(bean.getClass().getSimpleName()).append("@").append(counter).append("(");
}
}
/**
* Add a property as name value pair.
*/
public void add(String name, Object value) {
if (value != null && counter <= MAX) {
if (value instanceof BeanCollection) {
if (((BeanCollection<?>)value).isReference()) {
// suppress unloaded bean collections
return;
}
}
key(name);
value(value);
}
}
/**
* Add raw content.
*/
public void addRaw(String content) {
sb.append(content);
}
/**
* End of an object.
*/
public void end() {
if (counter <= MAX) {
sb.append(")");
}
}
private void key(String name) {
if (counter > MAX) {
return;
}
if (first) {
first = false;
} else {
sb.append(", ");
}
sb.append(name).append(":");
}
private void value(Object value) {
if (counter > MAX) {
return;
}
if (value instanceof ToStringAware) {
if (value instanceof BeanCollection) {
((ToStringAware) value).toString(this);
} else if (push(value)) {
((ToStringAware) value).toString(this);
}
} else if (value instanceof Collection) {
addCollection((Collection<?>) value);
} else {
String content = String.valueOf(value);
if (content.length() > TRIM_LENGTH) {
content = content.substring(0, TRIM_LENGTH) + " <trimmed>";
}
sb.append(content);
if (sb.length() >= MAX_TOTAL_CONTENT) {
sb.append(" ...");
counter += MAX;
}
}
}
/**
* Add a collection of values.
*/
public void addCollection(Collection<?> c) {
if (c == null || c.isEmpty()) {
sb.append("[]");
return;
}
boolean firstElement = true;
sb.append("[");
for (Object o : c) {
if (firstElement) {
firstElement = false;
} else {
sb.append(", ");
}
value(o);
if (counter > MAX) {
return;
}
}
sb.append("]");
}
private boolean push(Object bean) {
if (counter > MAX) {
return false;
}
if (counter == MAX) {
sb.append(" ...");
counter++;
return false;
}
Integer idx = id.putIfAbsent(bean, counter++);
if (idx != null) {
--counter;
sb.append(bean.getClass().getSimpleName()).append("@").append(idx);
return false;
}
first = true;
return true;
}
}
+15 -15
View File
@@ -1,5 +1,6 @@
package io.ebean.cache;
import io.avaje.lang.Nullable;
import io.ebean.meta.MetricVisitor;
import java.util.LinkedHashMap;
@@ -68,40 +69,39 @@ public interface ServerCache {
/**
* Return the number of entries in the cache.
*/
int size();
default int size() {
return 0;
}
/**
* Return the hit ratio the cache is currently getting.
*/
default int hitRatio() {
return getHitRatio();
return 0;
}
/**
* Deprecated migrate to hitRatio().
*/
@Deprecated
int getHitRatio();
/**
* Return statistics for the cache.
*
* @param reset if true the statistics are reset.
*/
@Nullable
default ServerCacheStatistics statistics(boolean reset) {
return getStatistics(reset);
return null;
}
/**
* Deprecated migrate to statistics().
*/
@Deprecated
ServerCacheStatistics getStatistics(boolean reset);
/**
* Visit the metrics for the cache.
*/
default void visit(MetricVisitor visitor) {
// do nothing by default
}
/**
* Unwrap the underlying ServerCache.
*/
@SuppressWarnings("unchecked")
default <T> T unwrap(Class<T> cls) {
return (T) this;
}
}
@@ -13,6 +13,7 @@ public class ServerCacheConfig {
private final ServerCacheOptions cacheOptions;
private final CurrentTenantProvider tenantProvider;
private final QueryCacheEntryValidate queryCacheEntryValidate;
private final TenantAwareKey tenantAwareKey;
public ServerCacheConfig(ServerCacheType type, String cacheKey, String shortName, ServerCacheOptions cacheOptions, CurrentTenantProvider tenantProvider, QueryCacheEntryValidate queryCacheEntryValidate) {
this.type = type;
@@ -21,6 +22,14 @@ public class ServerCacheConfig {
this.cacheOptions = cacheOptions;
this.tenantProvider = tenantProvider;
this.queryCacheEntryValidate = queryCacheEntryValidate;
this.tenantAwareKey = (tenantProvider == null) ? null : new TenantAwareKey(tenantProvider);
}
/**
* Return the ServerCache taking into account if multi-tenant is used.
*/
public ServerCache tenantAware(ServerCache cache) {
return tenantAwareKey == null ? cache : new TenantAwareCache(cache, tenantAwareKey);
}
/**
@@ -23,14 +23,6 @@ public interface ServerCacheManager {
*/
boolean localL2Caching();
/**
* Deprecated migrate to localL2Caching().
*/
@Deprecated
default boolean isLocalL2Caching() {
return localL2Caching();
}
/**
* Return all the cache regions.
*/
@@ -46,77 +38,36 @@ public interface ServerCacheManager {
*/
void enabledRegions(String regions);
/**
* Deprecated migrate to enabledRegions().
*/
@Deprecated
default void setEnabledRegions(String regions) {
enabledRegions(regions);
}
/**
* Enable or disable all the cache regions.
*/
void allRegionsEnabled(boolean enabled);
/**
* Deprecated migrate to allRegionsEnabled().
*/
@Deprecated
default void setAllRegionsEnabled(boolean enabled) {
allRegionsEnabled(enabled);
}
/**
* Return the cache region by name. Typically, to enable or disable the region.
*/
ServerCacheRegion region(String name);
@Deprecated
default ServerCacheRegion getRegion(String name) {
return region(name);
}
/**
* Return the cache for mapping natural keys to id values.
*/
ServerCache naturalKeyCache(Class<?> beanType);
@Deprecated
default ServerCache getNaturalKeyCache(Class<?> beanType) {
return naturalKeyCache(beanType);
}
/**
* Return the cache for beans of a particular type.
*/
ServerCache beanCache(Class<?> beanType);
@Deprecated
default ServerCache getBeanCache(Class<?> beanType) {
return beanCache(beanType);
}
/**
* Return the cache for associated many properties of a bean type.
*/
ServerCache collectionIdsCache(Class<?> beanType, String propertyName);
@Deprecated
default ServerCache getCollectionIdsCache(Class<?> beanType, String propertyName) {
return collectionIdsCache(beanType, propertyName);
}
/**
* Return the cache for query results of a particular type of bean.
*/
ServerCache queryCache(Class<?> beanType);
@Deprecated
default ServerCache getQueryCache(Class<?> beanType) {
return queryCache(beanType);
}
/**
* This clears both the bean and query cache for a given type.
*/
@@ -10,14 +10,6 @@ public interface ServerCacheRegion {
*/
String name();
/**
* Deprecated migrate to name().
*/
@Deprecated
default String getName() {
return name();
}
/**
* Return true if the cache region is enabled.
*/
@@ -0,0 +1,104 @@
package io.ebean.cache;
import io.ebean.meta.MetricVisitor;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* A ServerCache proxy that is tenant aware.
*/
public final class TenantAwareCache implements ServerCache {
private final ServerCache delegate;
private final TenantAwareKey tenantAwareKey;
/**
* Create given the TenantAwareKey and delegate cache to proxy to.
*
* @param delegate The cache to proxy to
* @param tenantAwareKey Provides tenant aware keys to use in the cache
*/
public TenantAwareCache(ServerCache delegate, TenantAwareKey tenantAwareKey) {
this.delegate = delegate;
this.tenantAwareKey = tenantAwareKey;
}
/**
* Return the underlying ServerCache that is being delegated to.
*/
@Override
public <T> T unwrap(Class<T> cls) {
return (T)delegate;
}
@Override
public void visit(MetricVisitor visitor) {
delegate.visit(visitor);
}
private Object key(Object key) {
return tenantAwareKey.key(key);
}
@Override
public Object get(Object id) {
return delegate.get(key(id));
}
@Override
public void put(Object id, Object value) {
delegate.put(key(id), value);
}
@Override
public void remove(Object id) {
delegate.remove(key(id));
}
@Override
public void clear() {
delegate.clear();
}
@Override
public int size() {
return delegate.size();
}
@Override
public int hitRatio() {
return delegate.hitRatio();
}
@Override
public ServerCacheStatistics statistics(boolean reset) {
return delegate.statistics(reset);
}
@Override
public Map<Object, Object> getAll(Set<Object> keys) {
Map<Object, Object> keyMapping = new HashMap<>(keys.size());
keys.forEach(k -> keyMapping.put(key(k), k));
Map<Object, Object> tmp = delegate.getAll(keyMapping.keySet());
Map<Object, Object> ret = new HashMap<>(keys.size());
// unwrap tenant info here
tmp.forEach((k,v)-> ret.put(((TenantAwareKey.CacheKey) k).key, v));
return ret;
}
@Override
public void putAll(Map<Object, Object> keyValues) {
Map<Object, Object> tmp = new HashMap<>();
keyValues.forEach((k, v) -> tmp.put(key(k), v));
delegate.putAll(tmp);
}
@Override
public void removeAll(Set<Object> keys) {
delegate.removeAll(keys.stream().map(this::key).collect(Collectors.toSet()));
}
}
@@ -1,9 +1,6 @@
package io.ebean.common;
import io.ebean.bean.BeanCollection;
import io.ebean.bean.BeanCollectionAdd;
import io.ebean.bean.BeanCollectionLoader;
import io.ebean.bean.EntityBean;
import io.ebean.bean.*;
import java.io.Serializable;
import java.util.ArrayList;
@@ -47,6 +44,11 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
super(loader, ownerBean, propertyName);
}
@Override
public void toString(ToStringBuilder builder) {
builder.addCollection(list);
}
@Override
public void reset(EntityBean ownerBean, String propertyName) {
this.ownerBean = ownerBean;
@@ -191,18 +193,11 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
@Override
public String toString() {
StringBuilder sb = new StringBuilder(50);
sb.append("BeanList ");
if (isReadOnly()) {
sb.append("readOnly ");
}
if (list == null) {
sb.append("deferred ");
return "BeanList<deferred>";
} else {
sb.append("size[").append(list.size()).append("] ");
sb.append("list").append(list);
return list.toString();
}
return sb.toString();
}
/**
@@ -3,6 +3,7 @@ package io.ebean.common;
import io.ebean.bean.BeanCollection;
import io.ebean.bean.BeanCollectionLoader;
import io.ebean.bean.EntityBean;
import io.ebean.bean.ToStringBuilder;
import java.util.Collection;
import java.util.Collections;
@@ -40,6 +41,19 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
super(ebeanServer, ownerBean, propertyName);
}
@Override
public void toString(ToStringBuilder builder) {
if (map == null || map.isEmpty()) {
builder.addRaw("{}");
} else {
builder.addRaw("{");
for (Entry<K, E> entry : map.entrySet()) {
builder.add(String.valueOf(entry.getKey()), entry.getValue());
}
builder.addRaw("}");
}
}
@Override
public void reset(EntityBean ownerBean, String propertyName) {
this.ownerBean = ownerBean;
@@ -183,27 +197,20 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
@Override
public String toString() {
StringBuilder sb = new StringBuilder(50);
sb.append("BeanMap ");
if (isReadOnly()) {
sb.append("readOnly ");
}
if (map == null) {
sb.append("deferred ");
return "BeanMap<deferred>";
} else {
sb.append("size[").append(map.size()).append("]");
sb.append(" map").append(map);
return map.toString();
}
return sb.toString();
}
/**
* Equal if obj is a Map and equal in a Map sense.
* Equal if object is a Map and equal in a Map sense.
*/
@Override
public boolean equals(Object obj) {
public boolean equals(Object object) {
init();
return map.equals(obj);
return map.equals(object);
}
@Override
@@ -1,9 +1,6 @@
package io.ebean.common;
import io.ebean.bean.BeanCollection;
import io.ebean.bean.BeanCollectionAdd;
import io.ebean.bean.BeanCollectionLoader;
import io.ebean.bean.EntityBean;
import io.ebean.bean.*;
import java.io.Serializable;
import java.util.Collection;
@@ -41,6 +38,11 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
super(loader, ownerBean, propertyName);
}
@Override
public void toString(ToStringBuilder builder) {
builder.addCollection(set);
}
@Override
public void reset(EntityBean ownerBean, String propertyName) {
this.ownerBean = ownerBean;
@@ -169,18 +171,11 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
@Override
public String toString() {
StringBuilder sb = new StringBuilder(50);
sb.append("BeanSet ");
if (isReadOnly()) {
sb.append("readOnly ");
}
if (set == null) {
sb.append("deferred ");
return "BeanSet<deferred>";
} else {
sb.append("size[").append(set.size()).append("]");
sb.append(" set").append(set);
return set.toString();
}
return sb.toString();
}
/**
@@ -25,14 +25,6 @@ public class QueryPlanCapture {
return database;
}
/**
* Deprecated migrate to database().
*/
@Deprecated
public Database getDatabase() {
return database;
}
/**
* Return the captured query plans.
*/
@@ -40,11 +32,4 @@ public class QueryPlanCapture {
return plans;
}
/**
* Deprecated migrate to plans().
*/
@Deprecated
public List<MetaQueryPlan> getPlans() {
return plans;
}
}
@@ -10,11 +10,4 @@ public interface MetaCountMetric extends MetaMetric {
*/
long count();
/**
* Migrate to count()
*/
@Deprecated
default long getCount() {
return count();
}
}
@@ -10,11 +10,4 @@ public interface MetaMetric {
*/
String name();
/**
* Migrate to name().
*/
@Deprecated
default String getName() {
return name();
}
}
@@ -10,40 +10,16 @@ public interface MetaQueryMetric extends MetaTimedMetric {
*/
Class<?> type();
/**
* Migrate to type().
*/
@Deprecated
default Class<?> getType() {
return type();
}
/**
* The label for the query (can be null).
*/
String label();
/**
* Migrate to label().
*/
@Deprecated
default String getLabel() {
return label();
}
/**
* The actual SQL of the query.
*/
String sql();
/**
* Migrate to sql().
*/
@Deprecated
default String getSql() {
return sql();
}
/**
* Return the hash of the plan.
*/
@@ -11,67 +11,26 @@ public interface MetaTimedMetric extends MetaMetric {
*/
String location();
/**
* Migrate to location()
*/
@Deprecated
default String getLocation() {
return location();
}
/**
* Return the total count.
*/
long count();
/**
* Migrate to count()
*/
@Deprecated
default long getCount() {
return count();
}
/**
* Return the total execution time in micros.
*/
long total();
/**
* Migrate to total()
*/
@Deprecated
default long getTotal() {
return total();
}
/**
* Return the max execution time in micros.
*/
long max();
/**
* Migrate to max()
*/
@Deprecated
default long getMax() {
return max();
}
/**
* Return the mean execution time in micros.
*/
long mean();
/**
* Migrate to mean()
*/
@Deprecated
default long getMean() {
return mean();
}
/**
* Return true if this is the first metrics collection for this query.
* <p>
@@ -12,37 +12,14 @@ public interface ServerMetrics {
*/
List<MetaTimedMetric> timedMetrics();
/**
* Migrate to timedMetrics().
*/
@Deprecated
default List<MetaTimedMetric> getTimedMetrics() {
return timedMetrics();
}
/**
* Return the query metrics.
*/
List<MetaQueryMetric> queryMetrics();
/**
* Migrate to queryMetrics().
*/
@Deprecated
default List<MetaQueryMetric> getQueryMetrics() {
return queryMetrics();
}
/**
* Return the Counter metrics.
*/
List<MetaCountMetric> countMetrics();
/**
* Migrate to countMetrics().
*/
@Deprecated
default List<MetaCountMetric> getCountMetrics() {
return countMetrics();
}
}
@@ -19,6 +19,7 @@ public interface ServerMetricsAsJson {
/**
* Set the sort property - see SortMetric
*
* @see SortMetric
*/
ServerMetricsAsJson withSort(Comparator<MetaTimedMetric> sortBy);
@@ -35,9 +36,9 @@ public interface ServerMetricsAsJson {
*/
ServerMetricsAsJson withHeader(boolean withHeader);
/**
* Collect and write metrics as JSON to the given buffer.
*/
/**
* Collect and write metrics as JSON to the given buffer.
*/
void write(Appendable buffer);
/**
@@ -5,7 +5,7 @@ import java.util.Comparator;
/**
* Comparator for timed metrics sorted by name and then count.
*/
public class SortMetric {
public final class SortMetric {
public static final Comparator<MetaCountMetric> COUNT_NAME = new CountName();
@@ -6,7 +6,7 @@ import java.util.ServiceLoader;
/**
* Lookup MetricFactory service.
*/
class MetricServiceProvider {
final class MetricServiceProvider {
private static final MetricFactory metricFactory = init();
@@ -12,14 +12,6 @@ public interface QueryPlanMetric {
*/
TimedMetric metric();
/**
* Deprecated migrate to metric().
*/
@Deprecated
default TimedMetric getMetric() {
return metric();
}
/**
* Visit the underlying metric.
*/
@@ -16,28 +16,12 @@ public interface BeanDocType<T> {
/**
* Return the doc store index type for this bean type.
*/
default String indexType() {
return getIndexType();
}
/**
* Deprecated migrate to indexType().
*/
@Deprecated
String getIndexType();
String indexType();
/**
* Return the doc store index name for this bean type.
*/
default String indexName() {
return getIndexName();
}
/**
* Deprecated migrate to indexName().
*/
@Deprecated
String getIndexName();
String indexName();
/**
* Apply the appropriate fetch path to the query such that the query returns beans matching
@@ -48,29 +32,13 @@ public interface BeanDocType<T> {
/**
* Return the FetchPath for the embedded document.
*/
default FetchPath embedded(String path) {
return getEmbedded(path);
}
/**
* Deprecated migrate to embedded().
*/
@Deprecated
FetchPath getEmbedded(String path);
FetchPath embedded(String path);
/**
* For embedded 'many' properties we need a FetchPath relative to the root which is used to
* build and replace the embedded list.
*/
default FetchPath embeddedManyRoot(String path) {
return getEmbeddedManyRoot(path);
}
/**
* Deprecated migrate to embeddedManyRoot().
*/
@Deprecated
FetchPath getEmbeddedManyRoot(String path);
FetchPath embeddedManyRoot(String path);
/**
* Return a 'raw' property mapped for the given property.
@@ -22,53 +22,21 @@ public interface BeanType<T> {
*/
String name();
/**
* Deprecated migrate to name().
*/
@Deprecated
default String getName() {
return name();
}
/**
* Return the full name of the bean type.
*/
String fullName();
/**
* Deprecated migrate to fullName().
*/
@Deprecated
default String getFullName() {
return fullName();
}
/**
* Return the class type this BeanDescriptor describes.
*/
Class<T> type();
/**
* Deprecated migrate to type().
*/
@Deprecated
default Class<T> getBeanType() {
return type();
}
/**
* Return the type bean for an OneToMany or ManyToOne or ManyToMany property.
*/
BeanType<?> beanTypeAtPath(String propertyName);
/**
* Deprecated migrate to beanTypeAtPath().
*/
@Deprecated
default BeanType<?> getBeanTypeAtPath(String propertyName) {
return beanTypeAtPath(propertyName);
}
/**
* Return all the properties for this bean type.
*/
@@ -79,53 +47,21 @@ public interface BeanType<T> {
*/
Property idProperty();
/**
* Deprecated migrate to idProperty().
*/
@Deprecated
default Property getIdProperty() {
return idProperty();
}
/**
* Return the when modified property if there is one defined.
*/
Property whenModifiedProperty();
/**
* Deprecated migrate to idProperty().
*/
@Deprecated
default Property getWhenModifiedProperty() {
return whenModifiedProperty();
}
/**
* Return the when created property if there is one defined.
*/
Property whenCreatedProperty();
/**
* Deprecated migrate to idProperty().
*/
@Deprecated
default Property getWhenCreatedProperty() {
return whenCreatedProperty();
}
/**
* Return the Property to read values from a bean.
*/
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.
* <p>
@@ -134,14 +70,6 @@ public interface BeanType<T> {
*/
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.
*/
@@ -177,14 +105,6 @@ public interface BeanType<T> {
*/
String baseTable();
/**
* Deprecated migrate to baseTable().
*/
@Deprecated
default String getBaseTable() {
return baseTable();
}
/**
* Create a new instance of the bean.
*/
@@ -195,98 +115,36 @@ public interface BeanType<T> {
*/
Object id(Object bean);
/**
* Deprecated migrate to id()
*/
@Deprecated
default Object beanId(Object bean) {
return id(bean);
}
/**
* Deprecated migrate to id()
*/
@Deprecated
Object getBeanId(T bean);
/**
* Set the id value to the bean.
*/
void setId(T bean, Object idValue);
/**
* Deprecated migrate to setId()
*/
@Deprecated
default void setBeanId(T bean, Object idValue) {
setId(bean, idValue);
}
/**
* Return the bean persist controller.
*/
BeanPersistController persistController();
/**
* Deprecated migrate to persistController()
*/
@Deprecated
default BeanPersistController getPersistController() {
return persistController();
}
/**
* Return the bean persist listener.
*/
BeanPersistListener persistListener();
/**
* Deprecated migrate to persistListener()
*/
@Deprecated
default BeanPersistListener getPersistListener() {
return persistListener();
}
/**
* Return the beanFinder. Usually null unless overriding the finder.
*/
BeanFindController findController();
/**
* Deprecated migrate to findController()
*/
@Deprecated
default BeanFindController getFindController() {
return findController();
}
/**
* Return the BeanQueryAdapter or null if none is defined.
*/
BeanQueryAdapter queryAdapter();
/**
* Deprecated migrate to queryAdapter()
*/
@Deprecated
default BeanQueryAdapter getQueryAdapter() {
return queryAdapter();
}
/**
* Return the identity generation type.
*/
IdType idType();
/**
* Deprecated migrate to idType()
*/
@Deprecated
default IdType getIdType() {
return idType();
}
/**
* Return true if this bean type has doc store backing.
*/
@@ -301,27 +159,11 @@ public interface BeanType<T> {
*/
DocMapping docMapping();
/**
* Deprecated migrate to docMapping()
*/
@Deprecated
default DocMapping getDocMapping() {
return docMapping();
}
/**
* Return the doc store queueId for this bean type.
*/
String docStoreQueueId();
/**
* Deprecated migrate to docStoreQueueId()
*/
@Deprecated
default String getDocStoreQueueId() {
return docStoreQueueId();
}
/**
* Return the doc store support for this bean type.\
*/
@@ -353,27 +195,11 @@ public interface BeanType<T> {
*/
List<BeanType<?>> inheritanceChildren();
/**
* Deprecated migrate to inheritanceChildren()
*/
@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
*/
@@ -384,14 +210,6 @@ public interface BeanType<T> {
*/
String discColumn();
/**
* Deprecated migrate to discColumn()
*/
@Deprecated
default String getDiscColumn() {
return discColumn();
}
/**
* Create a bean given the discriminator value.
*/
@@ -39,14 +39,6 @@ public interface ExpressionPath {
*/
StringParser stringParser();
/**
* Deprecated migrate to stringParser().
*/
@Deprecated
default StringParser getStringParser() {
return stringParser();
}
/**
* For DateTime capable scalar types convert the long systemTimeMillis into
* an appropriate java time (Date,Timestamp,Time,Calendar, JODA type etc).
@@ -64,14 +56,6 @@ public interface ExpressionPath {
*/
int jdbcType();
/**
* Deprecated migrate to jdbcType().
*/
@Deprecated
default int getJdbcType() {
return jdbcType();
}
/**
* Return true if this is an ManyToOne or OneToOne associated bean property.
*/
@@ -85,50 +69,19 @@ public interface ExpressionPath {
*/
String assocIdExpression(String propName, String bindOperator);
/**
* Deprecated migrate to assocIdExpression().
*/
@Deprecated
default String getAssocIdExpression(String propName, String bindOperator) {
return assocIdExpression(propName, bindOperator);
}
/**
* Return the Id values for the given bean value.
*/
Object[] assocIdValues(EntityBean bean);
/**
* Deprecated migrate to assocIdValues().
*/
@Deprecated
default Object[] getAssocIdValues(EntityBean bean) {
return assocIdValues(bean);
}
/**
* Return the underlying bean property.
*/
Property property();
/**
* Deprecated migrate to property().
*/
@Deprecated
default Property getProperty() {
return property();
}
/**
* The ElPrefix plus name.
*/
String elName();
/**
* Deprecated migrate to elName().
*/
@Deprecated
default String getElName() {
return elName();
}
}
@@ -10,40 +10,16 @@ public interface Property {
*/
String name();
/**
* Deprecated migrate to name().
*/
@Deprecated
default String getName() {
return name();
}
/**
* Return the type of the property.
*/
Class<?> type();
/**
* Deprecated migrate to type().
*/
@Deprecated
default Class<?> getPropertyType() {
return type();
}
/**
* Return the value of the property on the given 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.
*/
@@ -10,7 +10,7 @@ import java.util.Set;
/**
* Annotation utility methods to find annotations.
*/
public class AnnotationUtil {
public final class AnnotationUtil {
/**
* Determine if the supplied {@link Annotation} is defined in the core JDK {@code java.lang.annotation} package.
@@ -1,6 +1,6 @@
package io.ebean.util;
public class CamelCaseHelper {
public final class CamelCaseHelper {
/**
* To underscore from camel case using digits compressed true and force upper case false.
@@ -16,7 +16,7 @@ import java.nio.charset.StandardCharsets;
* Utilities for IO. It uses UTF-8 as encoding when reading/writing and uses
* buffered IO for better performance.
*/
public class IOUtils {
public final class IOUtils {
/**
* Read from stream as UTF-8.
@@ -11,7 +11,7 @@ import java.sql.Statement;
/**
* Utility for closing raw Jdbc resources.
*/
public class JdbcClose {
public final class JdbcClose {
private static final Logger log = LoggerFactory.getLogger("io.ebean");
@@ -3,7 +3,7 @@ package io.ebean.util;
/**
* Helper for dot notation property paths.
*/
public class SplitName {
public final class SplitName {
private static final char PERIOD = '.';
@@ -7,7 +7,7 @@ import java.util.regex.Pattern;
/**
* Utility String class that supports String manipulation functions.
*/
public class StringHelper {
public final class StringHelper {
private static final Pattern SPLIT_NAMES = Pattern.compile("[\\s,;]+");