diff --git a/src/main/java/io/ebean/Finder.java b/src/main/java/io/ebean/Finder.java index bcba9667a..42d5b3910 100644 --- a/src/main/java/io/ebean/Finder.java +++ b/src/main/java/io/ebean/Finder.java @@ -2,7 +2,6 @@ package io.ebean; import javax.annotation.Nonnull; import javax.annotation.Nullable; - import java.util.List; /** @@ -112,26 +111,26 @@ public class Finder { *
* This provides full access to the API such as explicit transaction demarcation etc. */ - public EbeanServer db() { - return Ebean.getServer(serverName); + public Database db() { + return DB.byName(serverName); } /** - * Return typically a different EbeanServer to the default. + * Return typically a different Database to the default. *
- * This is equivalent to {@link Ebean#getServer(String)} + * This is equivalent to {@link DB#byName(String)} * - * @param server The name of the EbeanServer. If this is null then the default EbeanServer is + * @param server The name of the Database. If this is null then the default EbeanServer is * returned. */ - public EbeanServer db(String server) { - return Ebean.getServer(server); + public Database db(String server) { + return DB.byName(server); } /** * Creates an entity reference for this ID. *
- * Equivalent to {@link EbeanServer#getReference(Class, Object)} + * Equivalent to {@link Database#getReference(Class, Object)} */ @Nonnull public T ref(I id) { @@ -141,7 +140,7 @@ public class Finder { /** * Retrieves an entity by ID. *
- * Equivalent to {@link EbeanServer#find(Class, Object)} + * Equivalent to {@link Database#find(Class, Object)} */ @Nullable public T byId(I id) { @@ -151,7 +150,7 @@ public class Finder { /** * Delete a bean by Id. *
- * Equivalent to {@link EbeanServer#delete(Class, Object)} + * Equivalent to {@link Database#delete(Class, Object)} */ public void deleteById(I id) { db().delete(type, id); @@ -181,7 +180,7 @@ public class Finder { * } * *
- * Equivalent to {@link EbeanServer#update(Class)}
+ * Equivalent to {@link Database#update(Class)}
*/
public UpdateQuery
- * Equivalent to {@link EbeanServer#find(Class)}
+ * Equivalent to {@link Database#find(Class)}
*/
public Query
* This provides full access to the API such as explicit transaction demarcation etc.
*
* Example:
*
- * If you are using multiple databases then each database has a name and maps to a single
- * EbeanServer. You can use this method to get an EbeanServer for another database.
+ * Return a named Database that is typically different to the default database.
*
- * @param server The name of the EbeanServer. If this is null then the default EbeanServer is returned.
+ * @param server The name of the Database. If this is null then the default Database is returned.
*/
- public static EbeanServer db(String server) {
- return Ebean.getServer(server);
+ public static Database db(String server) {
+ return DB.byName(server);
}
/**
@@ -146,7 +140,7 @@ public abstract class Model {
*
* }
*
- * @see EbeanServer#markAsDirty(Object)
+ * @see Database#markAsDirty(Object)
*/
public void markAsDirty() {
db().markAsDirty(this);
@@ -182,7 +176,7 @@ public abstract class Model {
* Ebean will detect if this is a new bean or a previously fetched bean and perform either an
* insert or an update based on that.
*
- * @see EbeanServer#save(Object)
+ * @see Database#save(Object)
*/
public void save() {
db().save(this);
@@ -202,7 +196,7 @@ public abstract class Model {
/**
* Update this entity.
*
- * @see EbeanServer#update(Object)
+ * @see Database#update(Object)
*/
public void update() {
db().update(this);
@@ -211,7 +205,7 @@ public abstract class Model {
/**
* Insert this entity.
*
- * @see EbeanServer#insert(Object)
+ * @see Database#insert(Object)
*/
public void insert() {
db().insert(this);
@@ -232,7 +226,7 @@ public abstract class Model {
* deleted. Note that, if JDBC batch mode is used then this always returns true.
* {@code
*
- * Transaction transaction = Customer.db().beginTransaction();
- * try {
+ * try (Transaction transaction = Customer.db().beginTransaction()) {
*
* // turn off cascade persist for this transaction
* transaction.setPersistCascade(false);
@@ -104,26 +103,21 @@ public abstract class Model {
*
* transaction.commit();
*
- * } finally {
- * transaction.end();
* }
*
* }
*/
- public static EbeanServer db() {
- return Ebean.getDefaultServer();
+ public static Database db() {
+ return DB.getDefault();
}
/**
- * Return a named EbeanServer that is typically different to the default server.
- *