mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Compare commits
56
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb89300027 | ||
|
|
27cb0d062d | ||
|
|
140c1dd965 | ||
|
|
75b9e748f4 | ||
|
|
289c0253b1 | ||
|
|
07ce758302 | ||
|
|
d91729f65d | ||
|
|
9e64d09e07 | ||
|
|
5f63d5c35f | ||
|
|
23e1ab4bfd | ||
|
|
0e2900d796 | ||
|
|
a46e086dc4 | ||
|
|
40ca179509 | ||
|
|
7632910027 | ||
|
|
ca777d7967 | ||
|
|
a315c7c11e | ||
|
|
35f3f53443 | ||
|
|
40f5596837 | ||
|
|
43c978e41a | ||
|
|
6120a465e1 | ||
|
|
8bb884374b | ||
|
|
3d8db775f7 | ||
|
|
b3b8f6b154 | ||
|
|
e4c80582a5 | ||
|
|
1846427859 | ||
|
|
82102340b8 | ||
|
|
d9e884b8bd | ||
|
|
6744c7886a | ||
|
|
271b4ee095 | ||
|
|
7cfdd331ca | ||
|
|
7e15faa9a8 | ||
|
|
1292c86b76 | ||
|
|
0260a73cb6 | ||
|
|
085fdaf177 | ||
|
|
a4b49dfa27 | ||
|
|
d056151852 | ||
|
|
f9ba6f9a3a | ||
|
|
2fa4345742 | ||
|
|
d9147327c1 | ||
|
|
5ad9a611f9 | ||
|
|
3fb497b651 | ||
|
|
fbfe5d1ff8 | ||
|
|
b6f21f8649 | ||
|
|
8fd04807c7 | ||
|
|
e49c42302a | ||
|
|
d96abece75 | ||
|
|
c953da637e | ||
|
|
8d39b0a996 | ||
|
|
0efcf1eeb3 | ||
|
|
335cef870f | ||
|
|
4c40962f04 | ||
|
|
9be0d22cfb | ||
|
|
2893d73fad | ||
|
|
33d66ea9d1 | ||
|
|
073ea9c550 | ||
|
|
8467934021 |
@@ -4,24 +4,20 @@
|
||||
<parent>
|
||||
<groupId>org.avaje</groupId>
|
||||
<artifactId>java8-parent</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.3</version>
|
||||
</parent>
|
||||
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean</artifactId>
|
||||
<version>10.1.3</version>
|
||||
<version>10.1.7</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ebean</name>
|
||||
<url>http://ebean-orm.github.io/</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
|
||||
<tag>ebean-10.1.3</tag>
|
||||
<tag>ebean-10.1.7</tag>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
@@ -41,7 +37,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-annotation</artifactId>
|
||||
<version>2.1</version>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -53,7 +49,7 @@
|
||||
<dependency>
|
||||
<groupId>org.avaje</groupId>
|
||||
<artifactId>avaje-datasource</artifactId>
|
||||
<version>1.1.4</version>
|
||||
<version>2.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -71,7 +67,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-dbmigration</artifactId>
|
||||
<version>10.1.2</version>
|
||||
<version>10.1.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -83,7 +79,7 @@
|
||||
<dependency>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4-runtime</artifactId>
|
||||
<version>4.5.3</version>
|
||||
<version>4.6</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Jackson core used internally by Ebean -->
|
||||
@@ -112,21 +108,21 @@
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>1.0.0.GA</version>
|
||||
<version>1.1.0.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.4</version>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>1.6</version>
|
||||
<version>2.9.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -134,7 +130,7 @@
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>9.4-1202-jdbc41</version>
|
||||
<version>9.4.1212.jre7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -157,14 +153,14 @@
|
||||
<dependency>
|
||||
<groupId>org.avaje</groupId>
|
||||
<artifactId>avaje-agentloader</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<version>2.1.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-agent</artifactId>
|
||||
<version>10.1.2</version>
|
||||
<version>10.1.6</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -173,28 +169,28 @@
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>1.4.192</version>
|
||||
<version>1.4.193</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.8.11.2</version>
|
||||
<version>3.15.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.3.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.36</version>
|
||||
<version>6.0.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -209,14 +205,14 @@
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.4</version>
|
||||
<version>2.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.avaje.moduuid</groupId>
|
||||
<artifactId>avaje-moduuid</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>2.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -229,17 +225,16 @@
|
||||
<plugin>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-maven-plugin</artifactId>
|
||||
<version>10.1.2</version>
|
||||
<version>10.1.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test</id>
|
||||
<phase>process-test-classes</phase>
|
||||
<configuration>
|
||||
<classSource>target/test-classes</classSource>
|
||||
<transformArgs>debug=1</transformArgs>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>enhance</goal>
|
||||
<goal>testEnhance</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.ebean;
|
||||
|
||||
import io.ebeanservice.docstore.api.DocQueryRequest;
|
||||
import io.ebeanservice.docstore.api.RawDoc;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -165,6 +166,24 @@ public interface DocumentStore {
|
||||
*/
|
||||
<T> void findEachWhile(DocQueryRequest<T> query, Predicate<T> consumer);
|
||||
|
||||
/**
|
||||
* Find each processing raw documents.
|
||||
*
|
||||
* @param indexNameType The full index name and type
|
||||
* @param rawQuery The query to execute
|
||||
* @param consumer Consumer to process each document
|
||||
*/
|
||||
void findEach(String indexNameType, String rawQuery, Consumer<RawDoc> consumer);
|
||||
|
||||
/**
|
||||
* Find each processing raw documents stopping when the predicate returns false.
|
||||
*
|
||||
* @param indexNameType The full index name and type
|
||||
* @param rawQuery The query to execute
|
||||
* @param consumer Consumer to process each document until false is returned
|
||||
*/
|
||||
void findEachWhile(String indexNameType, String rawQuery, Predicate<RawDoc> consumer);
|
||||
|
||||
/**
|
||||
* Process the queue entries sending updates to the document store or queuing them for later processing.
|
||||
*/
|
||||
|
||||
@@ -232,9 +232,9 @@ public interface EbeanServer {
|
||||
*
|
||||
* // Find order additionally fetching the customer, details and details.product name.
|
||||
*
|
||||
* String eql = "fetch customer fetch details fetch details.product (name) where id = :orderId ";
|
||||
* String ormQuery = "fetch customer fetch details fetch details.product (name) where id = :orderId ";
|
||||
*
|
||||
* Query<Order> query = Ebean.createQuery(Order.class, eql);
|
||||
* Query<Order> query = Ebean.createQuery(Order.class, ormQuery);
|
||||
* query.setParameter("orderId", 2);
|
||||
*
|
||||
* Order order = query.findUnique();
|
||||
@@ -251,11 +251,11 @@ public interface EbeanServer {
|
||||
* }</pre>
|
||||
*
|
||||
* @param beanType The type of bean to fetch
|
||||
* @param eql The Ebean query
|
||||
* @param ormQuery The Ebean ORM query
|
||||
* @param <T> The type of the entity bean
|
||||
* @return The query with expressions defined as per the parsed query statement
|
||||
*/
|
||||
<T> Query<T> createQuery(Class<T> beanType, String eql);
|
||||
<T> Query<T> createQuery(Class<T> beanType, String ormQuery);
|
||||
|
||||
/**
|
||||
* Create a query for a type of entity bean.
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.List;
|
||||
* </p>
|
||||
* <pre>{@code
|
||||
*
|
||||
* public class CustomerFinder extends Finder<Customer> {
|
||||
* public class CustomerFinder extends Finder<Long,Customer> {
|
||||
*
|
||||
* public CustomerFinder() {
|
||||
* super(Customer.class);
|
||||
@@ -31,7 +31,7 @@ import java.util.List;
|
||||
* }
|
||||
*
|
||||
* public List<Customer> findNew() {
|
||||
* return query()
|
||||
* return query().where()
|
||||
* .eq("status", Customer.Status.NEW)
|
||||
* .orderBy("name")
|
||||
* .findList()
|
||||
@@ -163,4 +163,11 @@ public class Finder<I, T> {
|
||||
public Query<T> nativeSql(String nativeSql) {
|
||||
return db().findNative(type, nativeSql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a query using the ORM query language.
|
||||
*/
|
||||
public Query<T> query(String ormQuery) {
|
||||
return db().createQuery(type, ormQuery);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +162,7 @@ public final class OrderBy<T> implements Serializable {
|
||||
list.add(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return list.toString();
|
||||
}
|
||||
@@ -201,6 +202,7 @@ public final class OrderBy<T> implements Serializable {
|
||||
* Return a hash value for this OrderBy. This can be to determine logical
|
||||
* equality for OrderBy clauses.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return list.hashCode();
|
||||
}
|
||||
@@ -276,6 +278,7 @@ public final class OrderBy<T> implements Serializable {
|
||||
return highLow != null ? highLow.equals(e.highLow) : e.highLow == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringFormat();
|
||||
}
|
||||
|
||||
@@ -61,20 +61,24 @@ public interface QueryIterator<T> extends Iterator<T>, java.io.Closeable {
|
||||
/**
|
||||
* Returns <tt>true</tt> if the iteration has more elements.
|
||||
*/
|
||||
@Override
|
||||
boolean hasNext();
|
||||
|
||||
/**
|
||||
* Returns the next element in the iteration.
|
||||
*/
|
||||
@Override
|
||||
T next();
|
||||
|
||||
/**
|
||||
* Remove is not allowed.
|
||||
*/
|
||||
@Override
|
||||
void remove();
|
||||
|
||||
/**
|
||||
* Close the underlying resources held by this iterator.
|
||||
*/
|
||||
@Override
|
||||
void close();
|
||||
}
|
||||
|
||||
@@ -292,6 +292,7 @@ public final class RawSql implements Serializable {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (!parsed) {
|
||||
return "unparsed[" + unparsedSql + "]";
|
||||
@@ -642,6 +643,7 @@ public final class RawSql implements Serializable {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return dbColumn + "->" + propertyName;
|
||||
}
|
||||
|
||||
@@ -39,16 +39,19 @@ public interface SqlRow extends Serializable, Map<String, Object> {
|
||||
/**
|
||||
* Remove a property from the map. Returns the value of the removed property.
|
||||
*/
|
||||
@Override
|
||||
Object remove(Object name);
|
||||
|
||||
/**
|
||||
* Return a property value by its name.
|
||||
*/
|
||||
@Override
|
||||
Object get(Object name);
|
||||
|
||||
/**
|
||||
* Set a value to a property.
|
||||
*/
|
||||
@Override
|
||||
Object put(String name, Object value);
|
||||
|
||||
/**
|
||||
@@ -118,51 +121,61 @@ public interface SqlRow extends Serializable, Map<String, Object> {
|
||||
/**
|
||||
* String description of the underlying map.
|
||||
*/
|
||||
@Override
|
||||
String toString();
|
||||
|
||||
/**
|
||||
* Clear the map.
|
||||
*/
|
||||
@Override
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Returns true if the map contains the property.
|
||||
*/
|
||||
@Override
|
||||
boolean containsKey(Object key);
|
||||
|
||||
/**
|
||||
* Returns true if the map contains the value.
|
||||
*/
|
||||
@Override
|
||||
boolean containsValue(Object value);
|
||||
|
||||
/**
|
||||
* Returns the entrySet of the map.
|
||||
*/
|
||||
@Override
|
||||
Set<Map.Entry<String, Object>> entrySet();
|
||||
|
||||
/**
|
||||
* Returns true if the map is empty.
|
||||
*/
|
||||
@Override
|
||||
boolean isEmpty();
|
||||
|
||||
/**
|
||||
* Returns the key set of the map.
|
||||
*/
|
||||
@Override
|
||||
Set<String> keySet();
|
||||
|
||||
/**
|
||||
* Put all the values from t into this map.
|
||||
*/
|
||||
@Override
|
||||
void putAll(Map<? extends String, ?> t);
|
||||
|
||||
/**
|
||||
* Return the size of the map.
|
||||
*/
|
||||
@Override
|
||||
int size();
|
||||
|
||||
/**
|
||||
* Return the values from this map.
|
||||
*/
|
||||
@Override
|
||||
Collection<Object> values();
|
||||
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ public final class TxScope {
|
||||
/**
|
||||
* Describes this TxScope instance.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TxScope[" + type + "] readOnly[" + readOnly + "] isolation[" + isolation
|
||||
+ "] serverName[" + serverName + "] rollbackFor[" + rollbackFor + "] noRollbackFor[" + noRollbackFor + "]";
|
||||
|
||||
@@ -51,6 +51,7 @@ public class ValuePair {
|
||||
this.oldValue = oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return newValue + "," + oldValue;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Transactional annotations.
|
||||
*/
|
||||
package io.ebean.annotation;
|
||||
@@ -32,6 +32,7 @@ public final class CallStack implements Serializable {
|
||||
this.pathHash = enc(pathHash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hc = 0;
|
||||
for (StackTraceElement aCallStack : callStack) {
|
||||
@@ -40,6 +41,7 @@ public final class CallStack implements Serializable {
|
||||
return hc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
@@ -79,6 +81,7 @@ public final class CallStack implements Serializable {
|
||||
return pathHash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return zeroHash + ":" + pathHash + ":" + callStack[0];
|
||||
}
|
||||
|
||||
@@ -859,7 +859,7 @@ public final class EntityBeanIntercept implements Serializable {
|
||||
loadedProps[propertyIndex] = true;
|
||||
}
|
||||
|
||||
private final void preGetterCallback() {
|
||||
private void preGetterCallback() {
|
||||
if (preGetterCallback != null) {
|
||||
preGetterCallback.preGetterTrigger();
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ public final class NodeUsageCollector {
|
||||
return loadProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return node + " read:" + used + " modified:" + modified;
|
||||
}
|
||||
|
||||
@@ -63,16 +63,19 @@ public final class ObjectGraphNode implements Serializable {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "origin:" + originQueryPoint + " path[" + path + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hc = 92821 * originQueryPoint.hashCode();
|
||||
hc = 92821 * hc + (path == null ? 0 : path.hashCode());
|
||||
return hc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
|
||||
@@ -57,10 +57,12 @@ public final class ObjectGraphOrigin implements Serializable {
|
||||
return callStack.getFirstStackTraceElement().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "key[" + key + "] type[" + beanType + "] " + callStack.getFirstStackTraceElement() + " ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hc = 92821 * callStack.hashCode();
|
||||
hc = 92821 * hc + beanType.hashCode();
|
||||
@@ -68,6 +70,7 @@ public final class ObjectGraphOrigin implements Serializable {
|
||||
return hc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
|
||||
@@ -39,6 +39,7 @@ public class ServerCacheStatistics {
|
||||
|
||||
protected long evictByLRU;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
//noinspection StringBufferReplaceableByString
|
||||
StringBuilder sb = new StringBuilder(80);
|
||||
|
||||
@@ -68,18 +68,22 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
|
||||
this.readOnly = ownerBean._ebean_getIntercept().isReadOnly();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityBean getOwnerBean() {
|
||||
return ownerBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertyName() {
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<?> getFilterMany() {
|
||||
return filterMany;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilterMany(ExpressionList<?> filterMany) {
|
||||
this.filterMany = filterMany;
|
||||
}
|
||||
@@ -104,20 +108,24 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
|
||||
checkEmptyLazyLoad();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegisteredWithLoadContext() {
|
||||
return registeredWithLoadContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoader(BeanCollectionLoader loader) {
|
||||
this.registeredWithLoadContext = true;
|
||||
this.loader = loader;
|
||||
this.ebeanServerName = loader.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
return readOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
this.readOnly = readOnly;
|
||||
}
|
||||
@@ -136,6 +144,7 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
|
||||
/**
|
||||
* set modifyListening to be on or off.
|
||||
*/
|
||||
@Override
|
||||
public void setModifyListening(ModifyListenMode mode) {
|
||||
|
||||
this.modifyListenMode = mode;
|
||||
@@ -162,24 +171,28 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
|
||||
return modifyHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyAddition(E bean) {
|
||||
if (modifyAddListening) {
|
||||
getModifyHolder().modifyAddition(bean);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyRemoval(Object bean) {
|
||||
if (modifyRemoveListening) {
|
||||
getModifyHolder().modifyRemoval(bean);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyReset() {
|
||||
if (modifyHolder != null) {
|
||||
modifyHolder.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<E> getModifyAdditions() {
|
||||
if (modifyHolder == null) {
|
||||
return null;
|
||||
@@ -188,6 +201,7 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<E> getModifyRemovals() {
|
||||
if (modifyHolder == null) {
|
||||
return null;
|
||||
|
||||
@@ -59,6 +59,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
return list == null || (list.isEmpty() && !holdsModifications());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addEntityBean(EntityBean bean) {
|
||||
list.add((E) bean);
|
||||
@@ -73,6 +74,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
list.addAll((Collection<? extends E>) other.getActualDetails());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void internalAdd(Object bean) {
|
||||
if (list == null) {
|
||||
@@ -102,6 +104,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEmptyLazyLoad() {
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
@@ -153,6 +156,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<E> getActualDetails() {
|
||||
return list;
|
||||
}
|
||||
@@ -165,6 +169,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
/**
|
||||
* Return true if the underlying list is populated.
|
||||
*/
|
||||
@Override
|
||||
public boolean isPopulated() {
|
||||
return list != null;
|
||||
}
|
||||
@@ -173,10 +178,12 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
* Return true if this is a reference (lazy loading) bean collection. This is
|
||||
* the same as !isPopulated();
|
||||
*/
|
||||
@Override
|
||||
public boolean isReference() {
|
||||
return list == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(50);
|
||||
sb.append("BeanList ");
|
||||
@@ -201,11 +208,13 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
* test.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
init();
|
||||
return list.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
init();
|
||||
return list.hashCode();
|
||||
@@ -219,6 +228,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
// proxy method for List
|
||||
// -----------------------------------------------------//
|
||||
|
||||
@Override
|
||||
public void add(int index, E element) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -233,6 +243,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
add(bean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E o) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -247,6 +258,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
return list.add(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> c) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -257,6 +269,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
return list.addAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends E> c) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -267,6 +280,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
return list.addAll(index, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
checkReadOnly();
|
||||
// TODO: when clear() and not initialised could be more clever
|
||||
@@ -280,31 +294,37 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
list.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
init();
|
||||
return list.contains(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
init();
|
||||
return list.containsAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(int index) {
|
||||
init();
|
||||
return list.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
init();
|
||||
return list.indexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
init();
|
||||
return list.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
init();
|
||||
if (isReadOnly()) {
|
||||
@@ -317,11 +337,13 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
return list.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
init();
|
||||
return list.lastIndexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator() {
|
||||
init();
|
||||
if (isReadOnly()) {
|
||||
@@ -334,6 +356,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
return list.listIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator(int index) {
|
||||
init();
|
||||
if (isReadOnly()) {
|
||||
@@ -353,6 +376,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public E remove(int index) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -364,6 +388,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
return list.remove(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -377,6 +402,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
return list.remove(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> beans) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -394,6 +420,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
return list.removeAll(beans);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> retainBeans) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -414,6 +441,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
return list.retainAll(retainBeans);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E set(int index, E element) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -426,11 +454,13 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
return list.set(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
init();
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> subList(int fromIndex, int toIndex) {
|
||||
init();
|
||||
if (isReadOnly()) {
|
||||
@@ -442,11 +472,13 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
return list.subList(fromIndex, toIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
init();
|
||||
return list.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a) {
|
||||
init();
|
||||
//noinspection SuspiciousToArrayCall
|
||||
@@ -463,38 +495,47 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(E o) {
|
||||
throw new IllegalStateException("This collection is in ReadOnly mode");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new IllegalStateException("This collection is in ReadOnly mode");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(E o) {
|
||||
throw new IllegalStateException("This collection is in ReadOnly mode");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return i.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPrevious() {
|
||||
return i.hasPrevious();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E next() {
|
||||
return i.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextIndex() {
|
||||
return i.nextIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E previous() {
|
||||
return i.previous();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int previousIndex() {
|
||||
return i.previousIndex();
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
|
||||
this.map = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSkipSave() {
|
||||
return map == null || (map.isEmpty() && !holdsModifications());
|
||||
}
|
||||
@@ -86,6 +87,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
|
||||
throw new RuntimeException("Not allowed for map");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void internalAdd(Object bean) {
|
||||
throw new RuntimeException("Not allowed for map");
|
||||
}
|
||||
@@ -94,6 +96,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
|
||||
* Return true if the underlying map has been populated. Returns false if it
|
||||
* has a deferred fetch pending.
|
||||
*/
|
||||
@Override
|
||||
public boolean isPopulated() {
|
||||
return map != null;
|
||||
}
|
||||
@@ -102,10 +105,12 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
|
||||
* Return true if this is a reference (lazy loading) bean collection. This is
|
||||
* the same as !isPopulated();
|
||||
*/
|
||||
@Override
|
||||
public boolean isReference() {
|
||||
return map == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEmptyLazyLoad() {
|
||||
if (map == null) {
|
||||
map = new LinkedHashMap<>();
|
||||
@@ -153,6 +158,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
|
||||
/**
|
||||
* Returns the collection of beans (map values).
|
||||
*/
|
||||
@Override
|
||||
public Collection<E> getActualDetails() {
|
||||
return map.values();
|
||||
}
|
||||
@@ -164,10 +170,12 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
|
||||
* they don't need to be set twice).
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public Collection<?> getActualEntries() {
|
||||
return map.entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(50);
|
||||
sb.append("BeanMap ");
|
||||
@@ -187,16 +195,19 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
|
||||
/**
|
||||
* Equal if obj is a Map and equal in a Map sense.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
init();
|
||||
return map.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
init();
|
||||
return map.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
checkReadOnly();
|
||||
initClear();
|
||||
@@ -209,16 +220,19 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
|
||||
map.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
init();
|
||||
return map.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
init();
|
||||
return map.containsValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public Set<Entry<K, E>> entrySet() {
|
||||
init();
|
||||
@@ -232,16 +246,19 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
|
||||
return map.entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(Object key) {
|
||||
init();
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
init();
|
||||
return map.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
init();
|
||||
if (isReadOnly()) {
|
||||
@@ -251,6 +268,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
|
||||
return map.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E put(K key, E value) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -265,6 +283,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
|
||||
return map.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends E> puts) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -290,6 +309,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
|
||||
throw new IllegalStateException("Method not allowed on Map. Please use List instead.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public E remove(Object key) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -301,11 +321,13 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
|
||||
return map.remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
init();
|
||||
return map.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<E> values() {
|
||||
init();
|
||||
if (isReadOnly()) {
|
||||
|
||||
@@ -48,10 +48,12 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
this.set = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSkipSave() {
|
||||
return set == null || (set.isEmpty() && !holdsModifications());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addEntityBean(EntityBean bean) {
|
||||
set.add((E) bean);
|
||||
@@ -73,6 +75,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void internalAdd(Object bean) {
|
||||
if (set == null) {
|
||||
@@ -86,6 +89,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
/**
|
||||
* Returns true if the underlying set has its data.
|
||||
*/
|
||||
@Override
|
||||
public boolean isPopulated() {
|
||||
return set != null;
|
||||
}
|
||||
@@ -94,10 +98,12 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
* Return true if this is a reference (lazy loading) bean collection. This is
|
||||
* the same as !isPopulated();
|
||||
*/
|
||||
@Override
|
||||
public boolean isReference() {
|
||||
return set == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEmptyLazyLoad() {
|
||||
if (set == null) {
|
||||
set = new LinkedHashSet<>();
|
||||
@@ -142,6 +148,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<E> getActualDetails() {
|
||||
return set;
|
||||
}
|
||||
@@ -151,6 +158,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(50);
|
||||
sb.append("BeanSet ");
|
||||
@@ -170,11 +178,13 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
/**
|
||||
* Equal if obj is a Set and equal in a Set sense.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
init();
|
||||
return set.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
init();
|
||||
return set.hashCode();
|
||||
@@ -196,6 +206,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
// proxy method for map
|
||||
// -----------------------------------------------------//
|
||||
|
||||
@Override
|
||||
public boolean add(E o) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -210,6 +221,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
return set.add(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> addCollection) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -227,6 +239,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
return set.addAll(addCollection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
checkReadOnly();
|
||||
initClear();
|
||||
@@ -238,21 +251,25 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
set.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
init();
|
||||
return set.contains(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
init();
|
||||
return set.containsAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
init();
|
||||
return set.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
init();
|
||||
if (isReadOnly()) {
|
||||
@@ -264,6 +281,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
return set.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -277,6 +295,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
return set.remove(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> beans) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -293,6 +312,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
return set.removeAll(beans);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> beans) {
|
||||
checkReadOnly();
|
||||
init();
|
||||
@@ -313,16 +333,19 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
return set.retainAll(beans);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
init();
|
||||
return set.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
init();
|
||||
return set.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a) {
|
||||
init();
|
||||
//noinspection SuspiciousToArrayCall
|
||||
@@ -339,14 +362,17 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
this.it = it;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return it.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E next() {
|
||||
return it.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new IllegalStateException("This collection is in ReadOnly mode");
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ class ModifyCollection<E> implements Collection<E> {
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E o) {
|
||||
if (c.add(o)) {
|
||||
owner.modifyAddition(o);
|
||||
@@ -38,6 +39,7 @@ class ModifyCollection<E> implements Collection<E> {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> collection) {
|
||||
boolean changed = false;
|
||||
for (E o : collection) {
|
||||
|
||||
@@ -31,15 +31,18 @@ class ModifyIterator<E> implements Iterator<E> {
|
||||
this.it = it;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return it.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E next() {
|
||||
last = it.next();
|
||||
return last;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
owner.modifyRemoval(last);
|
||||
it.remove();
|
||||
|
||||
@@ -33,11 +33,13 @@ class ModifyList<E> extends ModifyCollection<E> implements List<E> {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, E element) {
|
||||
list.add(index, element);
|
||||
owner.modifyAddition(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends E> addCollection) {
|
||||
if (list.addAll(index, addCollection)) {
|
||||
for (E bean : addCollection) {
|
||||
@@ -48,32 +50,39 @@ class ModifyList<E> extends ModifyCollection<E> implements List<E> {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(int index) {
|
||||
return list.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
return list.indexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
return list.lastIndexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator() {
|
||||
return new ModifyListIterator<>(owner, list.listIterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator(int index) {
|
||||
return new ModifyListIterator<>(owner, list.listIterator(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public E remove(int index) {
|
||||
E o = list.remove(index);
|
||||
owner.modifyRemoval(o);
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E set(int index, E element) {
|
||||
E o = list.set(index, element);
|
||||
owner.modifyAddition(element);
|
||||
@@ -81,6 +90,7 @@ class ModifyList<E> extends ModifyCollection<E> implements List<E> {
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> subList(int fromIndex, int toIndex) {
|
||||
return new ModifyList<>(owner, list.subList(fromIndex, toIndex));
|
||||
}
|
||||
|
||||
@@ -28,44 +28,53 @@ class ModifyListIterator<E> implements ListIterator<E> {
|
||||
this.it = it;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(E bean) {
|
||||
owner.modifyAddition(bean);
|
||||
last = null;
|
||||
it.add(bean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return it.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPrevious() {
|
||||
return it.hasPrevious();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E next() {
|
||||
last = it.next();
|
||||
return last;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextIndex() {
|
||||
return it.nextIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E previous() {
|
||||
last = it.previous();
|
||||
return last;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int previousIndex() {
|
||||
return it.previousIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
owner.modifyRemoval(last);
|
||||
last = null;
|
||||
it.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(E o) {
|
||||
if (last != null) {
|
||||
owner.modifyRemoval(last);
|
||||
|
||||
@@ -76,10 +76,12 @@ public abstract class AbstractNamingConvention implements NamingConvention {
|
||||
this(DEFAULT_SEQ_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDatabasePlatform(DatabasePlatform databasePlatform) {
|
||||
this.databasePlatform = databasePlatform;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSequenceName(String tableName, String pkColumn) {
|
||||
String s = sequenceFormat.replace("{table}", tableName);
|
||||
if (pkColumn == null) {
|
||||
@@ -152,6 +154,7 @@ public abstract class AbstractNamingConvention implements NamingConvention {
|
||||
* column names.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseForeignKeyPrefix() {
|
||||
return useForeignKeyPrefix;
|
||||
}
|
||||
@@ -180,6 +183,7 @@ public abstract class AbstractNamingConvention implements NamingConvention {
|
||||
* @see #getTableNameFromAnnotation(Class)
|
||||
* @see #getTableNameByConvention(Class)
|
||||
*/
|
||||
@Override
|
||||
public TableName getTableName(Class<?> beanClass) {
|
||||
|
||||
TableName tableName = getTableNameFromAnnotation(beanClass);
|
||||
@@ -221,6 +225,7 @@ public abstract class AbstractNamingConvention implements NamingConvention {
|
||||
return supCls.getAnnotation(annotation) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable) {
|
||||
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.ebean.config;
|
||||
/**
|
||||
* Provides the Tenant Id for the current request based on the current user.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface CurrentTenantProvider {
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.ebean.config;
|
||||
/**
|
||||
* Provides the current user in order to support 'Who created', 'Who modified' and other audit features.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface CurrentUserProvider {
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,21 @@ public class DocStoreConfig {
|
||||
*/
|
||||
protected String url;
|
||||
|
||||
/**
|
||||
* Credential that be used for authentication to document store.
|
||||
*/
|
||||
protected String username;
|
||||
|
||||
/**
|
||||
* Password credential that be used for authentication to document store.
|
||||
*/
|
||||
protected String password;
|
||||
|
||||
/**
|
||||
* Set to true such that the client allows connections to invalid/self signed SSL certificates.
|
||||
*/
|
||||
protected boolean allowAllCertificates;
|
||||
|
||||
/**
|
||||
* The default mode used by indexes.
|
||||
*/
|
||||
@@ -87,6 +102,34 @@ public class DocStoreConfig {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the user credential for connecting to the document store.
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user credential for connecting to the document store.
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the password credential for connecting to the document store.
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the password credential for connecting to the document store.
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the URL to the Document store server.
|
||||
* <p>
|
||||
@@ -152,6 +195,20 @@ public class DocStoreConfig {
|
||||
this.create = create;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the client allows connections to invalid/self signed SSL certificates.
|
||||
*/
|
||||
public boolean isAllowAllCertificates() {
|
||||
return allowAllCertificates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to true such that the client allows connections to invalid/self signed SSL certificates.
|
||||
*/
|
||||
public void setAllowAllCertificates(boolean allowAllCertificates) {
|
||||
this.allowAllCertificates = allowAllCertificates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default batch size to use for calls to the Bulk API.
|
||||
*/
|
||||
@@ -248,11 +305,14 @@ public class DocStoreConfig {
|
||||
|
||||
active = properties.getBoolean("docstore.active", active);
|
||||
url = properties.get("docstore.url", url);
|
||||
username = properties.get("docstore.username", url);
|
||||
password = properties.get("docstore.password", url);
|
||||
persist = properties.getEnum(DocStoreMode.class, "docstore.persist", persist);
|
||||
bulkBatchSize = properties.getInt("docstore.bulkBatchSize", bulkBatchSize);
|
||||
generateMapping = properties.getBoolean("docstore.generateMapping", generateMapping);
|
||||
dropCreate = properties.getBoolean("docstore.dropCreate", dropCreate);
|
||||
create = properties.getBoolean("docstore.create", create);
|
||||
allowAllCertificates = properties.getBoolean("docstore.allowAllCertificates", allowAllCertificates);
|
||||
mappingPath = properties.get("docstore.mappingPath", mappingPath);
|
||||
mappingSuffix = properties.get("docstore.mappingSuffix", mappingSuffix);
|
||||
pathToResources = properties.get("docstore.pathToResources", pathToResources);
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.ebean.config;
|
||||
/**
|
||||
* Programmatically define which database columns are encrypted.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface EncryptDeployManager {
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ package io.ebean.config;
|
||||
* For simple cases this often represent a simple String key but depending on
|
||||
* the encryption method this could contain other details.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface EncryptKey {
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.ebean.config;
|
||||
/**
|
||||
* Determine keys used for encryption and decryption.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface EncryptKeyManager {
|
||||
|
||||
/**
|
||||
@@ -11,7 +12,7 @@ public interface EncryptKeyManager {
|
||||
* This gives the EncryptKeyManager the opportunity to get keys etc.
|
||||
* </p>
|
||||
*/
|
||||
void initialise();
|
||||
default void initialise() {};
|
||||
|
||||
/**
|
||||
* Return the key used to encrypt and decrypt a property mapping to the given
|
||||
|
||||
@@ -29,15 +29,18 @@ public class MatchingNamingConvention extends AbstractNamingConvention {
|
||||
super(sequenceFormat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnFromProperty(Class<?> beanClass, String propertyName) {
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableName getTableNameByConvention(Class<?> beanClass) {
|
||||
|
||||
return new TableName(getCatalog(), getSchema(), beanClass.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertyFromColumn(Class<?> beanClass, String dbColumnName) {
|
||||
return dbColumnName;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public final class PropertyMap implements Serializable {
|
||||
return (disable == null || !disable.equalsIgnoreCase("true"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return map.toString();
|
||||
}
|
||||
|
||||
@@ -22,16 +22,9 @@ package io.ebean.config;
|
||||
* to implement this interface rather than let Ebean automatically support that
|
||||
* type via reflection.
|
||||
* </p>
|
||||
* <p>
|
||||
* If you want to support a Compound Type rather than a Scalar Type refer to
|
||||
* {@link CompoundType}.
|
||||
* </p>
|
||||
*
|
||||
* @param <B> The value object type.
|
||||
* @param <S> The scalar object type that is used to persist the value object.
|
||||
* @author rbygrave
|
||||
* @see CompoundType
|
||||
* @see CompoundTypeProperty
|
||||
*/
|
||||
public interface ScalarTypeConverter<B, S> {
|
||||
|
||||
|
||||
@@ -378,6 +378,8 @@ public class ServerConfig {
|
||||
|
||||
private Encryptor encryptor;
|
||||
|
||||
private boolean dbOffline;
|
||||
|
||||
private DbEncrypt dbEncrypt;
|
||||
|
||||
private ServerCachePlugin serverCachePlugin;
|
||||
@@ -1623,6 +1625,24 @@ public class ServerConfig {
|
||||
this.encryptor = encryptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the EbeanServer instance should be created in offline mode.
|
||||
*/
|
||||
public boolean isDbOffline() {
|
||||
return dbOffline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to true if the EbeanServer instance should be created in offline mode.
|
||||
* <p>
|
||||
* Typically used to create an EbeanServer instance for DDL Migration generation
|
||||
* without requiring a real DataSource / Database to connect to.
|
||||
* </p>
|
||||
*/
|
||||
public void setDbOffline(boolean dbOffline) {
|
||||
this.dbOffline = dbOffline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the DbEncrypt used to encrypt and decrypt properties.
|
||||
* <p>
|
||||
@@ -2507,6 +2527,7 @@ public class ServerConfig {
|
||||
encryptDeployManager = createInstance(p, EncryptDeployManager.class, "encryptDeployManager", encryptDeployManager);
|
||||
encryptor = createInstance(p, Encryptor.class, "encryptor", encryptor);
|
||||
dbEncrypt = createInstance(p, DbEncrypt.class, "dbEncrypt", dbEncrypt);
|
||||
dbOffline = p.getBoolean("dbOffline", dbOffline);
|
||||
serverCachePlugin = createInstance(p, ServerCachePlugin.class, "serverCachePlugin", serverCachePlugin);
|
||||
|
||||
if (packages != null) {
|
||||
|
||||
@@ -69,6 +69,7 @@ public final class TableName {
|
||||
return new TableName(qualifiedTableName).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getQualifiedName();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import javax.sql.DataSource;
|
||||
/**
|
||||
* For multi-tenancy via DB supply the DataSource given the tenantId.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface TenantDataSourceProvider {
|
||||
|
||||
/**
|
||||
@@ -15,5 +16,5 @@ public interface TenantDataSourceProvider {
|
||||
/**
|
||||
* Shutdown all the DataSources.
|
||||
*/
|
||||
void shutdown(boolean deregisterDriver);
|
||||
default void shutdown(boolean deregisterDriver) {};
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.ebean.config;
|
||||
/**
|
||||
* For multi-tenancy via DB SCHEMA supply the schema given the tenantId.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface TenantSchemaProvider {
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,6 +43,7 @@ public class UnderscoreNamingConvention extends AbstractNamingConvention {
|
||||
* @param beanClass the bean class
|
||||
* @return the table name from class
|
||||
*/
|
||||
@Override
|
||||
public TableName getTableNameByConvention(Class<?> beanClass) {
|
||||
|
||||
return new TableName(getCatalog(), getSchema(), toUnderscoreFromCamel(beanClass.getSimpleName()));
|
||||
@@ -53,6 +54,7 @@ public class UnderscoreNamingConvention extends AbstractNamingConvention {
|
||||
*
|
||||
* @return the column from property
|
||||
*/
|
||||
@Override
|
||||
public String getColumnFromProperty(Class<?> beanClass, String propertyName) {
|
||||
|
||||
return toUnderscoreFromCamel(propertyName);
|
||||
@@ -65,6 +67,7 @@ public class UnderscoreNamingConvention extends AbstractNamingConvention {
|
||||
* @param dbColumnName the db column name
|
||||
* @return the property from column
|
||||
*/
|
||||
@Override
|
||||
public String getPropertyFromColumn(Class<?> beanClass, String dbColumnName) {
|
||||
return toCamelFromUnderscore(dbColumnName);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ public abstract class AbstractDbEncrypt implements DbEncrypt {
|
||||
* Null is returned if DB encryption of the type is not supported.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public DbEncryptFunction getDbEncryptFunction(int jdbcType) {
|
||||
switch (jdbcType) {
|
||||
case Types.VARCHAR:
|
||||
@@ -64,6 +65,7 @@ public abstract class AbstractDbEncrypt implements DbEncrypt {
|
||||
/**
|
||||
* Return the DB stored type for encrypted properties.
|
||||
*/
|
||||
@Override
|
||||
public int getEncryptDbType() {
|
||||
return Types.VARBINARY;
|
||||
}
|
||||
@@ -71,6 +73,7 @@ public abstract class AbstractDbEncrypt implements DbEncrypt {
|
||||
/**
|
||||
* Generally encrypt function binding the data before the key (except h2).
|
||||
*/
|
||||
@Override
|
||||
public boolean isBindEncryptDataFirst() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.ebean.config.dbplatform;
|
||||
|
||||
import io.ebean.config.ServerConfig;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -13,6 +13,7 @@ public class DbPlatformTypeMapping {
|
||||
private static DbPlatformTypeLookup lookup = new DbPlatformTypeLookup();
|
||||
|
||||
private static final DbPlatformType UUID_NATIVE = new DbPlatformType("uuid", false);
|
||||
@SuppressWarnings("unused")
|
||||
private static final DbPlatformType UUID_PLACEHOLDER = new DbPlatformType("uuidPlaceholder");
|
||||
private static final DbPlatformType JSON_CLOB_PLACEHOLDER = new DbPlatformType("jsonClobPlaceholder");
|
||||
private static final DbPlatformType JSON_BLOB_PLACEHOLDER = new DbPlatformType("jsonBlobPlaceholder");
|
||||
@@ -25,7 +26,7 @@ public class DbPlatformTypeMapping {
|
||||
private static final DbPlatformType MULTILINESTRING = new DbPlatformType("multilinestring");
|
||||
private static final DbPlatformType MULTIPOLYGON = new DbPlatformType("multipolygon");
|
||||
|
||||
private final Map<DbType, DbPlatformType> typeMap = new HashMap<>();
|
||||
private final Map<DbType, DbPlatformType> typeMap = new EnumMap<>(DbType.class);
|
||||
|
||||
/**
|
||||
* Return the DbTypeMap with standard (not platform specific) types.
|
||||
|
||||
@@ -15,6 +15,7 @@ public class LimitOffsetSqlLimiter implements SqlLimiter {
|
||||
*/
|
||||
private static final String OFFSET = "offset";
|
||||
|
||||
@Override
|
||||
public SqlLimitResponse limit(SqlLimitRequest request) {
|
||||
|
||||
String dbSql = request.getDbSql();
|
||||
|
||||
@@ -28,6 +28,7 @@ public class RowNumberSqlLimiter implements SqlLimiter {
|
||||
this("as limitresult");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlLimitResponse limit(SqlLimitRequest request) {
|
||||
|
||||
String dbSql = request.getDbSql();
|
||||
@@ -38,7 +39,7 @@ public class RowNumberSqlLimiter implements SqlLimiter {
|
||||
|
||||
int lastRow = request.getMaxRows();
|
||||
if (lastRow > 0) {
|
||||
lastRow = lastRow + firstRow;
|
||||
lastRow += firstRow;
|
||||
}
|
||||
|
||||
sb.append("select * from ( ");
|
||||
|
||||
@@ -25,6 +25,7 @@ public class RownumSqlLimiter implements SqlLimiter {
|
||||
this.useFirstRowsHint = useFirstRowsHint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlLimitResponse limit(SqlLimitRequest request) {
|
||||
|
||||
// select *
|
||||
@@ -43,7 +44,7 @@ public class RownumSqlLimiter implements SqlLimiter {
|
||||
|
||||
int lastRow = request.getMaxRows();
|
||||
if (lastRow > 0) {
|
||||
lastRow = lastRow + firstRow;
|
||||
lastRow += firstRow;
|
||||
}
|
||||
|
||||
sb.append("select * from ( ");
|
||||
|
||||
@@ -60,6 +60,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
||||
/**
|
||||
* Returns the sequence name.
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return seqName;
|
||||
}
|
||||
@@ -67,6 +68,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
||||
/**
|
||||
* Returns true.
|
||||
*/
|
||||
@Override
|
||||
public boolean isDbSequence() {
|
||||
return true;
|
||||
}
|
||||
@@ -78,6 +80,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
||||
* beans Ebean can call this to ensure .
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void preAllocateIds(int allocateSize) {
|
||||
if (batchSize > 1 && allocateSize > batchSize) {
|
||||
// only bother if allocateSize is bigger than
|
||||
@@ -106,6 +109,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
||||
* If a Transaction has been passed in use the Connection from it.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public Object nextId(Transaction t) {
|
||||
synchronized (monitor) {
|
||||
|
||||
|
||||
@@ -36,18 +36,22 @@ public class SimpleSequenceIdGenerator implements PlatformIdGenerator {
|
||||
this.seqName = seqName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return seqName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDbSequence() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preAllocateIds(int batchSize) {
|
||||
// just ignore this
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object nextId(Transaction t) {
|
||||
|
||||
boolean useTxnConnection = t != null;
|
||||
|
||||
@@ -22,6 +22,7 @@ public class DB2SequenceIdGenerator extends SequenceIdGenerator {
|
||||
this.unionBaseSql = " union " + baseSql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSql(int batchSize) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* DB2 specific support.
|
||||
*/
|
||||
package io.ebean.config.dbplatform.db2;
|
||||
@@ -18,17 +18,20 @@ public class H2DbEncrypt extends AbstractDbEncrypt {
|
||||
/**
|
||||
* For H2 encrypt function returns false binding the key before the data.
|
||||
*/
|
||||
@Override
|
||||
public boolean isBindEncryptDataFirst() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class H2VarcharFunction implements DbEncryptFunction {
|
||||
|
||||
@Override
|
||||
public String getDecryptSql(String columnWithTableAlias) {
|
||||
// Hmmm, this looks ugly - checking with H2 Database folks.
|
||||
return "TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), " + columnWithTableAlias + ")))";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptBindSql() {
|
||||
return "ENCRYPT('AES', STRINGTOUTF8(?), STRINGTOUTF8(?))";
|
||||
}
|
||||
@@ -37,10 +40,12 @@ public class H2DbEncrypt extends AbstractDbEncrypt {
|
||||
|
||||
private static class H2DateFunction implements DbEncryptFunction {
|
||||
|
||||
@Override
|
||||
public String getDecryptSql(String columnWithTableAlias) {
|
||||
return "PARSEDATETIME(TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), " + columnWithTableAlias + "))),'yyyyMMdd')";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptBindSql() {
|
||||
return "ENCRYPT('AES', STRINGTOUTF8(?), STRINGTOUTF8(FORMATDATETIME(?,'yyyyMMdd')))";
|
||||
}
|
||||
|
||||
@@ -100,14 +100,11 @@ public class H2HistoryTrigger implements Trigger {
|
||||
*/
|
||||
private void insertIntoHistory(Connection connection, Object[] oldRow) throws SQLException {
|
||||
|
||||
PreparedStatement stmt = connection.prepareStatement(insertHistorySql);
|
||||
try {
|
||||
try (PreparedStatement stmt = connection.prepareStatement(insertHistorySql)) {
|
||||
for (int i = 0; i < oldRow.length; i++) {
|
||||
stmt.setObject(i + 1, oldRow[i]);
|
||||
}
|
||||
stmt.executeUpdate();
|
||||
} finally {
|
||||
stmt.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ public class H2SequenceIdGenerator extends SequenceIdGenerator {
|
||||
this.unionBaseSql = " union " + baseSql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSql(int batchSize) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* H2 specific support.
|
||||
*/
|
||||
package io.ebean.config.dbplatform.h2;
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Hsqldb specific support.
|
||||
*/
|
||||
package io.ebean.config.dbplatform.hsqldb;
|
||||
@@ -17,10 +17,12 @@ public class MySqlDbEncrypt extends AbstractDbEncrypt {
|
||||
|
||||
private static class MyVarcharFunction implements DbEncryptFunction {
|
||||
|
||||
@Override
|
||||
public String getDecryptSql(String columnWithTableAlias) {
|
||||
return "CONVERT(AES_DECRYPT(" + columnWithTableAlias + ",?) USING UTF8)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptBindSql() {
|
||||
return "AES_ENCRYPT(?,?)";
|
||||
}
|
||||
@@ -28,10 +30,12 @@ public class MySqlDbEncrypt extends AbstractDbEncrypt {
|
||||
|
||||
private static class MyDateFunction implements DbEncryptFunction {
|
||||
|
||||
@Override
|
||||
public String getDecryptSql(String columnWithTableAlias) {
|
||||
return "STR_TO_DATE(AES_DECRYPT(" + columnWithTableAlias + ",?),'%Y%d%m')";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptBindSql() {
|
||||
return "AES_ENCRYPT(DATE_FORMAT(?,'%Y%d%m'),?)";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* MySql specific support.
|
||||
*/
|
||||
package io.ebean.config.dbplatform.mysql;
|
||||
@@ -78,10 +78,12 @@ public class OracleDbEncrypt extends AbstractDbEncrypt {
|
||||
this.decryptfunction = decryptfunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDecryptSql(String columnWithTableAlias) {
|
||||
return decryptfunction + "(" + columnWithTableAlias + ",?)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptBindSql() {
|
||||
return encryptfunction + "(?,?)";
|
||||
}
|
||||
@@ -101,10 +103,12 @@ public class OracleDbEncrypt extends AbstractDbEncrypt {
|
||||
this.decryptfunction = decryptfunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDecryptSql(String columnWithTableAlias) {
|
||||
return "to_date(" + decryptfunction + "(" + columnWithTableAlias + ",?),'YYYYMMDD')";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptBindSql() {
|
||||
return encryptfunction + "(to_char(?,'YYYYMMDD'),?)";
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public class OracleSequenceIdGenerator extends SequenceIdGenerator {
|
||||
this.baseSql = "select " + seqName + ".nextval, a from (select level as a FROM dual CONNECT BY level <= ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSql(int batchSize) {
|
||||
return baseSql + batchSize + ")";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Oracle specific support.
|
||||
*/
|
||||
package io.ebean.config.dbplatform.oracle;
|
||||
@@ -15,10 +15,12 @@ public class PostgresDbEncrypt extends AbstractDbEncrypt {
|
||||
|
||||
private static class PgVarcharFunction implements DbEncryptFunction {
|
||||
|
||||
@Override
|
||||
public String getDecryptSql(String columnWithTableAlias) {
|
||||
return "pgp_sym_decrypt(" + columnWithTableAlias + ",?)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptBindSql() {
|
||||
return "pgp_sym_encrypt(?,?)";
|
||||
}
|
||||
@@ -26,10 +28,12 @@ public class PostgresDbEncrypt extends AbstractDbEncrypt {
|
||||
|
||||
private static class PgDateFunction implements DbEncryptFunction {
|
||||
|
||||
@Override
|
||||
public String getDecryptSql(String columnWithTableAlias) {
|
||||
return "to_date(pgp_sym_decrypt(" + columnWithTableAlias + ",?),'YYYYMMDD')";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptBindSql() {
|
||||
return "pgp_sym_encrypt(to_char(?::date,'YYYYMMDD'),?)";
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ public class PostgresPlatform extends DatabasePlatform {
|
||||
dbTypeMap.put(DbType.LONGVARCHAR, dbTypeText);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addGeoTypes(int srid) {
|
||||
dbTypeMap.put(DbType.POINT, geoType("point", srid));
|
||||
dbTypeMap.put(DbType.POLYGON, geoType("polygon", srid));
|
||||
@@ -86,6 +87,7 @@ public class PostgresPlatform extends DatabasePlatform {
|
||||
/**
|
||||
* Return a DdlHandler instance for generating DDL for the specific platform.
|
||||
*/
|
||||
@Override
|
||||
public DdlHandler createDdlHandler(ServerConfig serverConfig) {
|
||||
return this.platformDdl.createDdlHandler(serverConfig);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public class PostgresSequenceIdGenerator extends SequenceIdGenerator {
|
||||
this.baseSql = "select nextval('" + seqName + "'), s.generate_series from (select generate_series from generate_series(1,";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSql(int batchSize) {
|
||||
return baseSql + batchSize + ") ) as s";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Postgres specific support.
|
||||
*/
|
||||
package io.ebean.config.dbplatform.postgres;
|
||||
@@ -9,6 +9,7 @@ import io.ebean.config.dbplatform.SqlLimiter;
|
||||
*/
|
||||
public class SqlAnywhereLimiter implements SqlLimiter {
|
||||
|
||||
@Override
|
||||
public SqlLimitResponse limit(SqlLimitRequest request) {
|
||||
|
||||
String dbSql = request.getDbSql();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* SqlAnywhere specific support.
|
||||
*/
|
||||
package io.ebean.config.dbplatform.sqlanywhere;
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Sqlite specific support.
|
||||
*/
|
||||
package io.ebean.config.dbplatform.sqlite;
|
||||
@@ -22,6 +22,7 @@ public class SqlServer2005SqlLimiter implements SqlLimiter {
|
||||
this("as limitresult");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlLimitResponse limit(SqlLimitRequest request) {
|
||||
|
||||
StringBuilder sb = new StringBuilder(500);
|
||||
@@ -30,7 +31,7 @@ public class SqlServer2005SqlLimiter implements SqlLimiter {
|
||||
|
||||
int lastRow = request.getMaxRows();
|
||||
if (lastRow > 0) {
|
||||
lastRow = lastRow + firstRow;
|
||||
lastRow += firstRow;
|
||||
}
|
||||
|
||||
if (firstRow < 1) {
|
||||
|
||||
@@ -8,6 +8,8 @@ import io.ebean.config.dbplatform.DbType;
|
||||
import io.ebean.config.dbplatform.IdType;
|
||||
import io.ebean.dbmigration.ddlgeneration.platform.SqlServerDdl;
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
/**
|
||||
* Microsoft SQL Server platform.
|
||||
*/
|
||||
@@ -32,6 +34,7 @@ public class SqlServerPlatform extends DatabasePlatform {
|
||||
this.openQuote = "[";
|
||||
this.closeQuote = "]";
|
||||
|
||||
booleanDbType = Types.INTEGER;
|
||||
dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("bit default 0"));
|
||||
|
||||
dbTypeMap.put(DbType.INTEGER, new DbPlatformType("integer", false));
|
||||
|
||||
@@ -12,6 +12,7 @@ public class SqlServerSqlLimiter implements SqlLimiter {
|
||||
public SqlServerSqlLimiter() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlLimitResponse limit(SqlLimitRequest request) {
|
||||
|
||||
String dbSql = request.getDbSql();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* SqlServer specific support.
|
||||
*/
|
||||
package io.ebean.config.dbplatform.sqlserver;
|
||||
@@ -263,10 +263,10 @@ public class DbMigration {
|
||||
logger.info("writing repeatable script {}", fullName);
|
||||
|
||||
File file = new File(migrationDir, fullName);
|
||||
FileWriter writer = new FileWriter(file);
|
||||
writer.write(script.getValue());
|
||||
writer.flush();
|
||||
writer.close();
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
writer.write(script.getValue());
|
||||
writer.flush();
|
||||
}
|
||||
}
|
||||
|
||||
private String repeatableMigrationName(String scriptName) {
|
||||
|
||||
@@ -233,13 +233,9 @@ public class DdlGenerator {
|
||||
protected void writeFile(String fileName, String fileContent) throws IOException {
|
||||
|
||||
File f = new File(fileName);
|
||||
|
||||
FileWriter fw = new FileWriter(f);
|
||||
try {
|
||||
try (FileWriter fw = new FileWriter(f)) {
|
||||
fw.write(fileContent);
|
||||
fw.flush();
|
||||
} finally {
|
||||
fw.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,17 +252,13 @@ public class DdlGenerator {
|
||||
protected String readContent(Reader reader) throws IOException {
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
LineNumberReader lineReader = new LineNumberReader(reader);
|
||||
try {
|
||||
try (LineNumberReader lineReader = new LineNumberReader(reader)) {
|
||||
String s;
|
||||
while ((s = lineReader.readLine()) != null) {
|
||||
buf.append(s).append("\n");
|
||||
}
|
||||
return buf.toString();
|
||||
|
||||
} finally {
|
||||
lineReader.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ public class BaseDdlBuffer implements DdlBuffer {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBuffer() {
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ public class DefaultConstraintMaxLength implements DbConstraintNaming.MaxLength
|
||||
* <p>
|
||||
* This implementation should work well apart from perhaps DB2 where the limit is 18.
|
||||
*/
|
||||
@Override
|
||||
public String maxLength(String constraintName, int count) {
|
||||
if (constraintName.length() < maxConstraintNameLength) {
|
||||
return constraintName;
|
||||
|
||||
@@ -31,6 +31,7 @@ public class HistoryTableUpdate {
|
||||
this.column = column;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return description();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package io.ebean.dbmigration.ddlgeneration.platform;
|
||||
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.util.StringHelper;
|
||||
import io.ebean.dbmigration.ddlgeneration.DdlBuffer;
|
||||
import io.ebean.dbmigration.migration.AlterColumn;
|
||||
import io.ebean.dbmigration.migration.Column;
|
||||
import io.ebeaninternal.server.lib.util.StringHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -49,12 +49,14 @@ public class MySqlDdl extends PlatformDdl {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String alterColumnNotnull(String tableName, String columnName, boolean notnull) {
|
||||
|
||||
// can't alter itself - done in alterColumnBaseAttributes()
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String alterColumnDefaultValue(String tableName, String columnName, String defaultValue) {
|
||||
|
||||
String suffix = isDropDefault(defaultValue) ? columnDropDefault : columnSetDefault + " " + defaultValue;
|
||||
@@ -63,6 +65,7 @@ public class MySqlDdl extends PlatformDdl {
|
||||
return "alter table " + tableName + " alter " + columnName + " " + suffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String alterColumnBaseAttributes(AlterColumn alter) {
|
||||
|
||||
String tableName = alter.getTableName();
|
||||
@@ -89,6 +92,7 @@ public class MySqlDdl extends PlatformDdl {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inlineTableComment(DdlBuffer apply, String tableComment) throws IOException {
|
||||
if (tableComment.length() > 1000) {
|
||||
tableComment = tableComment.substring(0, 1000);
|
||||
|
||||
@@ -64,6 +64,7 @@ public class SqlServerDdl extends PlatformDdl {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String alterColumnBaseAttributes(AlterColumn alter) {
|
||||
|
||||
String tableName = alter.getTableName();
|
||||
@@ -82,6 +83,7 @@ public class SqlServerDdl extends PlatformDdl {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String alterColumnNotnull(String tableName, String columnName, boolean notnull) {
|
||||
|
||||
// can't alter itself - done in alterColumnBaseAttributes()
|
||||
@@ -91,6 +93,7 @@ public class SqlServerDdl extends PlatformDdl {
|
||||
/**
|
||||
* Add table comment as a separate statement (from the create table statement).
|
||||
*/
|
||||
@Override
|
||||
public void addTableComment(DdlBuffer apply, String tableName, String tableComment) throws IOException {
|
||||
|
||||
// do nothing for MS SQL Server (cause it requires stored procedures etc)
|
||||
@@ -99,6 +102,7 @@ public class SqlServerDdl extends PlatformDdl {
|
||||
/**
|
||||
* Add column comment as a separate statement.
|
||||
*/
|
||||
@Override
|
||||
public void addColumnComment(DdlBuffer apply, String table, String column, String comment) throws IOException {
|
||||
|
||||
// do nothing for MS SQL Server (cause it requires stored procedures etc)
|
||||
|
||||
@@ -37,13 +37,8 @@ public class MigrationXmlReader {
|
||||
*/
|
||||
public static Migration read(File migrationFile) {
|
||||
|
||||
try {
|
||||
FileInputStream is = new FileInputStream(migrationFile);
|
||||
try {
|
||||
return read(is);
|
||||
} finally {
|
||||
is.close();
|
||||
}
|
||||
try (FileInputStream is = new FileInputStream(migrationFile)) {
|
||||
return read(is);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ public class MigrationXmlWriter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a Migration to a file as an xml document to the file.
|
||||
* Write a Migration as a standalone XML document to a file.
|
||||
*/
|
||||
public void write(Migration migration, File file) {
|
||||
|
||||
try {
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
|
||||
FileWriter writer = new FileWriter(file);
|
||||
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
|
||||
writer.write("<!DOCTYPE xml>\n");
|
||||
if (comment != null) {
|
||||
writer.write("<!-- ");
|
||||
writer.write(comment);
|
||||
@@ -43,8 +43,6 @@ public class MigrationXmlWriter {
|
||||
|
||||
marshaller.marshal(migration, writer);
|
||||
|
||||
writer.close();
|
||||
|
||||
} catch (IOException | JAXBException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ public class MIndex {
|
||||
|
||||
|
||||
private List<String> split(String columns) {
|
||||
List<String> colList = new ArrayList<>();
|
||||
String[] cols = columns.split(",");
|
||||
List<String> colList = new ArrayList<>(cols.length);
|
||||
Collections.addAll(colList, cols);
|
||||
return colList;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class MigrationModel {
|
||||
// find all the migration xml files
|
||||
File[] xmlFiles = modelDirectory.listFiles(pathname -> pathname.getName().toLowerCase().endsWith(modelSuffix));
|
||||
|
||||
List<MigrationResource> resources = new ArrayList<>();
|
||||
List<MigrationResource> resources = new ArrayList<>(xmlFiles.length);
|
||||
|
||||
for (File xmlFile : xmlFiles) {
|
||||
resources.add(new MigrationResource(xmlFile, createVersion(xmlFile)));
|
||||
|
||||
@@ -22,6 +22,7 @@ public class MigrationResource implements Comparable<MigrationResource> {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return migrationFile.getName();
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ public class MigrationVersion implements Comparable<MigrationVersion> {
|
||||
return raw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return raw;
|
||||
}
|
||||
|
||||
@@ -71,12 +71,9 @@ public class PlatformDdlWriter {
|
||||
protected void writePlatformDdl(DdlWrite write, File resourcePath, String fullVersion) throws IOException {
|
||||
|
||||
if (!write.isApplyEmpty()) {
|
||||
FileWriter applyWriter = createWriter(resourcePath, fullVersion, config.getApplySuffix());
|
||||
try {
|
||||
try (FileWriter applyWriter = createWriter(resourcePath, fullVersion, config.getApplySuffix())) {
|
||||
writeApplyDdl(applyWriter, write);
|
||||
applyWriter.flush();
|
||||
} finally {
|
||||
applyWriter.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class ModelBuildBeanVisitor implements BeanVisitor {
|
||||
* This creates an MTable and adds it to the model.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public ModelBuildPropertyVisitor visitBean(BeanDescriptor<?> descriptor) {
|
||||
|
||||
if (!descriptor.isInheritanceRoot()) {
|
||||
|
||||
@@ -13,34 +13,40 @@ public abstract class BaseTablePropertyVisitor implements BeanPropertyVisitor {
|
||||
/**
|
||||
* Not required in that you can use the visitEmbeddedScalar.
|
||||
*/
|
||||
@Override
|
||||
public void visitEmbedded(BeanPropertyAssocOne<?> p) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method.
|
||||
*/
|
||||
@Override
|
||||
public abstract void visitEmbeddedScalar(BeanProperty p, BeanPropertyAssocOne<?> embedded);
|
||||
|
||||
/**
|
||||
* Not part of base table.
|
||||
*/
|
||||
@Override
|
||||
public void visitMany(BeanPropertyAssocMany<?> p) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Not part of base table.
|
||||
*/
|
||||
@Override
|
||||
public void visitOneExported(BeanPropertyAssocOne<?> p) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method for the foreign key.
|
||||
*/
|
||||
@Override
|
||||
public abstract void visitOneImported(BeanPropertyAssocOne<?> p);
|
||||
|
||||
/**
|
||||
* Override this method for normal scalar property.
|
||||
*/
|
||||
@Override
|
||||
public abstract void visitScalar(BeanProperty p);
|
||||
|
||||
}
|
||||
|
||||
@@ -137,6 +137,7 @@ public class VisitAllUsing {
|
||||
this.pv = pv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(InheritInfo inheritInfo) {
|
||||
BeanProperty[] propertiesLocal = inheritInfo.desc().propertiesLocal();
|
||||
for (BeanProperty aPropertiesLocal : propertiesLocal) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import io.ebean.config.ServerConfig;
|
||||
*/
|
||||
public abstract class BeanPersistAdapter implements BeanPersistController {
|
||||
|
||||
@Override
|
||||
public abstract boolean isRegisterFor(Class<?> cls);
|
||||
|
||||
/**
|
||||
@@ -21,6 +22,7 @@ public abstract class BeanPersistAdapter implements BeanPersistController {
|
||||
* BeanPersistController's are executed when there is multiple of them
|
||||
* registered for a given entity type (class).
|
||||
*/
|
||||
@Override
|
||||
public int getExecutionOrder() {
|
||||
return 10;
|
||||
}
|
||||
@@ -28,6 +30,7 @@ public abstract class BeanPersistAdapter implements BeanPersistController {
|
||||
/**
|
||||
* Returns true indicating normal processing should continue.
|
||||
*/
|
||||
@Override
|
||||
public boolean preDelete(BeanPersistRequest<?> request) {
|
||||
return true;
|
||||
}
|
||||
@@ -35,6 +38,7 @@ public abstract class BeanPersistAdapter implements BeanPersistController {
|
||||
/**
|
||||
* Returns true indicating normal processing should continue.
|
||||
*/
|
||||
@Override
|
||||
public boolean preInsert(BeanPersistRequest<?> request) {
|
||||
return true;
|
||||
}
|
||||
@@ -42,6 +46,7 @@ public abstract class BeanPersistAdapter implements BeanPersistController {
|
||||
/**
|
||||
* Returns true indicating normal processing should continue.
|
||||
*/
|
||||
@Override
|
||||
public boolean preUpdate(BeanPersistRequest<?> request) {
|
||||
return true;
|
||||
}
|
||||
@@ -49,6 +54,7 @@ public abstract class BeanPersistAdapter implements BeanPersistController {
|
||||
/**
|
||||
* Returns true indicating normal processing should continue.
|
||||
*/
|
||||
@Override
|
||||
public boolean preSoftDelete(BeanPersistRequest<?> request) {
|
||||
return true;
|
||||
}
|
||||
@@ -56,24 +62,28 @@ public abstract class BeanPersistAdapter implements BeanPersistController {
|
||||
/**
|
||||
* Does nothing by default.
|
||||
*/
|
||||
@Override
|
||||
public void postDelete(BeanPersistRequest<?> request) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Does nothing by default.
|
||||
*/
|
||||
@Override
|
||||
public void postInsert(BeanPersistRequest<?> request) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Does nothing by default.
|
||||
*/
|
||||
@Override
|
||||
public void postUpdate(BeanPersistRequest<?> request) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Does nothing by default.
|
||||
*/
|
||||
@Override
|
||||
public void postSoftDelete(BeanPersistRequest<?> request) {
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,11 @@ public class BeanChange {
|
||||
*/
|
||||
String table;
|
||||
|
||||
/**
|
||||
* The tenantId value.
|
||||
*/
|
||||
Object tenantId;
|
||||
|
||||
/**
|
||||
* The id value.
|
||||
*/
|
||||
@@ -37,8 +42,9 @@ public class BeanChange {
|
||||
/**
|
||||
* Construct with all the details.
|
||||
*/
|
||||
public BeanChange(String table, Object id, ChangeType type, Map<String, ValuePair> values) {
|
||||
public BeanChange(String table, Object tenantId, Object id, ChangeType type, Map<String, ValuePair> values) {
|
||||
this.table = table;
|
||||
this.tenantId = tenantId;
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.eventTime = System.currentTimeMillis();
|
||||
@@ -51,8 +57,9 @@ public class BeanChange {
|
||||
public BeanChange() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "table:" + table + " id:" + id + " values:" + values;
|
||||
return "table:" + table + " tenantId: " + tenantId + " id:" + id + " values:" + values;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,6 +76,20 @@ public class BeanChange {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the tenant id.
|
||||
*/
|
||||
public Object getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bean id (for JSON tools).
|
||||
*/
|
||||
public void setTenantId(Object tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the object id.
|
||||
*/
|
||||
|
||||
@@ -66,6 +66,7 @@ public class ChangeSet {
|
||||
public ChangeSet() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "txnId:" + txnId + " txnState:" + txnState + " txnBatch:" + txnBatch;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public class ReadAuditQueryPlan {
|
||||
public ReadAuditQueryPlan() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "beanType:" + beanType + " queryKey:" + queryKey + " sql:" + sql;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public class PathProperties implements FetchPath {
|
||||
this.pathMap.put(null, rootProps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return pathMap.toString();
|
||||
}
|
||||
@@ -103,6 +104,7 @@ public class PathProperties implements FetchPath {
|
||||
/**
|
||||
* Apply these path properties as fetch paths to the query.
|
||||
*/
|
||||
@Override
|
||||
public <T> void apply(Query<T> query) {
|
||||
|
||||
for (Entry<String, Props> entry : pathMap.entrySet()) {
|
||||
@@ -179,6 +181,7 @@ public class PathProperties implements FetchPath {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return propSet.toString();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ public final class TimeStringParser implements StringParser {
|
||||
/**
|
||||
* Parse the String supporting both HH:mm:ss and HH:mm formats.
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public Object parse(String value) {
|
||||
if (value == null || value.trim().isEmpty()) {
|
||||
|
||||
@@ -77,6 +77,7 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
||||
/**
|
||||
* Create a transaction if required.
|
||||
*/
|
||||
@Override
|
||||
public void begin(EbeanServer server) {
|
||||
this.server = server;
|
||||
this.startTime = System.currentTimeMillis();
|
||||
@@ -92,6 +93,7 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
||||
* <p>
|
||||
* By default this does nothing (effectively ignoring the heading).
|
||||
*/
|
||||
@Override
|
||||
public void readHeader(String[] line) {
|
||||
|
||||
}
|
||||
@@ -109,6 +111,7 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
||||
* error).
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public boolean processLine(int row, String[] line) {
|
||||
return true;
|
||||
}
|
||||
@@ -121,6 +124,7 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
||||
* to use Cascade.PERSIST etc).
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void processBean(int row, String[] line, T bean) {
|
||||
|
||||
// assumes single bean or Cascade.PERSIST will save any
|
||||
@@ -135,6 +139,7 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
||||
/**
|
||||
* Commit the transaction if one was created.
|
||||
*/
|
||||
@Override
|
||||
public void end(int row) {
|
||||
|
||||
commitTransactionIfCreated();
|
||||
@@ -146,6 +151,7 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
||||
/**
|
||||
* Rollback the transaction if one was created.
|
||||
*/
|
||||
@Override
|
||||
public void endWithError(int row, Exception e) {
|
||||
rollbackTransactionIfCreated(e);
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ public class EJson {
|
||||
/**
|
||||
* Parse the json returning as a List taking into account the current token.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<Object> parseList(JsonParser parser, JsonToken currentToken) throws IOException {
|
||||
return (List<Object>) EJsonReader.parse(parser, currentToken, false);
|
||||
}
|
||||
|
||||
@@ -304,22 +304,27 @@ class EJsonReader {
|
||||
map = new ModifyAwareMap<>(owner, new LinkedHashMap<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popContext(Context temp) {
|
||||
setValue(temp.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getValue() {
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
void setValue(Object value) {
|
||||
map.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
void setValueNull() {
|
||||
map.put(key, null);
|
||||
}
|
||||
@@ -337,22 +342,27 @@ class EJsonReader {
|
||||
values = new ModifyAwareList<>(owner, new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popContext(Context temp) {
|
||||
values.add(temp.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getValue() {
|
||||
return values;
|
||||
}
|
||||
|
||||
@Override
|
||||
void setValue(Object value) {
|
||||
values.add(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
void setValueNull() {
|
||||
// ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
void setKey(String key) {
|
||||
// not expected
|
||||
}
|
||||
|
||||
@@ -23,8 +23,7 @@ class EJsonWriter {
|
||||
|
||||
static String write(Object object) throws IOException {
|
||||
StringWriter writer = new StringWriter(200);
|
||||
JsonGenerator jsonGenerator = write(object, writer);
|
||||
jsonGenerator.close();
|
||||
write(object, writer).close();
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class StringHelper {
|
||||
private static HashMap<String, String> parseNameQuotedValue(HashMap<String, String> map,
|
||||
String tag, int pos) throws RuntimeException {
|
||||
|
||||
int equalsPos = tag.indexOf("=", pos);
|
||||
int equalsPos = tag.indexOf('=', pos);
|
||||
if (equalsPos > -1) {
|
||||
// check for begin quote...
|
||||
char firstQuote = tag.charAt(equalsPos + 1);
|
||||
@@ -68,7 +68,6 @@ public class StringHelper {
|
||||
// dp("pos="+pos+" equalsPos="+equalsPos+"
|
||||
// endQuotePos="+endQuotePos);
|
||||
String name = tag.substring(pos, equalsPos);
|
||||
String value = tag.substring(equalsPos + 2, endQuotePos);
|
||||
// dp("name="+name+"; value="+value+";");
|
||||
|
||||
// trim off any whitespace from the front of name...
|
||||
@@ -76,6 +75,8 @@ public class StringHelper {
|
||||
if ((name.indexOf(SINGLE_QUOTE) > -1) || (name.indexOf(DOUBLE_QUOTE) > -1)) {
|
||||
throw new RuntimeException("attribute name contains a quote [" + name + "]");
|
||||
}
|
||||
|
||||
String value = tag.substring(equalsPos + 2, endQuotePos);
|
||||
map.put(name, value);
|
||||
|
||||
return parseNameQuotedValue(map, tag, endQuotePos + 1);
|
||||
@@ -97,7 +98,7 @@ public class StringHelper {
|
||||
private static int countOccurances(String content, String occurs, int pos, int countSoFar) {
|
||||
int equalsPos = content.indexOf(occurs, pos);
|
||||
if (equalsPos > -1) {
|
||||
countSoFar = countSoFar + 1;
|
||||
countSoFar += 1;
|
||||
pos = equalsPos + occurs.length();
|
||||
// dp("countSoFar="+countSoFar+" pos="+pos);
|
||||
return countOccurances(content, occurs, pos, countSoFar);
|
||||
@@ -279,7 +280,7 @@ public class StringHelper {
|
||||
}
|
||||
int startPos = str.indexOf(leftBound);
|
||||
if (startPos > -1) {
|
||||
startPos = startPos + leftBound.length();
|
||||
startPos += leftBound.length();
|
||||
int endPos = str.indexOf(rightBound, startPos);
|
||||
// dp(str+" start:"+startPos+" end:"+endPos);
|
||||
if (endPos == -1) {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Utility and helper classes.
|
||||
*/
|
||||
package io.ebean.util;
|
||||
@@ -397,6 +397,7 @@ public class BindParams implements Serializable {
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hc = getClass().hashCode();
|
||||
hc = hc * 92821 + (isInParam ? 0 : 1);
|
||||
@@ -406,6 +407,7 @@ public class BindParams implements Serializable {
|
||||
return hc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o != null && (o == this || (o instanceof Param) && hashCode() == o.hashCode());
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user