mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4c7cf529d | ||
|
|
ba5c67f936 | ||
|
|
2bd7995ca1 | ||
|
|
cc8c860709 | ||
|
|
7d25e31289 | ||
|
|
936e56835c | ||
|
|
0d848e9311 | ||
|
|
b794b6c77e | ||
|
|
f45d240682 | ||
|
|
1a6f68edd3 | ||
|
|
81683c5d2a | ||
|
|
2b535d59b8 | ||
|
|
ae0bbaaaf8 | ||
|
|
aaca20f9c3 | ||
|
|
245cbb0ea1 | ||
|
|
dbe984c668 | ||
|
|
89088f9480 | ||
|
|
80253c4e07 | ||
|
|
f96ce11c73 | ||
|
|
b8f8cb5ae7 | ||
|
|
b8a2aac95a | ||
|
|
7b090a6346 | ||
|
|
b10c68489f | ||
|
|
2dbb2d9911 | ||
|
|
b3b4c72a77 | ||
|
|
1c040e4583 | ||
|
|
9677e585b6 | ||
|
|
c53806224f |
@@ -9,7 +9,7 @@
|
||||
|
||||
<groupId>org.avaje.ebeanorm</groupId>
|
||||
<artifactId>avaje-ebeanorm</artifactId>
|
||||
<version>5.1.1</version>
|
||||
<version>6.1.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>avaje-ebeanorm</name>
|
||||
@@ -43,6 +43,12 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>13.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>persistence-api</artifactId>
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.avaje.ebean;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -10,6 +9,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import javax.persistence.OptimisticLockException;
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -101,7 +101,7 @@ import com.avaje.ebean.text.json.JsonContext;
|
||||
* specific database.
|
||||
* </p>
|
||||
*
|
||||
* <pre> {@code
|
||||
* <pre>{@code
|
||||
*
|
||||
* // Get access to the Human Resources EbeanServer/Database
|
||||
* EbeanServer hrDb = Ebean.getServer("hr");
|
||||
@@ -533,7 +533,6 @@ public final class Ebean {
|
||||
* public class Order { ...
|
||||
*
|
||||
* @OneToMany(cascade=CascadeType.ALL, mappedBy="order")
|
||||
* @JoinColumn(name="order_id")
|
||||
* List<OrderDetail> details;
|
||||
* ...
|
||||
* }
|
||||
@@ -557,16 +556,6 @@ public final class Ebean {
|
||||
public static void insert(Object bean) {
|
||||
serverMgr.getDefaultServer().insert(bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated - please migrate to insertAll().
|
||||
*
|
||||
* Insert a collection of beans.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void insert(Collection<?> beans) {
|
||||
serverMgr.getDefaultServer().insertAll(beans);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a collection of beans.
|
||||
@@ -639,16 +628,6 @@ public final class Ebean {
|
||||
serverMgr.getDefaultServer().update(bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecate - please migrate to updateAll().
|
||||
*
|
||||
* Update the beans in the collection.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void update(Collection<?> beans) throws OptimisticLockException {
|
||||
serverMgr.getDefaultServer().updateAll(beans);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the beans in the collection.
|
||||
*/
|
||||
@@ -656,26 +635,6 @@ public final class Ebean {
|
||||
serverMgr.getDefaultServer().updateAll(beans);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated - please change to iterate yourself and save().
|
||||
*
|
||||
* Save all the beans from an Iterator.
|
||||
*/
|
||||
@Deprecated
|
||||
public static int save(Iterator<?> iterator) throws OptimisticLockException {
|
||||
return serverMgr.getDefaultServer().save(iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated - please migrate to saveAll().
|
||||
*
|
||||
* Save all the beans from a Collection.
|
||||
*/
|
||||
@Deprecated
|
||||
public static int save(Collection<?> beans) throws OptimisticLockException {
|
||||
return serverMgr.getDefaultServer().saveAll(beans);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save all the beans from a Collection.
|
||||
*/
|
||||
@@ -753,16 +712,6 @@ public final class Ebean {
|
||||
return serverMgr.getDefaultServer().delete(beanType, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated - please migrate to deleteAll().
|
||||
*
|
||||
* Delete several beans given their type and id values.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void delete(Class<?> beanType, Collection<?> ids) {
|
||||
serverMgr.getDefaultServer().deleteAll(beanType, ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete several beans given their type and id values.
|
||||
*/
|
||||
@@ -770,22 +719,6 @@ public final class Ebean {
|
||||
serverMgr.getDefaultServer().deleteAll(beanType, ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all the beans from an Iterator.
|
||||
*/
|
||||
@Deprecated
|
||||
public static int delete(Iterator<?> it) throws OptimisticLockException {
|
||||
return serverMgr.getDefaultServer().delete(it);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all the beans from a Collection.
|
||||
*/
|
||||
@Deprecated
|
||||
public static int delete(Collection<?> beans) throws OptimisticLockException {
|
||||
return serverMgr.getDefaultServer().deleteAll(beans);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all the beans in the Collection.
|
||||
*/
|
||||
@@ -945,6 +878,7 @@ public final class Ebean {
|
||||
* @param id
|
||||
* the id value
|
||||
*/
|
||||
@Nullable
|
||||
public static <T> T find(Class<T> beanType, Object id) {
|
||||
return serverMgr.getDefaultServer().find(beanType, id);
|
||||
}
|
||||
@@ -1553,13 +1487,5 @@ public final class Ebean {
|
||||
public static JsonContext json() {
|
||||
return serverMgr.getDefaultServer().json();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the JsonContext for reading/writing JSON.
|
||||
* @deprecated Please use #json instead.
|
||||
*/
|
||||
public static JsonContext createJsonContext() {
|
||||
return json();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.avaje.ebean;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -15,6 +14,7 @@ import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.meta.MetaInfoManager;
|
||||
import com.avaje.ebean.text.csv.CsvReader;
|
||||
import com.avaje.ebean.text.json.JsonContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Provides the API for fetching and saving beans to a particular DataSource.
|
||||
@@ -904,19 +904,6 @@ public interface EbeanServer {
|
||||
*/
|
||||
<T> void findEachWhile(Query<T> query, QueryEachWhileConsumer<T> consumer, Transaction transaction);
|
||||
|
||||
/**
|
||||
* Deprecated in favor of #findEachWhile which is functionally exactly the same
|
||||
* but has a much better name.
|
||||
* <p>
|
||||
* Execute the query visiting the results. This is similar to findIterate in
|
||||
* that not all the result beans need to be held in memory at the same time
|
||||
* and as such is go for processing large queries.
|
||||
* </p>
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
<T> void findVisit(Query<T> query, QueryResultVisitor<T> visitor, Transaction transaction);
|
||||
|
||||
/**
|
||||
* Execute a query returning a list of beans.
|
||||
* <p>
|
||||
@@ -1109,6 +1096,7 @@ public interface EbeanServer {
|
||||
*
|
||||
* @see Query#findUnique()
|
||||
*/
|
||||
@Nullable
|
||||
<T> T findUnique(Query<T> query, Transaction transaction);
|
||||
|
||||
/**
|
||||
@@ -1185,6 +1173,7 @@ public interface EbeanServer {
|
||||
*
|
||||
* @see SqlQuery#findUnique()
|
||||
*/
|
||||
@Nullable
|
||||
SqlRow findUnique(SqlQuery query, Transaction transaction);
|
||||
|
||||
/**
|
||||
@@ -1222,22 +1211,6 @@ public interface EbeanServer {
|
||||
*/
|
||||
void save(Object bean) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Deprecated - please change to iterate yourself and save.
|
||||
*
|
||||
* Save all the beans in the iterator.
|
||||
*/
|
||||
@Deprecated
|
||||
int save(Iterator<?> it) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Deprecated - please migrate to saveAll().
|
||||
*
|
||||
* Save all the beans in the collection.
|
||||
*/
|
||||
@Deprecated
|
||||
int save(Collection<?> beans) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Save all the beans in the collection.
|
||||
*/
|
||||
@@ -1252,22 +1225,6 @@ public interface EbeanServer {
|
||||
*/
|
||||
void delete(Object bean) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Deprecated - please change to iterate yourself and delete.
|
||||
*
|
||||
* Delete all the beans from an Iterator.
|
||||
*/
|
||||
@Deprecated
|
||||
int delete(Iterator<?> it) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Deprecated - please migrate to deleteAll().
|
||||
*
|
||||
* Delete all the beans in the collection.
|
||||
*/
|
||||
@Deprecated
|
||||
int delete(Collection<?> beans) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Delete all the beans in the collection.
|
||||
*/
|
||||
@@ -1283,28 +1240,11 @@ public interface EbeanServer {
|
||||
*/
|
||||
int delete(Class<?> beanType, Object id, Transaction transaction);
|
||||
|
||||
/**
|
||||
* Deprecated - please migrate to deleteAll().
|
||||
*
|
||||
* Delete several beans given their type and id values.
|
||||
*/
|
||||
@Deprecated
|
||||
void delete(Class<?> beanType, Collection<?> ids);
|
||||
|
||||
/**
|
||||
* Delete several beans given their type and id values.
|
||||
*/
|
||||
void deleteAll(Class<?> beanType, Collection<?> ids);
|
||||
|
||||
/**
|
||||
* Deprecated - please migrate to deleteAll().
|
||||
*
|
||||
* Delete several beans given their type and id values with an explicit
|
||||
* transaction.
|
||||
*/
|
||||
@Deprecated
|
||||
void delete(Class<?> beanType, Collection<?> ids, Transaction transaction);
|
||||
|
||||
/**
|
||||
* Delete several beans given their type and id values with an explicit
|
||||
* transaction.
|
||||
@@ -1316,14 +1256,6 @@ public interface EbeanServer {
|
||||
*/
|
||||
void delete(Object bean, Transaction transaction) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Deprecated - please migrate to iterate yourself and delete().
|
||||
*
|
||||
* Delete all the beans from an iterator.
|
||||
*/
|
||||
@Deprecated
|
||||
int delete(Iterator<?> it, Transaction transaction) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Execute a Sql Update Delete or Insert statement. This returns the number of
|
||||
* rows that where updated, deleted or inserted. If is executed in batch then
|
||||
@@ -1464,21 +1396,6 @@ public interface EbeanServer {
|
||||
*/
|
||||
void save(Object bean, Transaction transaction) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Deprecated - please change to iterate yourself and save.
|
||||
* Save all the beans in the iterator with an explicit transaction.
|
||||
*/
|
||||
@Deprecated
|
||||
int save(Iterator<?> it, Transaction transaction) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Deprecated - please migrate to saveAll().
|
||||
*
|
||||
* Save all the beans in the collection with an explicit transaction.
|
||||
*/
|
||||
@Deprecated
|
||||
int save(Collection<?> beans, Transaction transaction) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Save all the beans in the collection with an explicit transaction.
|
||||
*/
|
||||
@@ -1563,29 +1480,12 @@ public interface EbeanServer {
|
||||
*/
|
||||
void update(Object bean, Transaction transaction, boolean deleteMissingChildren) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Deprecated - please migrate to updateAll().
|
||||
*
|
||||
* Update a collection of beans. If there is no current transaction one is created and used to
|
||||
* update all the beans in the collection.
|
||||
*/
|
||||
@Deprecated
|
||||
void update(Collection<?> beans) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Update a collection of beans. If there is no current transaction one is created and used to
|
||||
* update all the beans in the collection.
|
||||
*/
|
||||
void updateAll(Collection<?> beans) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Deprecated - please migrate to updateAll().
|
||||
*
|
||||
* Update a collection of beans with an explicit transaction.
|
||||
*/
|
||||
@Deprecated
|
||||
void update(Collection<?> beans, Transaction transaction) throws OptimisticLockException;
|
||||
|
||||
/**
|
||||
* Update a collection of beans with an explicit transaction.
|
||||
*/
|
||||
@@ -1606,29 +1506,12 @@ public interface EbeanServer {
|
||||
*/
|
||||
void insert(Object bean, Transaction transaction);
|
||||
|
||||
/**
|
||||
* Deprecated - please migrate to insertAll().
|
||||
*
|
||||
* Insert a collection of beans. If there is no current transaction one is created and used to
|
||||
* insert all the beans in the collection.
|
||||
*/
|
||||
@Deprecated
|
||||
void insert(Collection<?> beans);
|
||||
|
||||
/**
|
||||
* Insert a collection of beans. If there is no current transaction one is created and used to
|
||||
* insert all the beans in the collection.
|
||||
*/
|
||||
void insertAll(Collection<?> beans);
|
||||
|
||||
/**
|
||||
* Deprecated - please migrate to insertAll().
|
||||
*
|
||||
* Insert a collection of beans with an explicit transaction.
|
||||
*/
|
||||
@Deprecated
|
||||
void insert(Collection<?> beans, Transaction transaction);
|
||||
|
||||
/**
|
||||
* Insert a collection of beans with an explicit transaction.
|
||||
*/
|
||||
@@ -1864,12 +1747,6 @@ public interface EbeanServer {
|
||||
*/
|
||||
void runCacheWarming(Class<?> beanType);
|
||||
|
||||
/**
|
||||
* Return the JsonContext for reading/writing JSON.
|
||||
* @deprecated Please use #json instead.
|
||||
*/
|
||||
JsonContext createJsonContext();
|
||||
|
||||
/**
|
||||
* Return the JsonContext for reading/writing JSON.
|
||||
* <p>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.avaje.ebean;
|
||||
|
||||
import com.avaje.ebean.text.PathProperties;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
@@ -116,14 +117,6 @@ public interface ExpressionList<T> extends Serializable {
|
||||
*/
|
||||
void findEachWhile(QueryEachWhileConsumer<T> consumer);
|
||||
|
||||
/**
|
||||
* Deprecated in favor of #findEachWhile which is functionally exactly the same
|
||||
* but has a much better name.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
void findVisit(QueryResultVisitor<T> visitor);
|
||||
|
||||
/**
|
||||
* Execute the query returning a list.
|
||||
*
|
||||
@@ -170,6 +163,7 @@ public interface ExpressionList<T> extends Serializable {
|
||||
*
|
||||
* @see Query#findUnique()
|
||||
*/
|
||||
@Nullable
|
||||
T findUnique();
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,57 +22,57 @@ import java.io.Serializable;
|
||||
* efficient loaded as 2 SQL queries.
|
||||
* </p>
|
||||
*
|
||||
* <pre class="code">
|
||||
* <pre>{@code
|
||||
* // Normal fetch join results in a single SQL query
|
||||
* List<Order> list = Ebean.find(Order.class).fetch("details").findList();
|
||||
* List<Order> list = Ebean.find(Order.class).fetch("details").findList();
|
||||
*
|
||||
* // Find Orders join details using a single SQL query
|
||||
* </pre>
|
||||
* }</pre>
|
||||
* <p>
|
||||
* Example: Using a "query join" instead of a "fetch join" we instead use 2 SQL
|
||||
* queries
|
||||
* </p>
|
||||
*
|
||||
* <pre class="code">
|
||||
* <pre>{@code
|
||||
* // This will use 2 SQL queries to build this object graph
|
||||
* List<Order> list =
|
||||
* List<Order> list =
|
||||
* Ebean.find(Order.class)
|
||||
* .fetch("details", new FetchConfig().query())
|
||||
* .fetch("details", new FetchConfig().query())
|
||||
* .findList();
|
||||
*
|
||||
* // query 1) find order
|
||||
* // query 2) find orderDetails where order.id in (?,?...) // first 100 order id's
|
||||
* </pre>
|
||||
* }</pre>
|
||||
* <p>
|
||||
* Example: Using 2 "query joins"
|
||||
* </p>
|
||||
*
|
||||
* <pre class="code">
|
||||
* <pre>{@code
|
||||
* // This will use 3 SQL queries to build this object graph
|
||||
* List<Order> list =
|
||||
* List<Order> list =
|
||||
* Ebean.find(Order.class)
|
||||
* .fetch("details", new FetchConfig().query())
|
||||
* .fetch("customer", new FetchConfig().queryFirst(5))
|
||||
* .fetch("details", new FetchConfig().query())
|
||||
* .fetch("customer", new FetchConfig().queryFirst(5))
|
||||
* .findList();
|
||||
*
|
||||
* // query 1) find order
|
||||
* // query 2) find orderDetails where order.id in (?,?...) // first 100 order id's
|
||||
* // query 3) find customer where id in (?,?,?,?,?) // first 5 customers
|
||||
* </pre>
|
||||
* }</pre>
|
||||
* <p>
|
||||
* Example: Using "query joins" and partial objects
|
||||
* </p>
|
||||
*
|
||||
* <pre class="code">
|
||||
* <pre>{@code
|
||||
* // This will use 3 SQL queries to build this object graph
|
||||
* List<Order> list =
|
||||
* List<Order> list =
|
||||
* Ebean.find(Order.class)
|
||||
* .select("status, shipDate")
|
||||
* .fetch("details", "quantity, price", new FetchConfig().query())
|
||||
* .fetch("details.product", "sku, name")
|
||||
* .fetch("customer", "name", new FetchConfig().queryFirst(5))
|
||||
* .fetch("customer.contacts")
|
||||
* .fetch("customer.shippingAddress")
|
||||
* .select("status, shipDate")
|
||||
* .fetch("details", "quantity, price", new FetchConfig().query())
|
||||
* .fetch("details.product", "sku, name")
|
||||
* .fetch("customer", "name", new FetchConfig().queryFirst(5))
|
||||
* .fetch("customer.contacts")
|
||||
* .fetch("customer.shippingAddress")
|
||||
* .findList();
|
||||
*
|
||||
* // query 1) find order (status, shipDate)
|
||||
@@ -81,22 +81,22 @@ import java.io.Serializable;
|
||||
* // query 3) find customer (name) fetch contacts (*) fetch shippingAddress (*)
|
||||
* // where id in (?,?,?,?,?)
|
||||
*
|
||||
* // Note: the fetch of "details.product" is automatically included into the
|
||||
* // fetch of "details"
|
||||
* // Note: the fetch of "details.product" is automatically included into the
|
||||
* // fetch of "details"
|
||||
* //
|
||||
* // Note: the fetch of "customer.contacts" and "customer.shippingAddress"
|
||||
* // are automatically included in the fetch of "customer"
|
||||
* </pre>
|
||||
* // Note: the fetch of "customer.contacts" and "customer.shippingAddress"
|
||||
* // are automatically included in the fetch of "customer"
|
||||
* }</pre>
|
||||
* <p>
|
||||
* You can use query() and lazy together on a single join. The query is executed
|
||||
* immediately and the lazy defines the batch size to use for further lazy
|
||||
* loading (if lazy loading is invoked).
|
||||
* </p>
|
||||
*
|
||||
* <pre class="code">
|
||||
* List<Order> list =
|
||||
* <pre>{@code
|
||||
* List<Order> list =
|
||||
* Ebean.find(Order.class)
|
||||
* .fetch("customer", new FetchConfig().query(10).lazy(5))
|
||||
* .fetch("customer", new FetchConfig().query(10).lazy(5))
|
||||
* .findList();
|
||||
*
|
||||
* // query 1) find order
|
||||
@@ -104,7 +104,7 @@ import java.io.Serializable;
|
||||
* // .. then if lazy loading of customers is invoked
|
||||
* // .. use a batch size of 5 to load the customers
|
||||
*
|
||||
* </pre>
|
||||
* }</pre>
|
||||
*
|
||||
* <p>
|
||||
* Example of controlling the lazy loading query:
|
||||
@@ -114,12 +114,12 @@ import java.io.Serializable;
|
||||
* case.
|
||||
* </p>
|
||||
*
|
||||
* <pre class="code">
|
||||
* List<Order> list = Ebean.find(Order.class)
|
||||
* .fetch("customer","name", new FetchConfig().lazy(5))
|
||||
* .fetch("customer.contacts","contactName, phone, email")
|
||||
* .fetch("customer.shippingAddress")
|
||||
* .where().eq("status",Order.Status.NEW)
|
||||
* <pre>{@code
|
||||
* List<Order> list = Ebean.find(Order.class)
|
||||
* .fetch("customer","name", new FetchConfig().lazy(5))
|
||||
* .fetch("customer.contacts","contactName, phone, email")
|
||||
* .fetch("customer.shippingAddress")
|
||||
* .where().eq("status",Order.Status.NEW)
|
||||
* .findList();
|
||||
*
|
||||
* // query 1) find order where status = Order.Status.NEW
|
||||
@@ -132,7 +132,7 @@ import java.io.Serializable;
|
||||
* fetch customer.shippingAddress (*)
|
||||
* where id in (?,?,?,?,?)
|
||||
*
|
||||
* </pre>
|
||||
* }</pre>
|
||||
*
|
||||
* @author mario
|
||||
* @author rbygrave
|
||||
|
||||
@@ -2,14 +2,13 @@ package com.avaje.ebean;
|
||||
|
||||
import com.avaje.ebean.text.PathProperties;
|
||||
import com.avaje.ebean.util.ClassUtil;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.GenericArrayType;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A MappedSuperclass base class that provides convenience methods for inserting, updating and
|
||||
@@ -514,6 +513,7 @@ public abstract class Model {
|
||||
* <p>
|
||||
* Equivalent to {@link EbeanServer#find(Class, Object)}
|
||||
*/
|
||||
@Nullable
|
||||
public T byId(I id) {
|
||||
return db().find(type, id);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.avaje.ebean;
|
||||
|
||||
import com.avaje.ebean.text.PathProperties;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@@ -520,19 +521,7 @@ public interface Query<T> extends Serializable {
|
||||
*/
|
||||
QueryIterator<T> findIterate();
|
||||
|
||||
/**
|
||||
* This is deprecated in favor of #findEachWhile.
|
||||
* <p>
|
||||
* This is functionally exactly the same as #findEachWhile. It is
|
||||
* replaced by findEachWhile because the method name is much better.
|
||||
* </p>
|
||||
*
|
||||
* @param visitor
|
||||
* the visitor used to process the queried beans.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
void findVisit(QueryResultVisitor<T> visitor);
|
||||
|
||||
|
||||
/**
|
||||
* Execute the query processing the beans one at a time.
|
||||
@@ -716,6 +705,7 @@ public interface Query<T> extends Serializable {
|
||||
* ...
|
||||
* }</pre>
|
||||
*/
|
||||
@Nullable
|
||||
T findUnique();
|
||||
|
||||
/**
|
||||
@@ -878,6 +868,11 @@ public interface Query<T> extends Serializable {
|
||||
*/
|
||||
Query<T> setId(Object id);
|
||||
|
||||
/**
|
||||
* Return the Id value.
|
||||
*/
|
||||
Object getId();
|
||||
|
||||
/**
|
||||
* Add additional clause(s) to the where clause.
|
||||
* <p>
|
||||
@@ -1123,8 +1118,8 @@ public interface Query<T> extends Serializable {
|
||||
|
||||
/**
|
||||
* Set the first row to return for this query.
|
||||
*
|
||||
* @param firstRow
|
||||
*
|
||||
* @param firstRow the first row to include in the query result.
|
||||
*/
|
||||
Query<T> setFirstRow(int firstRow);
|
||||
|
||||
@@ -1235,4 +1230,10 @@ public interface Query<T> extends Serializable {
|
||||
* Set root table alias.
|
||||
*/
|
||||
Query<T> alias(String alias);
|
||||
|
||||
/**
|
||||
* Return the type of beans being queried.
|
||||
*/
|
||||
Class<T> getBeanType();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.avaje.ebean;
|
||||
|
||||
/**
|
||||
* Used to process a query result one bean at a time via a callback to this
|
||||
* visitor.
|
||||
* <p>
|
||||
* If you wish to stop further processing return false from the accept method.
|
||||
* </p>
|
||||
* <p>
|
||||
* Unlike findList() and findSet() using a QueryResultVisitor does not require
|
||||
* all the beans in the query result to be held in memory at once. This makes
|
||||
* QueryResultVisitor useful for processing large queries.
|
||||
* </p>
|
||||
*
|
||||
* <pre class="code">
|
||||
*
|
||||
* Query<Customer> query = server.find(Customer.class)
|
||||
* .fetch("contacts", new FetchConfig().query(2))
|
||||
* .where().gt("id", 0)
|
||||
* .orderBy("id")
|
||||
* .setMaxRows(2);
|
||||
*
|
||||
* query.findVisit(new QueryResultVisitor<Customer>() {
|
||||
*
|
||||
* public boolean accept(Customer customer) {
|
||||
* // do something with customer
|
||||
* System.out.println("-- visit " + customer);
|
||||
* return true;
|
||||
* }
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
* @author rbygrave
|
||||
*
|
||||
* @param <T>
|
||||
* the type of entity bean being queried.
|
||||
*/
|
||||
public interface QueryResultVisitor<T> {
|
||||
|
||||
/**
|
||||
* Process the bean and return true if you want to continue processing more
|
||||
* beans. Return false if you want to stop processing further.
|
||||
*
|
||||
* @param bean
|
||||
* the entity bean to process
|
||||
* @return true to continue processing or false to stop.
|
||||
*/
|
||||
boolean accept(T bean);
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.avaje.ebean.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Deprecated - please use @DbHstore instead.
|
||||
* @see DbHstore
|
||||
*/
|
||||
@Deprecated
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface ColumnHstore {
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.avaje.ebean.event;
|
||||
|
||||
import com.avaje.ebean.bean.BeanCollection;
|
||||
|
||||
/**
|
||||
* Deprecated in favor of using BeanFindController.
|
||||
*
|
||||
* Used to override the finding implementation for a bean.
|
||||
* <p>
|
||||
* For beans that are not in a JDBC data source you can implement this handle
|
||||
* bean finding. For example, read a log file building each entry as a bean and
|
||||
* returning that.
|
||||
* </p>
|
||||
* <p>
|
||||
* There are a number of internal BeanFinders in Ebean to return meta data from
|
||||
* Ebean at runtime such as query execution statistics etc. See the beans in
|
||||
* com.avaje.ebean.meta and finders in com.avaje.ebean.server.meta.
|
||||
* </p>
|
||||
* @deprecated
|
||||
*/
|
||||
public interface BeanFinder<T> {
|
||||
|
||||
/**
|
||||
* Find a bean using its id or unique predicate.
|
||||
*/
|
||||
T find(BeanQueryRequest<T> request);
|
||||
|
||||
/**
|
||||
* Return a List, Set or Map for the given find request.
|
||||
* <p>
|
||||
* Note the returning object is cast to a List Set or Map so you do need to
|
||||
* get the return type right.
|
||||
* </p>
|
||||
*/
|
||||
BeanCollection<T> findMany(BeanQueryRequest<T> request);
|
||||
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
package com.avaje.ebeaninternal.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebean.ExpressionList;
|
||||
import com.avaje.ebean.OrderBy;
|
||||
import com.avaje.ebean.PersistenceContextScope;
|
||||
import com.avaje.ebean.Query;
|
||||
import com.avaje.ebean.bean.BeanCollectionTouched;
|
||||
import com.avaje.ebean.bean.CallStack;
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebean.bean.ObjectGraphNode;
|
||||
import com.avaje.ebean.bean.PersistenceContext;
|
||||
import com.avaje.ebean.event.BeanQueryRequest;
|
||||
@@ -22,6 +19,8 @@ import com.avaje.ebeaninternal.server.querydefn.NaturalKeyBindParam;
|
||||
import com.avaje.ebeaninternal.server.querydefn.OrmQueryDetail;
|
||||
import com.avaje.ebeaninternal.server.querydefn.OrmQueryProperties;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Object Relational query - Internal extension to Query object.
|
||||
*/
|
||||
@@ -148,6 +147,11 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
*/
|
||||
SpiQuery<T> copy();
|
||||
|
||||
/**
|
||||
* Return a copy of the query attaching to a different EbeanServer.
|
||||
*/
|
||||
SpiQuery<T> copy(EbeanServer server);
|
||||
|
||||
/**
|
||||
* Return the type of query (List, Set, Map, Bean, rowCount etc).
|
||||
*/
|
||||
@@ -171,18 +175,13 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
/**
|
||||
* This becomes a lazy loading query for a many relationship.
|
||||
*/
|
||||
void setLazyLoadForParents(List<Object> parentIds, BeanPropertyAssocMany<?> many);
|
||||
void setLazyLoadForParents(BeanPropertyAssocMany<?> many);
|
||||
|
||||
/**
|
||||
* Return the lazy loading 'many' property.
|
||||
*/
|
||||
BeanPropertyAssocMany<?> getLazyLoadForParentsProperty();
|
||||
|
||||
/**
|
||||
* Return the list of parent Id's for lazy loading.
|
||||
*/
|
||||
List<Object> getLazyLoadForParentIds();
|
||||
|
||||
/**
|
||||
* Set the load mode (+lazy or +query) and the load description.
|
||||
*/
|
||||
@@ -203,11 +202,6 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
*/
|
||||
ManyWhereJoins getManyWhereJoins();
|
||||
|
||||
/**
|
||||
* Convert this natural key query into a find by id query.
|
||||
*/
|
||||
void convertWhereNaturalKeyToId(Object idValue);
|
||||
|
||||
/**
|
||||
* Return a Natural Key bind parameter if supported by this query.
|
||||
*/
|
||||
@@ -341,11 +335,6 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
*/
|
||||
String getLazyLoadProperty();
|
||||
|
||||
/**
|
||||
* Return the lazy load path.
|
||||
*/
|
||||
String getLazyLoadManyPath();
|
||||
|
||||
/**
|
||||
* Used to hook back a lazy loading query to the original query (query
|
||||
* point).
|
||||
@@ -476,27 +465,11 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
*/
|
||||
Boolean isReadOnly();
|
||||
|
||||
/**
|
||||
* Adds this bean to the persistence context prior to executing the query.
|
||||
*/
|
||||
void contextAdd(EntityBean bean);
|
||||
|
||||
/**
|
||||
* Return the type of beans queries.
|
||||
*/
|
||||
Class<T> getBeanType();
|
||||
|
||||
/**
|
||||
* Return the query timeout.
|
||||
*/
|
||||
int getTimeout();
|
||||
|
||||
/**
|
||||
* Return the objects that should be added to the persistence context prior
|
||||
* to executing the query.
|
||||
*/
|
||||
ArrayList<EntityBean> getContextAdditions();
|
||||
|
||||
/**
|
||||
* Return the bind parameters.
|
||||
*/
|
||||
@@ -580,11 +553,6 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
*/
|
||||
String getRawWhereClause();
|
||||
|
||||
/**
|
||||
* Return the Id value.
|
||||
*/
|
||||
Object getId();
|
||||
|
||||
/**
|
||||
* Set the generated sql for debug purposes.
|
||||
*/
|
||||
|
||||
@@ -41,7 +41,6 @@ public class BootupClasses implements ClassPathSearchMatcher {
|
||||
|
||||
private ArrayList<Class<?>> transactionEventListenerList = new ArrayList<Class<?>>();
|
||||
|
||||
private ArrayList<Class<?>> beanFinderList = new ArrayList<Class<?>>();
|
||||
private ArrayList<Class<?>> beanFindControllerList = new ArrayList<Class<?>>();
|
||||
private ArrayList<Class<?>> beanQueryAdapterList = new ArrayList<Class<?>>();
|
||||
|
||||
@@ -282,13 +281,6 @@ public class BootupClasses implements ClassPathSearchMatcher {
|
||||
return transactionEventListenerList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of BeanFinders found.
|
||||
*/
|
||||
public List<Class<?>> getBeanFinders() {
|
||||
return beanFinderList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of BeanListeners found.
|
||||
*/
|
||||
@@ -351,11 +343,6 @@ public class BootupClasses implements ClassPathSearchMatcher {
|
||||
interesting = true;
|
||||
}
|
||||
|
||||
if (BeanFinder.class.isAssignableFrom(cls)) {
|
||||
beanFinderList.add(cls);
|
||||
interesting = true;
|
||||
}
|
||||
|
||||
if (BeanFindController.class.isAssignableFrom(cls)) {
|
||||
beanFindControllerList.add(cls);
|
||||
interesting = true;
|
||||
|
||||
@@ -121,7 +121,7 @@ public class DefaultBeanLoader {
|
||||
query.where().raw(ew);
|
||||
}
|
||||
|
||||
query.setLazyLoadForParents(idList, many);
|
||||
query.setLazyLoadForParents(many);
|
||||
many.addWhereParentIdIn(query, idList);
|
||||
|
||||
query.setPersistenceContext(pc);
|
||||
|
||||
@@ -1163,16 +1163,15 @@ public final class DefaultServer implements SpiEbeanServer {
|
||||
public <T> T findUnique(Query<T> query, Transaction t) {
|
||||
|
||||
// actually a find by Id type of query...
|
||||
// ... perhaps with joins and cache hints?
|
||||
SpiQuery<T> q = (SpiQuery<T>) query;
|
||||
Object id = q.getId();
|
||||
// ... perhaps with joins and cache hints
|
||||
Object id = query.getId();
|
||||
if (id != null) {
|
||||
return findId(query, t);
|
||||
}
|
||||
|
||||
BeanDescriptor<T> desc = beanDescriptorManager.getBeanDescriptor(q.getBeanType());
|
||||
BeanDescriptor<T> desc = beanDescriptorManager.getBeanDescriptor(query.getBeanType());
|
||||
|
||||
T bean = desc.cacheNaturalKeyLookup(q, (SpiTransaction) t);
|
||||
T bean = desc.cacheNaturalKeyLookup((SpiQuery<T>)query, (SpiTransaction) t);
|
||||
if (bean != null) {
|
||||
return bean;
|
||||
}
|
||||
@@ -1324,15 +1323,6 @@ public final class DefaultServer implements SpiEbeanServer {
|
||||
return new LimitOffsetPagedList<T>(this, (SpiQuery<T>)query, pageIndex, pageSize);
|
||||
}
|
||||
|
||||
public <T> void findVisit(Query<T> query, QueryResultVisitor<T> visitor, Transaction t) {
|
||||
|
||||
SpiOrmQueryRequest<T> request = createQueryRequest(Type.ITERATE, query, t);
|
||||
|
||||
request.initTransIfRequired();
|
||||
request.findVisit(visitor);
|
||||
// no try finally - findVisit guarantee's cleanup of the transaction if required
|
||||
}
|
||||
|
||||
public <T> void findEach(Query<T> query, QueryEachConsumer<T> consumer, Transaction t) {
|
||||
|
||||
SpiOrmQueryRequest<T> request = createQueryRequest(Type.ITERATE, query, t);
|
||||
@@ -1500,23 +1490,11 @@ public final class DefaultServer implements SpiEbeanServer {
|
||||
persister.update(checkEntityBean(bean), t, deleteMissingChildren);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all beans in the collection.
|
||||
*/
|
||||
public void update(Collection<?> beans) {
|
||||
updateAll(beans, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAll(Collection<?> beans) throws OptimisticLockException {
|
||||
updateAll(beans, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Collection<?> beans, Transaction transaction) throws OptimisticLockException {
|
||||
updateAll(beans, transaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all beans in the collection with an explicit transaction.
|
||||
*/
|
||||
@@ -1562,16 +1540,6 @@ public final class DefaultServer implements SpiEbeanServer {
|
||||
insertAll(beans, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insert(Collection<?> beans) {
|
||||
insertAll(beans, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insert(Collection<?> beans, Transaction transaction) {
|
||||
insertAll(beans, transaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert all beans in the collection with a transaction.
|
||||
*/
|
||||
@@ -1690,35 +1658,6 @@ public final class DefaultServer implements SpiEbeanServer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform an update or insert on each bean in the iterator. Returns the
|
||||
* number of beans that where saved.
|
||||
*/
|
||||
public int save(Iterator<?> it) {
|
||||
return saveAllInternal(it, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform an update or insert on each bean in the collection. Returns the
|
||||
* number of beans that where saved.
|
||||
*/
|
||||
public int save(Collection<?> c) {
|
||||
return saveAllInternal(c.iterator(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform an update or insert on each bean in the collection. Returns the
|
||||
* number of beans that where saved.
|
||||
*/
|
||||
public int save(Collection<?> c, Transaction t) {
|
||||
return saveAllInternal(c.iterator(), t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(Iterator<?> it, Transaction transaction) throws OptimisticLockException {
|
||||
return saveAllInternal(it, transaction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveAll(Collection<?> beans, Transaction transaction) throws OptimisticLockException {
|
||||
return saveAllInternal(beans.iterator(), transaction);
|
||||
@@ -1775,16 +1714,6 @@ public final class DefaultServer implements SpiEbeanServer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Class<?> beanType, Collection<?> ids) {
|
||||
deleteAll(beanType, ids, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Class<?> beanType, Collection<?> ids, Transaction transaction) {
|
||||
deleteAll(beanType, ids, transaction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Class<?> beanType, Collection<?> ids) {
|
||||
deleteAll(beanType, ids, null);
|
||||
@@ -1820,27 +1749,6 @@ public final class DefaultServer implements SpiEbeanServer {
|
||||
persister.delete(checkEntityBean(bean), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all the beans in the iterator.
|
||||
*/
|
||||
@Override
|
||||
public int delete(Iterator<?> it) {
|
||||
return deleteAllInternal(it, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all the beans in the collection.
|
||||
*/
|
||||
@Override
|
||||
public int delete(Collection<?> beans) {
|
||||
return deleteAllInternal(beans.iterator(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Iterator<?> it, Transaction transaction) throws OptimisticLockException {
|
||||
return deleteAllInternal(it, transaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all the beans in the collection.
|
||||
*/
|
||||
@@ -2065,12 +1973,6 @@ public final class DefaultServer implements SpiEbeanServer {
|
||||
// immutable thread safe so return shared instance
|
||||
return jsonContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonContext createJsonContext() {
|
||||
return json();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void collectQueryStats(ObjectGraphNode node, long loadedBeanCount, long timeMicros) {
|
||||
|
||||
@@ -259,19 +259,6 @@ public final class OrmQueryRequest<T> extends BeanRequest implements BeanQueryRe
|
||||
}
|
||||
}
|
||||
|
||||
public void findVisit(QueryResultVisitor<T> visitor) {
|
||||
QueryIterator<T> it = queryEngine.findIterate(this);
|
||||
try {
|
||||
while (it.hasNext()) {
|
||||
if (!visitor.accept(it.next())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
it.close();
|
||||
}
|
||||
}
|
||||
|
||||
public QueryIterator<T> findIterate() {
|
||||
return queryEngine.findIterate(this);
|
||||
}
|
||||
|
||||
@@ -1,115 +1,104 @@
|
||||
package com.avaje.ebeaninternal.server.core;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.avaje.ebean.QueryEachConsumer;
|
||||
import com.avaje.ebean.QueryEachWhileConsumer;
|
||||
import com.avaje.ebean.QueryIterator;
|
||||
import com.avaje.ebean.QueryResultVisitor;
|
||||
import com.avaje.ebean.bean.BeanCollection;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Defines the ORM query request api.
|
||||
*/
|
||||
public interface SpiOrmQueryRequest<T> {
|
||||
|
||||
/**
|
||||
* Return the query.
|
||||
*/
|
||||
public SpiQuery<T> getQuery();
|
||||
/**
|
||||
* Return the query.
|
||||
*/
|
||||
SpiQuery<T> getQuery();
|
||||
|
||||
/**
|
||||
* Return the associated BeanDescriptor.
|
||||
*/
|
||||
public BeanDescriptor<?> getBeanDescriptor();
|
||||
/**
|
||||
* Return the associated BeanDescriptor.
|
||||
*/
|
||||
BeanDescriptor<?> getBeanDescriptor();
|
||||
|
||||
/**
|
||||
* This will create a local (readOnly) transaction if no current transaction
|
||||
* exists.
|
||||
* <p>
|
||||
* A transaction may have been passed in explicitly or currently be active
|
||||
* in the thread local. If not, then a readOnly transaction is created to
|
||||
* execute this query.
|
||||
* </p>
|
||||
*/
|
||||
public void initTransIfRequired();
|
||||
/**
|
||||
* This will create a local (readOnly) transaction if no current transaction
|
||||
* exists.
|
||||
* <p>
|
||||
* A transaction may have been passed in explicitly or currently be active
|
||||
* in the thread local. If not, then a readOnly transaction is created to
|
||||
* execute this query.
|
||||
* </p>
|
||||
*/
|
||||
void initTransIfRequired();
|
||||
|
||||
/**
|
||||
* Will end a locally created transaction.
|
||||
* <p>
|
||||
* It ends the transaction by using a rollback() as the transaction is known
|
||||
* to be readOnly.
|
||||
* </p>
|
||||
*/
|
||||
public void endTransIfRequired();
|
||||
/**
|
||||
* Will end a locally created transaction.
|
||||
* <p>
|
||||
* It ends the transaction by using a rollback() as the transaction is known
|
||||
* to be readOnly.
|
||||
* </p>
|
||||
*/
|
||||
void endTransIfRequired();
|
||||
|
||||
/**
|
||||
* Execute the query as findById.
|
||||
*/
|
||||
public Object findId();
|
||||
/**
|
||||
* Execute the query as findById.
|
||||
*/
|
||||
Object findId();
|
||||
|
||||
/**
|
||||
* Execute the find row count query.
|
||||
*/
|
||||
public int findRowCount();
|
||||
/**
|
||||
* Execute the find row count query.
|
||||
*/
|
||||
int findRowCount();
|
||||
|
||||
/**
|
||||
* Execute the find ids query.
|
||||
*/
|
||||
public List<Object> findIds();
|
||||
|
||||
/**
|
||||
* Execute the find returning a QueryIterator and visitor pattern.
|
||||
*/
|
||||
public void findVisit(QueryResultVisitor<T> visitor);
|
||||
/**
|
||||
* Execute the find ids query.
|
||||
*/
|
||||
List<Object> findIds();
|
||||
|
||||
/**
|
||||
* Execute the find returning a QueryIterator and visitor pattern.
|
||||
*/
|
||||
public void findEach(QueryEachConsumer<T> consumer);
|
||||
void findEach(QueryEachConsumer<T> consumer);
|
||||
|
||||
/**
|
||||
* Execute the find returning a QueryIterator and visitor pattern.
|
||||
*/
|
||||
public void findEachWhile(QueryEachWhileConsumer<T> consumer);
|
||||
void findEachWhile(QueryEachWhileConsumer<T> consumer);
|
||||
|
||||
/**
|
||||
* Execute the find returning a QueryIterator.
|
||||
*/
|
||||
public QueryIterator<T> findIterate();
|
||||
|
||||
/**
|
||||
* Execute the query as findList.
|
||||
*/
|
||||
public List<T> findList();
|
||||
* Execute the find returning a QueryIterator.
|
||||
*/
|
||||
QueryIterator<T> findIterate();
|
||||
|
||||
/**
|
||||
* Execute the query as findSet.
|
||||
*/
|
||||
public Set<?> findSet();
|
||||
/**
|
||||
* Execute the query as findList.
|
||||
*/
|
||||
List<T> findList();
|
||||
|
||||
/**
|
||||
* Execute the query as findMap.
|
||||
*/
|
||||
public Map<?, ?> findMap();
|
||||
/**
|
||||
* Execute the query as findSet.
|
||||
*/
|
||||
Set<?> findSet();
|
||||
|
||||
/**
|
||||
* Try to get the object out of the persistence context.
|
||||
*/
|
||||
//public T getFromPersistenceContextOrCache();
|
||||
/**
|
||||
* Execute the query as findMap.
|
||||
*/
|
||||
Map<?, ?> findMap();
|
||||
|
||||
/**
|
||||
* Try to get the query result from the query cache.
|
||||
*/
|
||||
public BeanCollection<T> getFromQueryCache();
|
||||
/**
|
||||
* Try to get the query result from the query cache.
|
||||
*/
|
||||
BeanCollection<T> getFromQueryCache();
|
||||
|
||||
/**
|
||||
* Return the Database platform like clause.
|
||||
*/
|
||||
public String getDBLikeClause();
|
||||
/**
|
||||
* Return the Database platform like clause.
|
||||
*/
|
||||
String getDBLikeClause();
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.deploy;
|
||||
|
||||
import com.avaje.ebean.bean.BeanCollection;
|
||||
import com.avaje.ebean.event.BeanFindController;
|
||||
import com.avaje.ebean.event.BeanFinder;
|
||||
import com.avaje.ebean.event.BeanQueryRequest;
|
||||
|
||||
/**
|
||||
* Wraps the old BeanFinder to make it implement BeanFindController.
|
||||
*/
|
||||
public class BeanFinderAdapter implements BeanFindController {
|
||||
|
||||
final BeanFinder beanFinder;
|
||||
|
||||
public BeanFinderAdapter(BeanFinder beanFinder) {
|
||||
this.beanFinder = beanFinder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegisterFor(Class<?> cls) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInterceptFind(BeanQueryRequest<?> request) {
|
||||
// always intercept to support old behavior
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T find(BeanQueryRequest<T> request) {
|
||||
return (T)beanFinder.find(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> BeanCollection<T> findMany(BeanQueryRequest<T> request) {
|
||||
return beanFinder.findMany(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInterceptFindMany(BeanQueryRequest<?> request) {
|
||||
// always intercept to support old behavior
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,12 @@
|
||||
package com.avaje.ebeaninternal.server.deploy;
|
||||
|
||||
import com.avaje.ebean.event.BeanFindController;
|
||||
import com.avaje.ebean.event.BeanFinder;
|
||||
import com.avaje.ebeaninternal.server.core.BootupClasses;
|
||||
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Default implementation for BeanFinderFactory.
|
||||
@@ -19,31 +15,14 @@ public class BeanFinderManager {
|
||||
|
||||
final Logger logger = LoggerFactory.getLogger(BeanFinderManager.class);
|
||||
|
||||
/**
|
||||
* Register of BeanFinder instances.
|
||||
*/
|
||||
final Map<Class<?>, BeanFinder<?>> registerFor = new HashMap<Class<?>, BeanFinder<?>>();
|
||||
|
||||
private final List<BeanFindController> list;
|
||||
|
||||
public BeanFinderManager(BootupClasses bootupClasses) {
|
||||
list = bootupClasses.getBeanFindControllers();
|
||||
|
||||
List<Class<?>> beanFinders = bootupClasses.getBeanFinders();
|
||||
for (Class<?> cls : beanFinders) {
|
||||
Class<?> entityType = getEntityClass(cls);
|
||||
try {
|
||||
BeanFinder<?> beanFinder = (BeanFinder<?>) cls.newInstance();
|
||||
registerFor.put(entityType, beanFinder);
|
||||
|
||||
} catch (Exception ex) {
|
||||
throw new PersistenceException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getRegisterCount() {
|
||||
return registerFor.size() + list.size();
|
||||
return list.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,28 +37,6 @@ public class BeanFinderManager {
|
||||
deployDesc.setBeanFinder(c);
|
||||
}
|
||||
}
|
||||
// support the deprecated BeanFinder
|
||||
BeanFinder beanFinder = registerFor.get(deployDesc.getBeanType());
|
||||
if (beanFinder != null) {
|
||||
deployDesc.setBeanFinder(new BeanFinderAdapter(beanFinder));
|
||||
logger.debug("BeanFinder on[" + deployDesc.getFullName() + "] " + beanFinder.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the entity class given the controller class.
|
||||
* <p>
|
||||
* This uses reflection to find the generics parameter type.
|
||||
* </p>
|
||||
*/
|
||||
private Class<?> getEntityClass(Class<?> controller) {
|
||||
|
||||
Class<?> cls = ParamTypeUtil.findParamType(controller, BeanFinder.class);
|
||||
|
||||
if (cls == null) {
|
||||
String msg = "Could not determine the entity class (generics parameter type) from " + controller + " using reflection.";
|
||||
throw new PersistenceException(msg);
|
||||
}
|
||||
return cls;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.avaje.ebeaninternal.server.deploy.parse;
|
||||
|
||||
import com.avaje.ebean.annotation.ColumnHstore;
|
||||
import com.avaje.ebean.annotation.CreatedTimestamp;
|
||||
import com.avaje.ebean.annotation.DbHstore;
|
||||
import com.avaje.ebean.annotation.DbJson;
|
||||
@@ -180,9 +179,7 @@ public class AnnotationFields extends AnnotationParser {
|
||||
util.setDbJsonBType(prop);
|
||||
}
|
||||
}
|
||||
if (get(prop, ColumnHstore.class) != null) {
|
||||
util.setDbHstore(prop);
|
||||
}
|
||||
|
||||
if (get(prop, DbHstore.class) != null) {
|
||||
util.setDbHstore(prop);
|
||||
}
|
||||
|
||||
+12
-5
@@ -1,12 +1,16 @@
|
||||
package com.avaje.ebeaninternal.server.deploy.parse;
|
||||
|
||||
import com.avaje.ebean.annotation.ColumnHstore;
|
||||
import com.avaje.ebean.annotation.DbHstore;
|
||||
import com.avaje.ebean.annotation.DbJson;
|
||||
import com.avaje.ebean.annotation.DbJsonB;
|
||||
import com.avaje.ebeaninternal.server.deploy.DetermineManyType;
|
||||
import com.avaje.ebeaninternal.server.deploy.ManyType;
|
||||
import com.avaje.ebeaninternal.server.deploy.meta.*;
|
||||
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanProperty;
|
||||
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocMany;
|
||||
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne;
|
||||
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanPropertyCompound;
|
||||
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanPropertySimpleCollection;
|
||||
import com.avaje.ebeaninternal.server.type.CtCompoundType;
|
||||
import com.avaje.ebeaninternal.server.type.ScalarType;
|
||||
import com.avaje.ebeaninternal.server.type.TypeManager;
|
||||
@@ -17,7 +21,11 @@ import org.slf4j.LoggerFactory;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.Transient;
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* Create the properties for a bean.
|
||||
@@ -294,8 +302,7 @@ public class DeployCreateProperties {
|
||||
private boolean isMappedType(Field field) {
|
||||
return (field.getAnnotation(DbJson.class) != null)
|
||||
|| (field.getAnnotation(DbJsonB.class) != null)
|
||||
|| (field.getAnnotation(DbHstore.class) != null)
|
||||
|| (field.getAnnotation(ColumnHstore.class) != null);
|
||||
|| (field.getAnnotation(DbHstore.class) != null);
|
||||
}
|
||||
|
||||
private boolean isTransientField(Field field) {
|
||||
|
||||
@@ -252,11 +252,6 @@ abstract class JunctionExpression<T> implements Junction<T>, SpiExpression, Expr
|
||||
exprList.findEachWhile(consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findVisit(QueryResultVisitor<T> visitor) {
|
||||
exprList.findVisit(visitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryIterator<T> findIterate() {
|
||||
return exprList.findIterate();
|
||||
|
||||
@@ -51,11 +51,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
|
||||
private transient final ExpressionFactory expressionFactory;
|
||||
|
||||
/**
|
||||
* Used to add beans to the PersistanceContext prior to query.
|
||||
*/
|
||||
private transient ArrayList<EntityBean> contextAdditions;
|
||||
|
||||
/**
|
||||
* For lazy loading of ManyToMany we need to add a join to the intersection table. This is that
|
||||
* join to the intersection table.
|
||||
@@ -137,7 +132,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
|
||||
private List<Object> partialIds;
|
||||
|
||||
private int timeout = -1;
|
||||
private int timeout;
|
||||
|
||||
/**
|
||||
* The property used to get the key value for a Map.
|
||||
@@ -205,8 +200,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
|
||||
private BeanPropertyAssocMany<?> lazyLoadForParentsProperty;
|
||||
|
||||
private List<Object> lazyLoadForParentsIds;
|
||||
|
||||
/**
|
||||
* Hash of final query after AutoFetch tuning.
|
||||
*/
|
||||
@@ -313,10 +306,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
this.lazyLoadProperty = lazyLoadProperty;
|
||||
}
|
||||
|
||||
public String getLazyLoadManyPath() {
|
||||
return lazyLoadManyPath;
|
||||
}
|
||||
|
||||
public ExpressionFactory getExpressionFactory() {
|
||||
return expressionFactory;
|
||||
}
|
||||
@@ -389,11 +378,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
select(beanDescriptor.getIdBinder().getIdProperty());
|
||||
}
|
||||
|
||||
public void convertWhereNaturalKeyToId(Object idValue) {
|
||||
whereExpressions = new DefaultExpressionList<T>(this, null);
|
||||
setId(idValue);
|
||||
}
|
||||
|
||||
public NaturalKeyBindParam getNaturalKeyBindParam() {
|
||||
NaturalKeyBindParam namedBind = null;
|
||||
if (bindParams != null) {
|
||||
@@ -426,6 +410,10 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
}
|
||||
|
||||
public DefaultOrmQuery<T> copy() {
|
||||
return copy(server);
|
||||
}
|
||||
|
||||
public DefaultOrmQuery<T> copy(EbeanServer server) {
|
||||
// Not including these in the copy:
|
||||
// contextAdditions
|
||||
// queryListener
|
||||
@@ -535,16 +523,10 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLazyLoadForParents(List<Object> parentIds, BeanPropertyAssocMany<?> many) {
|
||||
this.lazyLoadForParentsIds = parentIds;
|
||||
public void setLazyLoadForParents(BeanPropertyAssocMany<?> many) {
|
||||
this.lazyLoadForParentsProperty = many;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getLazyLoadForParentIds() {
|
||||
return lazyLoadForParentsIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeanPropertyAssocMany<?> getLazyLoadForParentsProperty() {
|
||||
return lazyLoadForParentsProperty;
|
||||
@@ -753,8 +735,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
hc = hc * 31 + (whereExpressions == null ? 0 : whereExpressions.queryBindHash());
|
||||
hc = hc * 31 + (havingExpressions == null ? 0 : havingExpressions.queryBindHash());
|
||||
hc = hc * 31 + (bindParams == null ? 0 : bindParams.queryBindHash());
|
||||
hc = hc * 31 + (contextAdditions == null ? 0 : contextAdditions.hashCode());
|
||||
|
||||
return hc;
|
||||
}
|
||||
|
||||
@@ -917,10 +897,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
return server.findRowCount(this, null);
|
||||
}
|
||||
|
||||
public void findVisit(QueryResultVisitor<T> visitor) {
|
||||
server.findVisit(this, visitor, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findEachWhile(QueryEachWhileConsumer<T> consumer) {
|
||||
server.findEachWhile(this, consumer, null);
|
||||
@@ -1096,26 +1072,6 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
return detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return any beans that should be added to the persistence context prior to executing the query.
|
||||
*/
|
||||
public final ArrayList<EntityBean> getContextAdditions() {
|
||||
return contextAdditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a bean to the context additions.
|
||||
* <p>
|
||||
* These are added to the persistence context before executing the query.
|
||||
* </p>
|
||||
*/
|
||||
public void contextAdd(EntityBean bean) {
|
||||
if (contextAdditions == null) {
|
||||
contextAdditions = new ArrayList<EntityBean>();
|
||||
}
|
||||
contextAdditions.add(bean);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Query [" + whereExpressions + "]";
|
||||
}
|
||||
|
||||
@@ -182,11 +182,6 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
query.findEachWhile(consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findVisit(QueryResultVisitor<T> visitor) {
|
||||
query.findVisit(visitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryIterator<T> findIterate() {
|
||||
return query.findIterate();
|
||||
|
||||
@@ -413,11 +413,6 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void findVisit(Query<T> query, QueryResultVisitor<T> visitor, Transaction transaction) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> findList(Query<T> query, Transaction transaction) {
|
||||
return null;
|
||||
@@ -488,31 +483,11 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(Iterator<?> it) throws OptimisticLockException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(Collection<?> beans) throws OptimisticLockException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Object bean) throws OptimisticLockException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Iterator<?> it) throws OptimisticLockException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Collection<?> c) throws OptimisticLockException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Class<?> beanType, Object id) {
|
||||
return 0;
|
||||
@@ -523,16 +498,6 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Class<?> beanType, Collection<?> ids) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Class<?> beanType, Collection<?> ids, Transaction transaction) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute(SqlUpdate updSql) {
|
||||
return 0;
|
||||
@@ -568,16 +533,6 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(Iterator<?> it, Transaction transaction) throws OptimisticLockException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(Collection<?> beans, Transaction transaction) throws OptimisticLockException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markAsDirty(Object bean) {
|
||||
|
||||
@@ -598,16 +553,6 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Collection<?> beans) throws OptimisticLockException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Collection<?> beans, Transaction transaction) throws OptimisticLockException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insert(Object bean) {
|
||||
|
||||
@@ -618,16 +563,6 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insert(Collection<?> beans) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insert(Collection<?> beans, Transaction t) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteManyToManyAssociations(Object ownerBean, String propertyName) {
|
||||
return 0;
|
||||
@@ -663,11 +598,6 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Iterator<?> it, Transaction t) throws OptimisticLockException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute(SqlUpdate updSql, Transaction t) {
|
||||
return 0;
|
||||
@@ -718,11 +648,6 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonContext createJsonContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonContext json() {
|
||||
return null;
|
||||
|
||||
@@ -16,7 +16,7 @@ public class TestNotEnhancedMappedSuper extends BaseTestCase {
|
||||
|
||||
ASimpleBean bean = new ASimpleBean();
|
||||
bean.setName("junk");
|
||||
|
||||
|
||||
Ebean.save(bean);
|
||||
Assert.assertNotNull(bean.getId());
|
||||
|
||||
|
||||
@@ -15,63 +15,64 @@ import com.avaje.tests.model.basic.ResetBasicData;
|
||||
public class TestDeleteByIdCollection extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Customer c0 = ResetBasicData.createCustomer("del1", "del1 ship", "del1 bill", 1);
|
||||
Customer c1 = ResetBasicData.createCustomer("del2", "del2 ship", "del2 bill", 2);
|
||||
|
||||
Ebean.save(c0);
|
||||
Ebean.save(c1);
|
||||
public void test() {
|
||||
|
||||
Customer c0Back = Ebean.find(Customer.class, c0.getId());
|
||||
Customer c1Back = Ebean.find(Customer.class, ""+c1.getId());
|
||||
ResetBasicData.reset();
|
||||
|
||||
Assert.assertNotNull(c0Back);
|
||||
Assert.assertNotNull(c1Back);
|
||||
|
||||
List<String> ids = new ArrayList<String>();
|
||||
// also test id type conversion
|
||||
ids.add(""+c0.getId());
|
||||
ids.add(""+c1.getId());
|
||||
|
||||
|
||||
Ebean.delete(Customer.class, ids);
|
||||
|
||||
c0Back = Ebean.find(Customer.class, c0.getId());
|
||||
c1Back = Ebean.find(Customer.class, ""+c1.getId());
|
||||
|
||||
Assert.assertNull(c0Back);
|
||||
Assert.assertNull(c1Back);
|
||||
}
|
||||
|
||||
public void testDelByStatement() {
|
||||
Customer c0 = ResetBasicData.createCustomer("del1", "del1 ship", "del1 bill", 1);
|
||||
Customer c1 = ResetBasicData.createCustomer("del2", "del2 ship", "del2 bill", 2);
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Order order0 = ResetBasicData.createOrderCustAndOrder("delBySql 0");
|
||||
Order order1 = ResetBasicData.createOrderCustAndOrder("delBySql 1");
|
||||
|
||||
Order o0Back = Ebean.find(Order.class, order0.getId());
|
||||
Order o1Back = Ebean.find(Order.class, order1.getId());
|
||||
|
||||
Assert.assertNotNull(o0Back);
|
||||
Assert.assertNotNull(o1Back);
|
||||
|
||||
Ebean.save(c0);
|
||||
Ebean.save(c1);
|
||||
|
||||
List<Object> ids = new ArrayList<Object>();
|
||||
// also test id type conversion
|
||||
ids.add(order0.getId());
|
||||
ids.add(order1.getId());
|
||||
Customer c0Back = Ebean.find(Customer.class, c0.getId());
|
||||
Customer c1Back = Ebean.find(Customer.class, "" + c1.getId());
|
||||
|
||||
Assert.assertNotNull(c0Back);
|
||||
Assert.assertNotNull(c1Back);
|
||||
|
||||
List<String> ids = new ArrayList<String>();
|
||||
// also test id type conversion
|
||||
ids.add("" + c0.getId());
|
||||
ids.add("" + c1.getId());
|
||||
|
||||
|
||||
Ebean.deleteAll(Customer.class, ids);
|
||||
|
||||
c0Back = Ebean.find(Customer.class, c0.getId());
|
||||
c1Back = Ebean.find(Customer.class, "" + c1.getId());
|
||||
|
||||
Assert.assertNull(c0Back);
|
||||
Assert.assertNull(c1Back);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelByStatement() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Order order0 = ResetBasicData.createOrderCustAndOrder("delBySql 0");
|
||||
Order order1 = ResetBasicData.createOrderCustAndOrder("delBySql 1");
|
||||
|
||||
Order o0Back = Ebean.find(Order.class, order0.getId());
|
||||
Order o1Back = Ebean.find(Order.class, order1.getId());
|
||||
|
||||
Assert.assertNotNull(o0Back);
|
||||
Assert.assertNotNull(o1Back);
|
||||
|
||||
|
||||
List<Object> ids = new ArrayList<Object>();
|
||||
// also test id type conversion
|
||||
ids.add(order0.getId());
|
||||
ids.add(order1.getId());
|
||||
|
||||
Ebean.deleteAll(Order.class, ids);
|
||||
|
||||
o0Back = Ebean.find(Order.class, order0.getId());
|
||||
o1Back = Ebean.find(Order.class, order1.getId());
|
||||
|
||||
Assert.assertNull(o0Back);
|
||||
Assert.assertNull(o1Back);
|
||||
}
|
||||
|
||||
Ebean.delete(Order.class, ids);
|
||||
|
||||
o0Back = Ebean.find(Order.class, order0.getId());
|
||||
o1Back = Ebean.find(Order.class, order1.getId());
|
||||
|
||||
Assert.assertNull(o0Back);
|
||||
Assert.assertNull(o1Back);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TestDeleteByIdList extends BaseTestCase {
|
||||
|
||||
Assert.assertEquals(2, orderIds.size());
|
||||
|
||||
Ebean.delete(Order.class, orderIds);
|
||||
Ebean.deleteAll(Order.class, orderIds);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public class TestBatchInsertSimple extends BaseTestCase {
|
||||
transaction.setBatchSize(20);
|
||||
|
||||
// escalate based on batchOnCascade value
|
||||
Ebean.save(masters);
|
||||
Ebean.saveAll(masters);
|
||||
|
||||
transaction.commit();
|
||||
|
||||
@@ -119,7 +119,7 @@ public class TestBatchInsertSimple extends BaseTestCase {
|
||||
}
|
||||
|
||||
// escalate based on batchOnCascade value
|
||||
Ebean.save(masters);
|
||||
Ebean.saveAll(masters);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -30,9 +30,10 @@ import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||
* @see https://groups.google.com/forum/#!topic/ebean/VD1MV2-LrOc
|
||||
*/
|
||||
public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase {
|
||||
|
||||
@Before public void before() {
|
||||
// remove all the User records first
|
||||
Ebean.delete(Ebean.find(User.class).findList());
|
||||
Ebean.deleteAll(Ebean.find(User.class).findList());
|
||||
|
||||
// insert 2 User records
|
||||
Ebean.save(new User(1L));
|
||||
@@ -59,7 +60,7 @@ public class TestOnCascadeDeleteChildrenWithCompositeKeys extends BaseTestCase {
|
||||
ids.add(1L);
|
||||
ids.add(2L);
|
||||
|
||||
Ebean.delete(User.class, ids); // PersistenceException would be thrown here
|
||||
Ebean.deleteAll(User.class, ids); // PersistenceException would be thrown here
|
||||
assertEquals(0, Ebean.find(User.class).findList().size());
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class TestDeleteByIdWithPersistenceContext extends BaseTestCase {
|
||||
server.find(Product.class, prod1.getId());
|
||||
server.find(Product.class, prod2.getId());
|
||||
|
||||
server.delete(Product.class, Arrays.asList(prod1.getId(), prod2.getId()));
|
||||
server.deleteAll(Product.class, Arrays.asList(prod1.getId(), prod2.getId()));
|
||||
|
||||
// are these found in the persistence context?
|
||||
Product shadow1 = server.find(Product.class, prod1.getId());
|
||||
|
||||
@@ -54,7 +54,7 @@ public class TestInsertCollection extends BaseTestCase {
|
||||
saveList.add(cust1Check2);
|
||||
saveList.add(cust3);
|
||||
|
||||
Ebean.save(saveList);
|
||||
Ebean.saveAll(saveList);
|
||||
|
||||
|
||||
Customer cust1Check3 = Ebean.find(Customer.class, cust1.getId());
|
||||
|
||||
@@ -44,7 +44,7 @@ public class TestM2MDeleteWithCascade extends BaseTestCase {
|
||||
|
||||
Assert.assertEquals("roles not deleted", 2, rc);
|
||||
|
||||
Ebean.delete(roles);
|
||||
Ebean.deleteAll(roles);
|
||||
|
||||
rc = Ebean.find(MRole.class).where().idIn(roleIds).findRowCount();
|
||||
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.avaje.tests.query;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebean.FetchConfig;
|
||||
import com.avaje.ebean.Query;
|
||||
import com.avaje.ebean.QueryResultVisitor;
|
||||
import com.avaje.ebean.QueryEachConsumer;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class TestQueryFindVisit extends BaseTestCase {
|
||||
|
||||
@@ -29,11 +28,9 @@ public class TestQueryFindVisit extends BaseTestCase {
|
||||
|
||||
final AtomicInteger counter = new AtomicInteger(0);
|
||||
|
||||
query.findVisit(new QueryResultVisitor<Customer>() {
|
||||
|
||||
public boolean accept(Customer bean) {
|
||||
query.findEach(new QueryEachConsumer<Customer>() {
|
||||
public void accept(Customer bean) {
|
||||
counter.incrementAndGet();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -56,14 +53,13 @@ public class TestQueryFindVisit extends BaseTestCase {
|
||||
|
||||
final AtomicInteger counter = new AtomicInteger(0);
|
||||
|
||||
query.findVisit(new QueryResultVisitor<Customer>() {
|
||||
query.findEach(new QueryEachConsumer<Customer>() {
|
||||
|
||||
public boolean accept(Customer bean) {
|
||||
public void accept(Customer bean) {
|
||||
counter.incrementAndGet();
|
||||
if (counter.intValue() > 0) {
|
||||
throw new IllegalStateException("cause a failure");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class TestManyLazyLoadingQuery extends BaseTestCase {
|
||||
|
||||
SpiQuery<?> query0 = (SpiQuery<?>)Ebean.find(OrderDetail.class);
|
||||
|
||||
query0.setLazyLoadForParents(parentIds, beanProperty);
|
||||
query0.setLazyLoadForParents(beanProperty);
|
||||
|
||||
beanProperty.addWhereParentIdIn(query0, parentIds);
|
||||
|
||||
|
||||
@@ -51,6 +51,6 @@ public class TestInsertManyAndRef extends BaseTestCase {
|
||||
bookmarks.add(b1);
|
||||
bookmarks.add(b2);
|
||||
|
||||
Ebean.save(bookmarks);
|
||||
Ebean.saveAll(bookmarks);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user