diff --git a/src/main/java/io/ebean/EbeanVersion.java b/src/main/java/io/ebean/EbeanVersion.java index c9ca35b77..a6424f9d0 100644 --- a/src/main/java/io/ebean/EbeanVersion.java +++ b/src/main/java/io/ebean/EbeanVersion.java @@ -21,7 +21,7 @@ public class EbeanVersion { static { try { Properties prop = new Properties(); - try (InputStream in = Ebean.class.getResourceAsStream("/META-INF/maven/io.ebean/ebean/pom.properties")) { + try (InputStream in = DB.class.getResourceAsStream("/META-INF/maven/io.ebean/ebean/pom.properties")) { if (in != null) { prop.load(in); in.close(); diff --git a/src/main/java/io/ebean/Expr.java b/src/main/java/io/ebean/Expr.java index ab8887c49..461b5e411 100644 --- a/src/main/java/io/ebean/Expr.java +++ b/src/main/java/io/ebean/Expr.java @@ -34,14 +34,14 @@ public class Expr { * Equal To - property equal to the given value. */ public static Expression eq(String propertyName, Object value) { - return Ebean.getExpressionFactory().eq(propertyName, value); + return DB.getExpressionFactory().eq(propertyName, value); } /** * Not Equal To - property not equal to the given value. */ public static Expression ne(String propertyName, Object value) { - return Ebean.getExpressionFactory().ne(propertyName, value); + return DB.getExpressionFactory().ne(propertyName, value); } /** @@ -49,7 +49,7 @@ public class Expr { * using a lower() function to make it case insensitive). */ public static Expression ieq(String propertyName, String value) { - return Ebean.getExpressionFactory().ieq(propertyName, value); + return DB.getExpressionFactory().ieq(propertyName, value); } /** @@ -59,28 +59,28 @@ public class Expr { *
*/ public static Expression inRange(String propertyName, Object value1, Object value2) { - return Ebean.getExpressionFactory().inRange(propertyName, value1, value2); + return DB.getExpressionFactory().inRange(propertyName, value1, value2); } /** * Between - property between the two given values. */ public static Expression between(String propertyName, Object value1, Object value2) { - return Ebean.getExpressionFactory().between(propertyName, value1, value2); + return DB.getExpressionFactory().between(propertyName, value1, value2); } /** * Between - value between two given properties. */ public static Expression between(String lowProperty, String highProperty, Object value) { - return Ebean.getExpressionFactory().betweenProperties(lowProperty, highProperty, value); + return DB.getExpressionFactory().betweenProperties(lowProperty, highProperty, value); } /** * Greater Than - property greater than the given value. */ public static Expression gt(String propertyName, Object value) { - return Ebean.getExpressionFactory().gt(propertyName, value); + return DB.getExpressionFactory().gt(propertyName, value); } /** @@ -88,42 +88,42 @@ public class Expr { * value. */ public static Expression ge(String propertyName, Object value) { - return Ebean.getExpressionFactory().ge(propertyName, value); + return DB.getExpressionFactory().ge(propertyName, value); } /** * Less Than - property less than the given value. */ public static Expression lt(String propertyName, Object value) { - return Ebean.getExpressionFactory().lt(propertyName, value); + return DB.getExpressionFactory().lt(propertyName, value); } /** * Less Than or Equal to - property less than or equal to the given value. */ public static Expression le(String propertyName, Object value) { - return Ebean.getExpressionFactory().le(propertyName, value); + return DB.getExpressionFactory().le(propertyName, value); } /** * Is Null - property is null. */ public static Expression isNull(String propertyName) { - return Ebean.getExpressionFactory().isNull(propertyName); + return DB.getExpressionFactory().isNull(propertyName); } /** * Is Not Null - property is not null. */ public static Expression isNotNull(String propertyName) { - return Ebean.getExpressionFactory().isNotNull(propertyName); + return DB.getExpressionFactory().isNotNull(propertyName); } /** * Case insensitive {@link #exampleLike(Object)} */ public static ExampleExpression iexampleLike(Object example) { - return Ebean.getExpressionFactory().iexampleLike(example); + return DB.getExpressionFactory().iexampleLike(example); } /** @@ -131,14 +131,14 @@ public class Expr { * LikeType.RAW (you need to add you own wildcards % and _). */ public static ExampleExpression exampleLike(Object example) { - return Ebean.getExpressionFactory().exampleLike(example); + return DB.getExpressionFactory().exampleLike(example); } /** * Create the query by Example expression specifying more options. */ public static ExampleExpression exampleLike(Object example, boolean caseInsensitive, LikeType likeType) { - return Ebean.getExpressionFactory().exampleLike(example, caseInsensitive, likeType); + return DB.getExpressionFactory().exampleLike(example, caseInsensitive, likeType); } /** @@ -146,7 +146,7 @@ public class Expr { * characters % (percentage) and _ (underscore). */ public static Expression like(String propertyName, String value) { - return Ebean.getExpressionFactory().like(propertyName, value); + return DB.getExpressionFactory().like(propertyName, value); } /** @@ -155,14 +155,14 @@ public class Expr { * a lower() function to make the expression case insensitive. */ public static Expression ilike(String propertyName, String value) { - return Ebean.getExpressionFactory().ilike(propertyName, value); + return DB.getExpressionFactory().ilike(propertyName, value); } /** * Starts With - property like value%. */ public static Expression startsWith(String propertyName, String value) { - return Ebean.getExpressionFactory().startsWith(propertyName, value); + return DB.getExpressionFactory().startsWith(propertyName, value); } /** @@ -170,14 +170,14 @@ public class Expr { * lower() function to make the expression case insensitive. */ public static Expression istartsWith(String propertyName, String value) { - return Ebean.getExpressionFactory().istartsWith(propertyName, value); + return DB.getExpressionFactory().istartsWith(propertyName, value); } /** * Ends With - property like %value. */ public static Expression endsWith(String propertyName, String value) { - return Ebean.getExpressionFactory().endsWith(propertyName, value); + return DB.getExpressionFactory().endsWith(propertyName, value); } /** @@ -185,14 +185,14 @@ public class Expr { * function to make the expression case insensitive. */ public static Expression iendsWith(String propertyName, String value) { - return Ebean.getExpressionFactory().iendsWith(propertyName, value); + return DB.getExpressionFactory().iendsWith(propertyName, value); } /** * Contains - property like %value%. */ public static Expression contains(String propertyName, String value) { - return Ebean.getExpressionFactory().contains(propertyName, value); + return DB.getExpressionFactory().contains(propertyName, value); } /** @@ -200,42 +200,42 @@ public class Expr { * function to make the expression case insensitive. */ public static Expression icontains(String propertyName, String value) { - return Ebean.getExpressionFactory().icontains(propertyName, value); + return DB.getExpressionFactory().icontains(propertyName, value); } /** * For collection properties that are empty (have not existing elements). */ public static Expression isEmpty(String propertyName) { - return Ebean.getExpressionFactory().isEmpty(propertyName); + return DB.getExpressionFactory().isEmpty(propertyName); } /** * For collection properties that are not empty (have existing elements). */ public static Expression isNotEmpty(String propertyName) { - return Ebean.getExpressionFactory().isNotEmpty(propertyName); + return DB.getExpressionFactory().isNotEmpty(propertyName); } /** * In - property has a value in the array of values. */ public static Expression in(String propertyName, Object[] values) { - return Ebean.getExpressionFactory().in(propertyName, values); + return DB.getExpressionFactory().in(propertyName, values); } /** * In - using a subQuery. */ public static Expression in(String propertyName, Query> subQuery) { - return Ebean.getExpressionFactory().in(propertyName, subQuery); + return DB.getExpressionFactory().in(propertyName, subQuery); } /** * In - property has a value in the collection of values. */ public static Expression in(String propertyName, Collection> values) { - return Ebean.getExpressionFactory().in(propertyName, values); + return DB.getExpressionFactory().in(propertyName, values); } /** @@ -272,14 +272,14 @@ public class Expr { * } */ public static Expression inOrEmpty(String propertyName, Collection> values) { - return Ebean.getExpressionFactory().inOrEmpty(propertyName, values); + return DB.getExpressionFactory().inOrEmpty(propertyName, values); } /** * Id Equal to - ID property is equal to the value. */ public static Expression idEq(Object value) { - return Ebean.getExpressionFactory().idEq(value); + return DB.getExpressionFactory().idEq(value); } /** @@ -292,7 +292,7 @@ public class Expr { * @param propertyMap a map keyed by property names. */ public static Expression allEq(Map- * Refer to {@link Ebean#sort(List, String)} for more detail. + * Refer to {@link DB#sort(List, String)} for more detail. *
*/ Filter* This information matches the features of the Transactional annotation. You * can use it directly with Runnable or Callable via - * {@link Ebean#execute(TxScope, Runnable)} or - * {@link Ebean#executeCall(TxScope, Callable)}. + * {@link DB#execute(TxScope, Runnable)} or + * {@link DB#executeCall(TxScope, Callable)}. *
** This object is used internally with the enhancement of a method with * Transactional annotation. *
* - * @see Ebean#execute(TxScope, Runnable) - * @see Ebean#executeCall(TxScope, Callable) + * @see DB#execute(TxScope, Runnable) + * @see DB#executeCall(TxScope, Callable) */ public final class TxScope { diff --git a/src/main/java/io/ebean/bean/EntityBeanIntercept.java b/src/main/java/io/ebean/bean/EntityBeanIntercept.java index 37922364b..8d23fdbcc 100644 --- a/src/main/java/io/ebean/bean/EntityBeanIntercept.java +++ b/src/main/java/io/ebean/bean/EntityBeanIntercept.java @@ -1,6 +1,6 @@ package io.ebean.bean; -import io.ebean.Ebean; +import io.ebean.DB; import io.ebean.ValuePair; import javax.persistence.EntityNotFoundException; @@ -821,7 +821,7 @@ public final class EntityBeanIntercept implements Serializable { synchronized (this) { if (beanLoader == null) { - BeanLoader serverLoader = (BeanLoader) Ebean.getServer(ebeanServerName); + BeanLoader serverLoader = (BeanLoader) DB.byName(ebeanServerName); if (serverLoader == null) { throw new PersistenceException("Server [" + ebeanServerName + "] was not found?"); } diff --git a/src/main/java/io/ebean/common/AbstractBeanCollection.java b/src/main/java/io/ebean/common/AbstractBeanCollection.java index 25001b91b..5790f9d13 100644 --- a/src/main/java/io/ebean/common/AbstractBeanCollection.java +++ b/src/main/java/io/ebean/common/AbstractBeanCollection.java @@ -1,6 +1,6 @@ package io.ebean.common; -import io.ebean.Ebean; +import io.ebean.DB; import io.ebean.ExpressionList; import io.ebean.bean.BeanCollection; import io.ebean.bean.BeanCollectionLoader; @@ -93,7 +93,7 @@ abstract class AbstractBeanCollection* These events can be triggered via - * {@link Ebean#externalModification(String, boolean, boolean, boolean)} or + * {@link DB#externalModification(String, boolean, boolean, boolean)} or * automatically determined from Ebean bulk update statements. */ public interface BulkTableEventListener { diff --git a/src/main/java/io/ebeaninternal/api/HelpScopeTrans.java b/src/main/java/io/ebeaninternal/api/HelpScopeTrans.java index 972a288f0..cb7643c65 100644 --- a/src/main/java/io/ebeaninternal/api/HelpScopeTrans.java +++ b/src/main/java/io/ebeaninternal/api/HelpScopeTrans.java @@ -1,6 +1,6 @@ package io.ebeaninternal.api; -import io.ebean.Ebean; +import io.ebean.DB; import io.ebean.TxScope; /** @@ -28,7 +28,7 @@ public class HelpScopeTrans { } private static SpiEbeanServer server() { - return (SpiEbeanServer) Ebean.getDefaultServer(); + return (SpiEbeanServer) DB.getDefault(); } /** diff --git a/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java b/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java index 48e705cc6..53d0b944c 100644 --- a/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java +++ b/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java @@ -1,6 +1,7 @@ package io.ebeaninternal.dbmigration; -import io.ebean.Ebean; +import io.ebean.DB; +import io.ebean.Database; import io.ebean.EbeanServer; import io.ebean.annotation.Platform; import io.ebean.config.DbConstraintNaming; @@ -142,8 +143,8 @@ public class DefaultDbMigration implements DbMigration { * Typically this is not called explicitly. */ @Override - public void setServer(EbeanServer ebeanServer) { - this.server = (SpiEbeanServer) ebeanServer; + public void setServer(Database database) { + this.server = (SpiEbeanServer) database; setServerConfig(server.getServerConfig()); } @@ -671,7 +672,7 @@ public class DefaultDbMigration implements DbMigration { */ private void setDefaults() { if (server == null) { - setServer(Ebean.getDefaultServer()); + setServer(DB.getDefault()); } if (vanillaPlatform || databasePlatform == null) { // not explicitly set so use the platform of the server diff --git a/src/test/java/io/ebean/BaseTestCase.java b/src/test/java/io/ebean/BaseTestCase.java index ccdb8f561..123145b26 100644 --- a/src/test/java/io/ebean/BaseTestCase.java +++ b/src/test/java/io/ebean/BaseTestCase.java @@ -70,7 +70,7 @@ public abstract class BaseTestCase { } try { // First try, if we get the default server. If this fails, all tests will fail. - Ebean.getDefaultServer(); + DB.getDefault(); } catch (Throwable e) { logger.error("Fatal error while getting ebean-server. Exiting...", e); System.exit(1); @@ -239,7 +239,7 @@ public abstract class BaseTestCase { } protected SpiEbeanServer spiEbeanServer() { - return (SpiEbeanServer) Ebean.getDefaultServer(); + return (SpiEbeanServer) DB.getDefault(); } protected EbeanServer server() { @@ -248,7 +248,7 @@ public abstract class BaseTestCase { protected void loadCountryCache() { - Ebean.find(Country.class) + DB.find(Country.class) .setBeanCacheMode(CacheMode.PUT) .findList(); } diff --git a/src/test/java/io/ebean/ConditionalTestRunner.java b/src/test/java/io/ebean/ConditionalTestRunner.java index c60b46b73..7764cea97 100644 --- a/src/test/java/io/ebean/ConditionalTestRunner.java +++ b/src/test/java/io/ebean/ConditionalTestRunner.java @@ -37,7 +37,7 @@ public class ConditionalTestRunner extends BlockJUnit4ClassRunner { } private boolean platformMath(Platform[] platforms) { - Platform current = Ebean.getDefaultServer().getPluginApi().getDatabasePlatform().getPlatform(); + Platform current = DB.getDefault().getPluginApi().getDatabasePlatform().getPlatform(); for (Platform p : platforms) { if (p.equals(current)) { return true;