Compare commits

...
75 Commits
Author SHA1 Message Date
Rob Bygrave f815415eb0 [maven-release-plugin] prepare release ebean-9.1.2 2016-11-16 00:24:44 +13:00
Rob Bygrave cf81d1699b Modify scm in pom 2016-11-16 00:23:54 +13:00
Rob Bygrave de9576835c #872 - test models for DDL check constraint issue (not reproduced) 2016-11-15 23:27:08 +13:00
Rob Bygrave 632cf10096 #878 - @AttributeOverride (not wrapped in @AttributeOverrides) is not applied 2016-11-15 22:48:36 +13:00
Rob Bygrave d2b6d06da5 Merge branch 'master' of github.com:ebean-orm/ebean 2016-11-15 22:13:09 +13:00
Rob Bygrave b41f3e9d1f #877 - DBMigration Generates wrong ddl for UUID type 2016-11-15 22:12:54 +13:00
Rob BygraveandGitHub 8357d9c7e7 Merge pull request #876 from ksperling/batching-exception-safety
Batching exception safety: Fix test
2016-11-14 15:28:36 +13:00
Karsten Sperling 97f1834c4d Batching exception safety: Update test to reflect real world scenario more closely (and actually fail before the change) 2016-11-14 12:48:58 +13:00
Rob Bygrave 01f551a951 #875 - Changes to support ElasticSearch 5.x 2016-11-12 01:05:13 +13:00
Rob Bygrave 482d454fc3 #875 - Changes to support ElasticSearch 5.x 2016-11-11 23:43:13 +13:00
Rob Bygrave 2953418683 No effective change - add .editorconfig 2016-11-11 17:14:12 +13:00
Rob Bygrave 5c142a61f6 No effective change - add javadoc 2016-11-11 17:11:15 +13:00
Rob BygraveandGitHub 74626184b2 Merge pull request #873 from ksperling/batching-exception-safety
Batching exception safety
2016-11-11 17:06:29 +13:00
Karsten Sperling 8661e1fd3f Reset batch on rollback 2016-11-09 10:58:57 +13:00
Karsten Sperling 9569b1b0d5 Added test for exception safety when using batchOnCascade 2016-11-09 10:58:57 +13:00
Rob BygraveandGitHub 3eb9bc1d16 Merge pull request #870 from 0xbaadf00d/feature/use-foreach
Replace "for" with "foreach"
2016-11-08 23:42:12 +13:00
Thibault Meyer ec6a8f5ea2 Replace "for" with "foreach" 2016-11-08 09:06:13 +01:00
Rob Bygrave d6ba567763 [maven-release-plugin] prepare for next development iteration 2016-11-08 00:32:47 +13:00
Rob Bygrave 6826fe1015 [maven-release-plugin] prepare release ebean-9.1.1 2016-11-08 00:32:38 +13:00
Rob Bygrave e67860cbe3 Merge branch 'master' of https://github.com/ebean-orm/ebean 2016-11-08 00:27:40 +13:00
Rob Bygrave b41238ddbb No effective change - modify TestHistoryInsert for more wait time and logging (PG test failing sometimes in CI) 2016-11-08 00:25:13 +13:00
Rob BygraveandGitHub c0b1c3d3ee Merge pull request #868 from 0xbaadf00d/feature/array-copy-performance
Use "Collection.addAll(...)" rather than manually copying arrays
2016-11-08 00:16:33 +13:00
Rob Bygrave ae69fcb80a #862 - ENH: Change ServerConfig such that if H2 ... no using createOnly = true in case the test EbeanServer instance is created for each test (and hence we need to drop if the same in memory db is used) 2016-11-08 00:10:15 +13:00
Rob Bygrave 6c4c33f1f3 No effective change - reduce logging in test (for CI) 2016-11-08 00:03:15 +13:00
Rob Bygrave 2986290947 Refactor - change use of 31 prime in various hash to 92821 2016-11-07 23:57:51 +13:00
Rob Bygrave 376cb9ebcb #869 - Clash on bind hash value for query cache with consecutive values of "01","20" and "02", "10" 2016-11-07 23:47:29 +13:00
Rob Bygrave 5cf5629232 #869 - Test for ... Clash on bind hash value for query cache with consecutive values of "01","20" and "02", "10" 2016-11-07 23:46:28 +13:00
Thibault Meyer 98aa5e9da9 Use "Collection.addAll(...)" rather than manually copying arrays 2016-11-07 11:07:37 +01:00
Rob BygraveandGitHub ed1df5bcbb Merge pull request #864 from 0xbaadf00d/feature/redundant-local-var
Remove redundant local variables
2016-11-07 22:14:59 +13:00
Thibault Meyer 6704ccc6a7 Merge branch 'master' into feature/redundant-local-var 2016-11-07 10:11:03 +01:00
Thibault Meyer 5f35e3c944 Remove redundant local variables 2016-11-07 10:03:50 +01:00
Rob Bygrave 0893972115 Fix for running CI tests as Postgres (where we need to explicitly turn on DDL generation and running for the tests). 2016-11-07 22:00:33 +13:00
Rob Bygrave 7a8d1b85a9 #866 - Fix RawSql mapping such that it automatically maps foreign key columns 2016-11-07 21:57:03 +13:00
Rob Bygrave 686593e9e8 No effective change - tidy up test Order entity bean 2016-11-07 21:36:19 +13:00
Rob Bygrave d05b593432 #862 - ENH: Change ServerConfig such that if H2 is the DataSource/DatabasePlatform then automatically it sets up for testing (ddl generation) 2016-11-07 19:50:05 +13:00
Rob Bygrave b581c893ec No effective change - tidy up test conversation User entity bean 2016-11-07 19:47:34 +13:00
Rob Bygrave 63f852475d #863 - @Enumerated(EnumType.STRING) DayOfWeek day; ... incorrectly maps to SQL Integer type 2016-11-07 17:15:47 +13:00
Rob BygraveandGitHub 51364763fb Merge pull request #860 from 0xbaadf00d/feature/replace-anonymous-classes
Replace anonymous classes with lambda expressions
2016-11-07 13:02:33 +13:00
Rob BygraveandGitHub ea408fd4c7 Merge pull request #861 from 0xbaadf00d/feature/coding-style
Remove redundant "public" modifier for interface methods
2016-11-07 12:58:23 +13:00
Thibault Meyer 8dc521ca8b Remove redundant "public" modifier for interface methods 2016-11-06 11:48:59 +01:00
Thibault Meyer 6680e2ea75 Replace anonymous classes with lambda expressions 2016-11-06 11:17:53 +01:00
Rob BygraveandGitHub da30df3b2b Merge pull request #858 from 0xbaadf00d/feature/deprecated-api-usage
Deprecated API usage - Modify ScalarTypeJodaLocalTime to use toDateTimeToday().getMillis()
2016-11-06 22:59:32 +13:00
Rob BygraveandGitHub d12ea89388 Merge pull request #854 from 0xbaadf00d/feature/explicit-type-to-diamond
Replace explicit type with <>
2016-11-06 22:54:24 +13:00
Thibault Meyer e0931e41e5 Remove deprecated API usage 2016-11-06 10:50:31 +01:00
Rob BygraveandGitHub c98d258127 Merge pull request #857 from 0xbaadf00d/feature/boxing-unboxing
Remove unnecessary boxing and unboxing
2016-11-06 22:43:33 +13:00
Rob BygraveandGitHub a4922a5b1d Merge pull request #856 from 0xbaadf00d/feature/identical-catch
Change identical 'catch' statements
2016-11-06 22:42:13 +13:00
Rob BygraveandGitHub edb2a69f6e Merge pull request #853 from 0xbaadf00d/fix/javadoc-error
Javadoc error
2016-11-06 22:40:52 +13:00
Thibault Meyer b94f852b67 Remove unnecessary boxing and unboxing 2016-11-06 10:29:42 +01:00
Thibault Meyer a8778ef14c Change identical 'catch' statements 2016-11-06 10:26:13 +01:00
Rob Bygrave cbfce0d14d #855 - Fix @Aggregation lazy loading and base select issue 2016-11-06 22:18:23 +13:00
Thibault Meyer abb25d397a Fix comments 2016-11-06 10:03:33 +01:00
Thibault Meyer 969a3c8b8d Replace explicit type with <> 2016-11-06 10:00:12 +01:00
Rob Bygrave 2a6d38eef2 #852 - javax.persistence.PersistenceException: No ScalarType registered for class Foo$1 ... where Foo is an Enum where individual instances override a method (example below). 2016-11-06 20:33:56 +13:00
Rob Bygrave d84080fb76 Refactor - clean up DefaultTypeManager, diamond operator and access modifiers only 2016-11-06 19:45:46 +13:00
Rob Bygrave 54d7a6fb42 Refactor - clean up docstore api mapping, diamond operator only 2016-11-05 23:04:33 +13:00
Rob Bygrave e5356e7118 Refactor - tidy up in com.avaje.ebeaninternal util, no effective change 2016-11-05 23:01:03 +13:00
Rob Bygrave e83556cada Refactor - clean up OrmQueryDetailParser, remove unused sections 2016-11-05 22:51:51 +13:00
Rob Bygrave 201a2826ab Refactor - tidy up in com.avaje.ebeaninternal.server.querydefn, no effective change 2016-11-05 22:46:43 +13:00
Rob Bygrave 670bac52f8 Refactor - tidy up in com.avaje.ebeaninternal.server.query, no effective change 2016-11-05 22:32:36 +13:00
Rob Bygrave 77e3346d9e Refactor - clean up CQueryPlan, CQueryPlanStats 2016-11-05 15:11:17 +13:00
Rob Bygrave 4663162f95 Refactor - no effective chang - Add SpiQuery getOriginKey() 2016-11-05 14:48:03 +13:00
Rob BygraveandGitHub 83a3ef43bd Merge pull request #851 from FOCONIS/fix/javawarnings
FIX some java warnings / rawtypes
2016-11-05 09:23:07 +13:00
Roland Praml 3701b314a0 FIX some java warnings / rawtypes 2016-11-04 12:19:38 +01:00
Rob Bygrave fad8358a9d Bump to java8-parent, update to Java8 LongAdder 2016-11-04 20:04:25 +13:00
Rob Bygrave 78c4dbb44d [maven-release-plugin] prepare for next development iteration 2016-11-04 19:19:11 +13:00
Rob Bygrave 9c74520a4b [maven-release-plugin] prepare release ebean-8.8.1 2016-11-04 19:19:02 +13:00
Rob Bygrave c911c710d5 Bump pom to 8.8.1-SNAPSHOT 2016-11-04 01:17:08 +13:00
Rob Bygrave f08dd01035 #836 - ENH: Add support for @DbArray even for H2 db 2016-11-04 01:16:32 +13:00
Rob Bygrave a1b4af2716 Refactor - no effective change - remove un-required callback from PersistExecute to PersistRequestBean 2016-11-03 23:42:43 +13:00
Rob Bygrave 8c500c5836 #846 - Add soft delete related callbacks 2016-11-03 23:27:39 +13:00
Rob Bygrave c1d6cc7b75 Refactor - no real change - tighter access on SqlTreeNodeBean 2016-11-03 23:18:14 +13:00
Rob Bygrave d6fe16ffda Change permissions on travis scripts 2016-11-03 23:14:14 +13:00
Rob Bygrave d0230491e5 #99 - ENH (419) : Simplify aggregation queries - part 2 2016-11-03 23:06:54 +13:00
Rob Bygrave 3526f71f0a #99 - ENH (419) : Simplify aggregation queries 2016-11-02 22:10:22 +13:00
Rob Bygrave 18f943ab2b [maven-release-plugin] prepare for next development iteration 2016-10-31 21:59:39 +13:00
516 changed files with 4350 additions and 4133 deletions
+12
View File
@@ -0,0 +1,12 @@
# editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
spaces_around_operators = true
+5 -31
View File
@@ -3,13 +3,13 @@
<parent>
<groupId>org.avaje</groupId>
<artifactId>oss-parent</artifactId>
<artifactId>java8-parent</artifactId>
<version>1.1</version>
</parent>
<groupId>org.avaje.ebean</groupId>
<artifactId>ebean</artifactId>
<version>8.7.1</version>
<version>9.1.2</version>
<packaging>jar</packaging>
<name>ebean</name>
@@ -19,25 +19,9 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>rbygrave</id>
<name>Rob Bygrave</name>
<email>robin.bygrave@gmail.com</email>
</developer>
</developers>
<scm>
<developerConnection>scm:git:https://github.com/ebean-orm/ebean.git</developerConnection>
<tag>ebean-8.7.1</tag>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>ebean-9.1.2</tag>
</scm>
<dependencies>
@@ -236,16 +220,6 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.avaje.ebean</groupId>
<artifactId>ebean-maven-plugin</artifactId>
@@ -303,7 +277,7 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<doctitle>Ebean 8</doctitle>
<doctitle>Ebean 9</doctitle>
<overview>src/main/java/com/avaje/ebean/overview.html</overview>
<source>1.8</source>
<doclet>org.avaje.doclet.PygmentsDoclet</doclet>
@@ -30,7 +30,7 @@ final class DRawSqlColumnsParser {
private ColumnMapping parse() {
ArrayList<ColumnMapping.Column> columns = new ArrayList<ColumnMapping.Column>();
ArrayList<ColumnMapping.Column> columns = new ArrayList<>();
while (pos <= end) {
ColumnMapping.Column c = nextColumnInfo();
columns.add(c);
@@ -47,10 +47,10 @@ final class DRawSqlColumnsParser {
String[] split = colInfo.split("\\s(?=[^\\)]*(?:\\(|$))");
if (split.length > 1) {
ArrayList<String> tmp = new ArrayList<String>(split.length);
for (int i = 0; i < split.length; i++) {
if (!split[i].trim().isEmpty()) {
tmp.add(split[i].trim());
ArrayList<String> tmp = new ArrayList<>(split.length);
for (String aSplit : split) {
if (!aSplit.trim().isEmpty()) {
tmp.add(aSplit.trim());
}
}
split = tmp.toArray(new String[tmp.size()]);
@@ -66,8 +66,8 @@ final class DRawSqlColumnsParser {
if (split.length == 2) {
return new ColumnMapping.Column(indexPos++, split[0], split[1]);
}
// Ok, we now expect/require the AS keyword and it should be the
// second to last word in the colInfo content
// Ok, we now expect/require the AS keyword and it should be the
// second to last word in the colInfo content
if (!split[split.length - 2].equalsIgnoreCase("as")) {
throw new PersistenceException("Expecting AS keyword as second to last word when parsing column " + colInfo);
}
@@ -1,6 +1,7 @@
package com.avaje.ebean;
import com.avaje.ebean.RawSql.Sql;
import com.avaje.ebeaninternal.server.querydefn.SimpleTextParser;
/**
* Parses sql-select queries to try and determine the location where WHERE and
@@ -8,13 +9,13 @@ import com.avaje.ebean.RawSql.Sql;
*/
class DRawSqlParser {
public static final String $_AND_HAVING = "${andHaving}";
private static final String $_AND_HAVING = "${andHaving}";
public static final String $_HAVING = "${having}";
private static final String $_HAVING = "${having}";
public static final String $_AND_WHERE = "${andWhere}";
private static final String $_AND_WHERE = "${andWhere}";
public static final String $_WHERE = "${where}";
private static final String $_WHERE = "${where}";
private final SimpleTextParser textParser;
+2 -2
View File
@@ -132,13 +132,13 @@ public final class Ebean {
/**
* Cache for fast concurrent read access.
*/
private final ConcurrentHashMap<String, EbeanServer> concMap = new ConcurrentHashMap<String, EbeanServer>();
private final ConcurrentHashMap<String, EbeanServer> concMap = new ConcurrentHashMap<>();
/**
* Cache for synchronized read, creation and put. Protected by the monitor
* object.
*/
private final HashMap<String, EbeanServer> syncMap = new HashMap<String, EbeanServer>();
private final HashMap<String, EbeanServer> syncMap = new HashMap<>();
private final Object monitor = new Object();
@@ -752,7 +752,7 @@ public interface EbeanServer {
*
* @see Query#findIds()
*/
<A> List<A> findIds(Query<?> query, Transaction transaction);
<A, T> List<A> findIds(Query<T> query, Transaction transaction);
/**
* Return a QueryIterator for the query.
@@ -1024,7 +1024,7 @@ public interface EbeanServer {
*
* @see Query#findSingleAttributeList()
*/
<A> List<A> findSingleAttributeList(Query<?> query, Transaction transaction);
<A, T> List<A> findSingleAttributeList(Query<T> query, Transaction transaction);
/**
* Execute the query returning at most one entity bean or null (if no matching
@@ -9,6 +9,7 @@ import java.util.concurrent.Future;
* It extends the java.util.concurrent.Future.
* </p>
*
* @param <T> the BeanType
* @author rbygrave
*/
public interface FutureRowCount<T> extends Future<Integer> {
@@ -96,6 +96,11 @@ public interface Junction<T> extends Expression, ExpressionList<T> {
*/
NOT(" and ", "not ", false),
/**
* FILTER group (for internal use only).
*/
FILTER("filter", "", true),
/**
* Text search AND group.
*/
+1 -1
View File
@@ -512,7 +512,7 @@ public abstract class Model {
* Create and return a new Finder for a different server.
*/
public Finder<I, T> on(String server) {
return new Finder<I, T>(server, type);
return new Finder<>(server, type);
}
/**
+22 -22
View File
@@ -28,9 +28,9 @@ public final class OrderBy<T> implements Serializable {
* Create an empty OrderBy with no associated query.
*/
public OrderBy() {
this.list = new ArrayList<Property>(3);
this.list = new ArrayList<>(3);
}
private OrderBy(List<Property> list) {
this.list = list;
}
@@ -52,7 +52,7 @@ public final class OrderBy<T> implements Serializable {
*/
public OrderBy(Query<T> query, String orderByClause) {
this.query = query;
this.list = new ArrayList<Property>(3);
this.list = new ArrayList<>(3);
parse(orderByClause);
}
@@ -60,8 +60,8 @@ public final class OrderBy<T> implements Serializable {
* Reverse the ascending/descending order on all the properties.
*/
public void reverse() {
for (int i = 0; i < list.size(); i++) {
list.get(i).reverse();
for (Property aList : list) {
aList.reverse();
}
}
@@ -88,8 +88,8 @@ public final class OrderBy<T> implements Serializable {
*/
public boolean containsProperty(String propertyName) {
for (int i = 0; i < list.size(); i++) {
if (propertyName.equals(list.get(i).getProperty())) {
for (Property aList : list) {
if (propertyName.equals(aList.getProperty())) {
return true;
}
}
@@ -100,13 +100,13 @@ public final class OrderBy<T> implements Serializable {
* Return a copy of this OrderBy with the path trimmed.
*/
public OrderBy<T> copyWithTrim(String path) {
List<Property> newList = new ArrayList<Property>(list.size());
for (int i = 0; i < list.size(); i++) {
newList.add(list.get(i).copyWithTrim(path));
List<Property> newList = new ArrayList<>(list.size());
for (Property aList : list) {
newList.add(aList.copyWithTrim(path));
}
return new OrderBy<T>(newList);
return new OrderBy<>(newList);
}
/**
* Return the properties for this OrderBy.
*/
@@ -141,9 +141,9 @@ public final class OrderBy<T> implements Serializable {
*/
public OrderBy<T> copy() {
OrderBy<T> copy = new OrderBy<T>();
for (int i = 0; i < list.size(); i++) {
copy.add(list.get(i).copy());
OrderBy<T> copy = new OrderBy<>();
for (Property aList : list) {
copy.add(aList.copy());
}
return copy;
}
@@ -192,7 +192,7 @@ public final class OrderBy<T> implements Serializable {
if (!(obj instanceof OrderBy<?>)) {
return false;
}
OrderBy<?> e = (OrderBy<?>) obj;
return e.list.equals(list);
}
@@ -356,8 +356,8 @@ public final class OrderBy<T> implements Serializable {
}
String[] chunks = orderByClause.split(",");
for (int i = 0; i < chunks.length; i++) {
String[] pairs = chunks[i].split(" ");
for (String chunk : chunks) {
String[] pairs = chunk.split(" ");
Property p = parseProperty(pairs);
if (p != null) {
list.add(p);
@@ -370,10 +370,10 @@ public final class OrderBy<T> implements Serializable {
return null;
}
ArrayList<String> wordList = new ArrayList<String>(pairs.length);
for (int i = 0; i < pairs.length; i++) {
if (!isEmptyString(pairs[i])) {
wordList.add(pairs[i]);
ArrayList<String> wordList = new ArrayList<>(pairs.length);
for (String pair : pairs) {
if (!isEmptyString(pair)) {
wordList.add(pair);
}
}
if (wordList.isEmpty()) {
+1 -1
View File
@@ -8,7 +8,7 @@ import java.util.concurrent.Future;
* <p>
* The benefit of using PagedList over just using the normal Query with
* {@link Query#setFirstRow(int)} and {@link Query#setMaxRows(int)} is that it additionally wraps
* functionality that can call {@link Query#findFutureRowCount()} to determine total row count,
* functionality that can call {@link Query#findFutureCount()} to determine total row count,
* total page count etc.
* </p>
* <p>
@@ -7,6 +7,8 @@ import javax.persistence.PersistenceException;
*/
public class PersistenceIOException extends PersistenceException {
private static final long serialVersionUID = -7630050437148176148L;
public PersistenceIOException(String msg, Exception cause) {
super(msg, cause);
}
+29 -30
View File
@@ -53,37 +53,37 @@ import com.avaje.ebean.util.CamelCaseHelper;
* </p>
*
* <h3>Example OrderAggregate</h3>
*
*
* <pre>{@code
* ...
* // @Sql indicates to that this bean
* // is based on RawSql rather than a table
*
*
* @Entity
* @Sql
* public class OrderAggregate {
*
*
* @OneToOne
* Order order;
*
*
* Double totalAmount;
*
*
* Double totalItems;
*
*
* // getters and setters
* ...
*
* }</pre>
*
* <h3>Example 1:</h3>
*
*
* <pre>{@code
*
* String sql = " select order_id, o.status, c.id, c.name, sum(d.order_qty*d.unit_price) as totalAmount"
* + " from o_order o"
* + " join o_customer c on c.id = o.kcustomer_id "
* + " join o_order_detail d on d.order_id = o.id " + " group by order_id, o.status ";
*
*
* RawSql rawSql = RawSqlBuilder.parse(sql)
* // map the sql result columns to bean properties
* .columnMapping("order_id", "order.id")
@@ -93,35 +93,35 @@ import com.avaje.ebean.util.CamelCaseHelper;
* // we don't need to map this one due to the sql column alias
* // .columnMapping("sum(d.order_qty*d.unit_price)", "totalAmount")
* .create();
*
*
* List<OrderAggregate> list = Ebean.find(OrderAggregate.class)
* .setRawSql(rawSql)
* .where().gt("order.id", 0)
* .having().gt("totalAmount", 20)
* .findList();
*
*
*
* }</pre>
*
*
* <h3>Example 2:</h3>
*
*
* <p>
* The following example uses a FetchConfig().query() so that after the initial
* RawSql query is executed Ebean executes a secondary query to fetch the
* associated order status, orderDate along with the customer name.
* </p>
*
*
* <pre>{@code
*
* String sql = " select order_id, 'ignoreMe', sum(d.order_qty*d.unit_price) as totalAmount "
* + " from o_order_detail d"
* + " group by order_id ";
*
*
* RawSql rawSql = RawSqlBuilder.parse(sql)
* .columnMapping("order_id", "order.id")
* .columnMappingIgnore("'ignoreMe'")
* .create();
*
*
* List<OrderAggregate> orders = Ebean.find(OrderAggregate.class)
* .setRawSql(rawSql)
* .fetch("order", "status,orderDate", new FetchConfig().query())
@@ -131,7 +131,7 @@ import com.avaje.ebean.util.CamelCaseHelper;
* .order().desc("totalAmount")
* .setMaxRows(10)
* .findList();
*
*
* }</pre>
*
*
@@ -167,14 +167,14 @@ import com.avaje.ebean.util.CamelCaseHelper;
* <p>
* Note that lazy loading also works with object graphs built with RawSql.
* </p>
*
*
*/
public final class RawSql implements Serializable {
private static final long serialVersionUID = 1L;
private final ResultSet resultSet;
private final Sql sql;
private final ColumnMapping columnMapping;
@@ -192,7 +192,7 @@ public final class RawSql implements Serializable {
this.sql = null;
this.columnMapping = new ColumnMapping(propertyNames);
}
protected RawSql(ResultSet resultSet, Sql sql, ColumnMapping columnMapping) {
this.resultSet = resultSet;
this.sql = sql;
@@ -214,7 +214,7 @@ public final class RawSql implements Serializable {
String unParsedSql = (sql == null) ? "" : sql.unparsedSql;
return new Key(parsed, unParsedSql, columnMapping);
}
/**
* Return the resultSet if this is a ResultSet based RawSql.
*/
@@ -386,7 +386,7 @@ public final class RawSql implements Serializable {
private final LinkedHashMap<String, Column> dbColumnMap;
private final Map<String, String> propertyMap;
private final Map<String, Column> propertyColumnMap;
private final boolean parsed;
@@ -401,9 +401,8 @@ public final class RawSql implements Serializable {
this.parsed = true;
this.propertyMap = null;
this.propertyColumnMap = null;
this.dbColumnMap = new LinkedHashMap<String, Column>();
for (int i = 0; i < columns.size(); i++) {
Column c = columns.get(i);
this.dbColumnMap = new LinkedHashMap<>();
for (Column c : columns) {
dbColumnMap.put(c.getDbColumnKey(), c);
}
}
@@ -416,9 +415,9 @@ public final class RawSql implements Serializable {
this.parsed = false;
this.propertyMap = null;
this.propertyColumnMap = null;
this.dbColumnMap = new LinkedHashMap<String, Column>();
this.dbColumnMap = new LinkedHashMap<>();
}
/**
* Construct for ResultSet use.
*/
@@ -426,7 +425,7 @@ public final class RawSql implements Serializable {
this.immutable = false;
this.parsed = false;
this.propertyMap = null;
this.dbColumnMap = new LinkedHashMap<String, Column>();
this.dbColumnMap = new LinkedHashMap<>();
int pos = 0;
for (String prop : propertyNames) {
@@ -443,8 +442,8 @@ public final class RawSql implements Serializable {
this.parsed = parsed;
this.dbColumnMap = dbColumnMap;
HashMap<String, Column> pcMap = new HashMap<String, Column>();
HashMap<String, String> pMap = new HashMap<String, String>();
HashMap<String, Column> pcMap = new HashMap<>();
HashMap<String, String> pMap = new HashMap<>();
for (Column c : dbColumnMap.values()) {
pMap.put(c.getPropertyName(), c.getDbColumn());
@@ -476,7 +475,7 @@ public final class RawSql implements Serializable {
/**
* Creates an immutable copy of this ColumnMapping.
*
*
* @throws IllegalStateException
* when a propertyName has not been defined for a column.
*/
@@ -1,167 +0,0 @@
package com.avaje.ebean;
class SimpleTextParser {
private final String oql;
private final char[] chars;
private final int eof;
private int pos;
private String word;
private String lowerWord;
SimpleTextParser(String oql) {
this.oql = oql;
this.chars = oql.toCharArray();
this.eof = oql.length();
}
public int getPos() {
return pos;
}
public String getWord() {
return word;
}
public String peekNextWord() {
int origPos = pos;
String nw = nextWordInternal();
pos = origPos;
return nw;
}
/**
* Match the current and the next word.
*/
public boolean isMatch(String lowerMatch, String nextWordMatch) {
if (isMatch(lowerMatch)) {
String nw = peekNextWord();
if (nw != null) {
nw = nw.toLowerCase();
return nw.equals(nextWordMatch);
}
}
return false;
}
public boolean isFinished() {
return word == null;
}
public int findWordLower(String lowerMatch, int afterPos) {
this.pos = afterPos;
return findWordLower(lowerMatch);
}
public int findWordLower(String lowerMatch) {
do {
if (nextWord() == null) {
return -1;
}
if (lowerMatch.equals(lowerWord)) {
return pos - lowerWord.length();
}
} while (true);
}
/**
* Match the current word.
*/
public boolean isMatch(String lowerMatch) {
return lowerMatch.equals(lowerWord);
}
public String nextWord() {
word = nextWordInternal();
if (word != null) {
lowerWord = word.toLowerCase();
}
return word;
}
private String nextWordInternal() {
trimLeadingWhitespace();
if (pos >= eof) {
return null;
}
int start = pos;
if (chars[pos] == '(') {
moveToClose();
} else {
moveToEndOfWord();
}
return oql.substring(start, pos);
}
private void moveToClose() {
pos++;
int openParenthesisCount = 0;
for (; pos < eof; pos++) {
char c = chars[pos];
if (c == '(') {
// count nested parenthesis
openParenthesisCount++;
} else if (c == ')') {
if (openParenthesisCount > 0) {
// still in nested parenthesis
--openParenthesisCount;
} else {
// we have found the end
pos++;
return;
}
}
}
}
private void moveToEndOfWord() {
char c = chars[pos];
boolean isOperator = isOperator(c);
for (; pos < eof; pos++) {
c = chars[pos];
if (isWordTerminator(c, isOperator)) {
return;
}
}
}
private boolean isWordTerminator(char c, boolean isOperator) {
if (Character.isWhitespace(c)) {
return true;
}
if (isOperator(c)) {
return !isOperator;
}
return c == '(' || isOperator;
}
private boolean isOperator(char c) {
switch (c) {
case '<':
return true;
case '>':
return true;
case '=':
return true;
case '!':
return true;
default:
return false;
}
}
private void trimLeadingWhitespace() {
for (; pos < eof; pos++) {
char c = chars[pos];
if (!Character.isWhitespace(c)) {
break;
}
}
}
}
+8 -8
View File
@@ -282,7 +282,7 @@ public final class TxScope {
*/
public TxScope setRollbackFor(Class<? extends Throwable> rollbackThrowable) {
if (rollbackFor == null) {
rollbackFor = new ArrayList<Class<? extends Throwable>>(2);
rollbackFor = new ArrayList<>(2);
}
rollbackFor.add(rollbackThrowable);
return this;
@@ -294,10 +294,10 @@ public final class TxScope {
@SuppressWarnings("unchecked")
public TxScope setRollbackFor(Class<?>[] rollbackThrowables) {
if (rollbackFor == null) {
rollbackFor = new ArrayList<Class<? extends Throwable>>(rollbackThrowables.length);
rollbackFor = new ArrayList<>(rollbackThrowables.length);
}
for (int i = 0; i < rollbackThrowables.length; i++) {
rollbackFor.add((Class<? extends Throwable>) rollbackThrowables[i]);
for (Class<?> rollbackThrowable : rollbackThrowables) {
rollbackFor.add((Class<? extends Throwable>) rollbackThrowable);
}
return this;
}
@@ -316,7 +316,7 @@ public final class TxScope {
*/
public TxScope setNoRollbackFor(Class<? extends Throwable> noRollback) {
if (noRollbackFor == null) {
noRollbackFor = new ArrayList<Class<? extends Throwable>>(2);
noRollbackFor = new ArrayList<>(2);
}
this.noRollbackFor.add(noRollback);
return this;
@@ -328,10 +328,10 @@ public final class TxScope {
@SuppressWarnings("unchecked")
public TxScope setNoRollbackFor(Class<?>[] noRollbacks) {
if (noRollbackFor == null) {
noRollbackFor = new ArrayList<Class<? extends Throwable>>(noRollbacks.length);
noRollbackFor = new ArrayList<>(noRollbacks.length);
}
for (int i = 0; i < noRollbacks.length; i++) {
noRollbackFor.add((Class<? extends Throwable>) noRollbacks[i]);
for (Class<?> noRollback : noRollbacks) {
noRollbackFor.add((Class<? extends Throwable>) noRollback);
}
return this;
}
@@ -0,0 +1,50 @@
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;
/**
* Specify a property to be an aggregation formula.
* <p>
* The aggregation formula should be a sum, count, avg, min or max.
* By default aggregation properties are treated as transient and not
* included in a query. To populate the aggregation property it must be
* explicitly included in the select().
* </p>
*
* <h3>Example:</h3>
* <pre>{@code
*
* @Aggregation("count(details)")
* Long totalCount;
*
* @Aggregation("sum(details.quantity*details.unitPrice)")
* Long totalAmount;
*
* }</pre>
*
* <h3>Example query</h3>
* <pre>{@code
*
* List<TEventOne> list = Ebean.find(TEventOne.class)
* .select("name, totalCount, totalUnits, totalAmount")
* .where()
* .startsWith("logs.description", "a")
* .having()
* .ge("count", 1)
* .orderBy().asc("name")
* .findList();
*
* }</pre>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Aggregation {
/**
* Aggregation formula using sum, count, avg, min, max.
*/
String value();
}
@@ -34,12 +34,12 @@ public final class CallStack implements Serializable {
public int hashCode() {
int hc = 0;
for (int i = 0; i < callStack.length; i++) {
hc = 31 * hc + callStack[i].hashCode();
for (StackTraceElement aCallStack : callStack) {
hc = 31 * hc + aCallStack.hashCode();
}
return hc;
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
@@ -88,8 +88,8 @@ public final class CallStack implements Serializable {
*/
public String description(String newLine) {
StringBuilder sb = new StringBuilder(400);
for (int i = 0; i < callStack.length; i++) {
sb.append(callStack[i].toString()).append(newLine);
for (StackTraceElement aCallStack : callStack) {
sb.append(aCallStack.toString()).append(newLine);
}
return sb.toString();
}
@@ -30,7 +30,7 @@ public final class EntityBeanIntercept implements Serializable {
private static final int STATE_NEW = 0;
private static final int STATE_REFERENCE = 1;
private static final int STATE_LOADED = 2;
private transient NodeUsageCollector nodeUsageCollector;
private transient PropertyChangeSupport pcs;
@@ -55,11 +55,11 @@ public final class EntityBeanIntercept implements Serializable {
* One of NEW, REF, UPD.
*/
private int state;
private boolean readOnly;
private boolean dirty;
/**
* Flag set to disable lazy loading - typically for SQL "report" type entity beans.
*/
@@ -74,14 +74,14 @@ public final class EntityBeanIntercept implements Serializable {
* Used when a bean is partially filled.
*/
private final boolean[] loadedProps;
private boolean fullyLoadedBean;
/**
* Set of changed properties.
*/
private boolean[] changedProps;
/**
* Flags indicating if a property is a dirty embedded bean. Used to distingush
* between an embedded bean being completely overwritten and one of its
@@ -180,7 +180,7 @@ public final class EntityBeanIntercept implements Serializable {
public Object getEmbeddedOwner() {
return embeddedOwner;
}
/**
* Return the property index (for the parent) of this embedded bean.
*/
@@ -240,8 +240,8 @@ public final class EntityBeanIntercept implements Serializable {
* Check each property to see if the bean is partially loaded.
*/
public boolean isPartial() {
for (int i = 0; i < loadedProps.length; i++) {
if (!loadedProps[i]) {
for (boolean loadedProp : loadedProps) {
if (!loadedProp) {
return true;
}
}
@@ -263,7 +263,7 @@ public final class EntityBeanIntercept implements Serializable {
this.dirty = true;
setEmbeddedPropertyDirty(embeddedProperty);
}
public void setDirty(boolean dirty) {
this.dirty = dirty;
}
@@ -290,12 +290,12 @@ public final class EntityBeanIntercept implements Serializable {
if (i == idIndex) {
if (!loadedProps[i]) return false;
} else if (loadedProps[i]) {
return false;
return false;
}
}
return true;
}
/**
* Return true if the entity is a reference.
*/
@@ -312,7 +312,7 @@ public final class EntityBeanIntercept implements Serializable {
// For cases where properties are set on constructor
// set every non Id property to unloaded (for lazy loading)
for (int i=0; i< loadedProps.length; i++) {
if (i != idPos) {
if (i != idPos) {
loadedProps[i] = false;
}
}
@@ -448,7 +448,7 @@ public final class EntityBeanIntercept implements Serializable {
}
return origValues[propertyIndex];
}
/**
* Finds the index position of a given property. Returns -1 if the property
* can not be found.
@@ -462,7 +462,7 @@ public final class EntityBeanIntercept implements Serializable {
}
return -1;
}
/**
* Return the property name for the given property.
*/
@@ -472,7 +472,7 @@ public final class EntityBeanIntercept implements Serializable {
}
return owner._ebean_getPropertyName(propertyIndex);
}
/**
* Return the number of properties.s
*/
@@ -498,7 +498,7 @@ public final class EntityBeanIntercept implements Serializable {
public void setPropertyUnloaded(int propertyIndex) {
loadedProps[propertyIndex] = false;
}
/**
* Set the property to be loaded.
*/
@@ -525,7 +525,7 @@ public final class EntityBeanIntercept implements Serializable {
* embedded properties is dirty.
*/
public boolean isDirtyProperty(int propertyIndex) {
return (changedProps != null && changedProps[propertyIndex]
return (changedProps != null && changedProps[propertyIndex]
|| embeddedDirty != null && embeddedDirty[propertyIndex]);
}
@@ -536,7 +536,7 @@ public final class EntityBeanIntercept implements Serializable {
setChangedProperty(propertyIndex);
setDirty(true);
}
public void setChangedProperty(int propertyIndex) {
if (changedProps == null) {
changedProps = new boolean[owner._ebean_getPropertyNames().length];
@@ -553,7 +553,7 @@ public final class EntityBeanIntercept implements Serializable {
}
embeddedDirty[propertyIndex] = true;
}
private void setOriginalValue(int propertyIndex, Object value) {
if (origValues == null) {
origValues = new Object[owner._ebean_getPropertyNames().length];
@@ -567,19 +567,19 @@ public final class EntityBeanIntercept implements Serializable {
* For forced update on a 'New' bean set all the loaded properties to changed.
*/
public void setNewBeanForUpdate() {
if (changedProps == null) {
changedProps = new boolean[owner._ebean_getPropertyNames().length];
}
for (int i=0; i< loadedProps.length; i++) {
if (loadedProps[i]) {
changedProps[i] = true;
changedProps[i] = true;
}
}
setDirty(true);
}
/**
* Return the set of property names for a partially loaded bean.
*/
@@ -587,7 +587,7 @@ public final class EntityBeanIntercept implements Serializable {
if (fullyLoadedBean) {
return null;
}
Set<String> props = new LinkedHashSet<String>();
Set<String> props = new LinkedHashSet<>();
for (int i=0; i<loadedProps.length; i++) {
if (loadedProps[i]) {
props.add(getProperty(i));
@@ -617,11 +617,11 @@ public final class EntityBeanIntercept implements Serializable {
* Return the set of dirty properties.
*/
public Set<String> getDirtyPropertyNames() {
Set<String> props = new LinkedHashSet<String>();
Set<String> props = new LinkedHashSet<>();
addDirtyPropertyNames(props, null);
return props;
}
/**
* Recursively add dirty properties.
*/
@@ -666,11 +666,11 @@ public final class EntityBeanIntercept implements Serializable {
* Return a map of dirty properties with their new and old values.
*/
public Map<String,ValuePair> getDirtyValues() {
Map<String,ValuePair> dirtyValues = new LinkedHashMap<String, ValuePair>();
Map<String,ValuePair> dirtyValues = new LinkedHashMap<>();
addDirtyPropertyValues(dirtyValues, null);
return dirtyValues;
}
/**
* Recursively add dirty properties.
*/
@@ -684,7 +684,7 @@ public final class EntityBeanIntercept implements Serializable {
Object oldVal = getOrigValue(i);
dirtyValues.put(propName, new ValuePair(newVal, oldVal));
} else if (embeddedDirty != null && embeddedDirty[i]) {
// an embedded property has been changed - recurse
EntityBean embeddedBean = (EntityBean)owner._ebean_getField(i);
@@ -692,14 +692,14 @@ public final class EntityBeanIntercept implements Serializable {
}
}
}
/**
* Return a dirty property hash taking into account embedded beans.
*/
public int getDirtyPropertyHash() {
return addDirtyPropertyHash(37);
}
/**
* Add and return a dirty property hash recursing into embedded beans.
*/
@@ -749,7 +749,7 @@ public final class EntityBeanIntercept implements Serializable {
public int getLazyLoadPropertyIndex() {
return lazyLoadProperty;
}
/**
* Return the property that triggered the lazy load.
*/
@@ -849,7 +849,7 @@ public final class EntityBeanIntercept implements Serializable {
}
return obj1.equals(obj2);
}
/**
* Called when a BeanCollection is initialised automatically.
*/
@@ -920,7 +920,7 @@ public final class EntityBeanIntercept implements Serializable {
if (readOnly) {
throw new IllegalStateException("This bean is readOnly");
}
setLoadedProperty(propertyIndex);
// Bean itself not considered dirty when many changed
@@ -930,7 +930,7 @@ public final class EntityBeanIntercept implements Serializable {
return null;
}
}
private void setChangedPropertyValue(int propertyIndex, boolean setDirtyState, Object origValue) {
if (readOnly) {
@@ -941,7 +941,7 @@ public final class EntityBeanIntercept implements Serializable {
if (setDirtyState) {
setOriginalValue(propertyIndex, origValue);
if (!dirty) {
dirty = true;
dirty = true;
if (embeddedOwner != null) {
// Cascade dirty state from Embedded bean to parent bean
embeddedOwner._ebean_getIntercept().setEmbeddedDirty(embeddedOwnerIndex);
@@ -952,7 +952,7 @@ public final class EntityBeanIntercept implements Serializable {
}
}
}
/**
* Check to see if the values are not equal. If they are not equal then create
* the old values for use with ConcurrencyMode.ALL.
@@ -962,15 +962,15 @@ public final class EntityBeanIntercept implements Serializable {
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else if (!areEqual(oldValue, newValue)) {
setChangedPropertyValue(propertyIndex, intercept, oldValue);
setChangedPropertyValue(propertyIndex, intercept, oldValue);
} else {
return null;
}
return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue);
return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue);
}
/**
* Check for primitive boolean.
*/
@@ -1007,13 +1007,13 @@ public final class EntityBeanIntercept implements Serializable {
public PropertyChangeEvent preSetter(boolean intercept, int propertyIndex, long oldValue, long newValue) {
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
setLoadedProperty(propertyIndex);
} else if (oldValue != newValue) {
setChangedPropertyValue(propertyIndex, intercept, oldValue);
} else {
return null;
}
return (pcs == null) ? null : new PropertyChangeEvent(owner, getProperty(propertyIndex), oldValue, newValue);
}
@@ -1025,7 +1025,7 @@ public final class EntityBeanIntercept implements Serializable {
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else if (oldValue != newValue) {
setChangedPropertyValue(propertyIndex, intercept, oldValue);
setChangedPropertyValue(propertyIndex, intercept, oldValue);
} else {
return null;
}
@@ -29,7 +29,7 @@ public final class NodeUsageCollector {
/**
* The properties used at this profile point.
*/
private final Set<String> used = new LinkedHashSet<String>();
private final Set<String> used = new LinkedHashSet<>();
/**
* set to true if the bean is modified (setter called)
@@ -159,7 +159,7 @@ public abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
protected ModifyHolder<E> getModifyHolder() {
if (modifyHolder == null) {
modifyHolder = new ModifyHolder<E>();
modifyHolder = new ModifyHolder<>();
}
return modifyHolder;
}
@@ -37,7 +37,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
* Uses an ArrayList as the underlying List implementation.
*/
public BeanList() {
this(new ArrayList<E>());
this(new ArrayList<>());
}
/**
@@ -68,7 +68,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
@SuppressWarnings("unchecked")
public void loadFrom(BeanCollection<?> other) {
if (list == null) {
list = new ArrayList<E>();
list = new ArrayList<>();
}
list.addAll((Collection<? extends E>) other.getActualDetails());
}
@@ -76,7 +76,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
@SuppressWarnings("unchecked")
public void internalAdd(Object bean) {
if (list == null) {
list = new ArrayList<E>();
list = new ArrayList<>();
}
if (bean != null) {
list.add((E) bean);
@@ -92,7 +92,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
public boolean checkEmptyLazyLoad() {
if (list == null) {
list = new ArrayList<E>();
list = new ArrayList<>();
return true;
} else {
return false;
@@ -105,7 +105,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
if (!disableLazyLoad && modifyListening) {
lazyLoadCollection(true);
} else {
list = new ArrayList<E>();
list = new ArrayList<>();
}
}
}
@@ -115,7 +115,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
synchronized (this) {
if (list == null) {
if (disableLazyLoad) {
list = new ArrayList<E>();
list = new ArrayList<>();
} else {
lazyLoadCollection(false);
}
@@ -261,8 +261,8 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
// and fetch just the Id's
initClear();
if (modifyRemoveListening) {
for (int i = 0; i < list.size(); i++) {
getModifyHolder().modifyRemoval(list.get(i));
for (E aList : list) {
getModifyHolder().modifyRemoval(aList);
}
}
list.clear();
@@ -296,11 +296,11 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
public Iterator<E> iterator() {
init();
if (isReadOnly()) {
return new ReadOnlyListIterator<E>(list.listIterator());
return new ReadOnlyListIterator<>(list.listIterator());
}
if (modifyListening) {
Iterator<E> it = list.iterator();
return new ModifyIterator<E>(this, it);
return new ModifyIterator<>(this, it);
}
return list.iterator();
}
@@ -313,11 +313,11 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
public ListIterator<E> listIterator() {
init();
if (isReadOnly()) {
return new ReadOnlyListIterator<E>(list.listIterator());
return new ReadOnlyListIterator<>(list.listIterator());
}
if (modifyListening) {
ListIterator<E> it = list.listIterator();
return new ModifyListIterator<E>(this, it);
return new ModifyListIterator<>(this, it);
}
return list.listIterator();
}
@@ -325,11 +325,11 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
public ListIterator<E> listIterator(int index) {
init();
if (isReadOnly()) {
return new ReadOnlyListIterator<E>(list.listIterator(index));
return new ReadOnlyListIterator<>(list.listIterator(index));
}
if (modifyListening) {
ListIterator<E> it = list.listIterator(index);
return new ModifyListIterator<E>(this, it);
return new ModifyListIterator<>(this, it);
}
return list.listIterator(index);
}
@@ -425,7 +425,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
return Collections.unmodifiableList(list.subList(fromIndex, toIndex));
}
if (modifyListening) {
return new ModifyList<E>(this, list.subList(fromIndex, toIndex));
return new ModifyList<>(this, list.subList(fromIndex, toIndex));
}
return list.subList(fromIndex, toIndex);
}
@@ -33,7 +33,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
* Create using a underlying LinkedHashMap.
*/
public BeanMap() {
this(new LinkedHashMap<K, E>());
this(new LinkedHashMap<>());
}
public BeanMap(BeanCollectionLoader ebeanServer, EntityBean ownerBean, String propertyName) {
@@ -61,14 +61,14 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
public void internalPutNull() {
if (map == null) {
map = new LinkedHashMap<K, E>();
map = new LinkedHashMap<>();
}
}
@SuppressWarnings("unchecked")
public void internalPut(Object key, Object bean) {
if (map == null) {
map = new LinkedHashMap<K, E>();
map = new LinkedHashMap<>();
}
if (key != null) {
map.put((K) key, (E) bean);
@@ -108,7 +108,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
public boolean checkEmptyLazyLoad() {
if (map == null) {
map = new LinkedHashMap<K, E>();
map = new LinkedHashMap<>();
return true;
} else {
return false;
@@ -121,7 +121,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
if (modifyListening) {
lazyLoadCollection(true);
} else {
map = new LinkedHashMap<K, E>();
map = new LinkedHashMap<>();
}
}
}
@@ -265,7 +265,6 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
return map.put(key, value);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public void putAll(Map<? extends K, ? extends E> puts) {
checkReadOnly();
init();
@@ -314,7 +313,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
}
if (modifyListening) {
Collection<E> c = map.values();
return new ModifyCollection<E>(this, c);
return new ModifyCollection<>(this, c);
}
return map.values();
}
@@ -34,7 +34,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
* Create using an underlying LinkedHashSet.
*/
public BeanSet() {
this(new LinkedHashSet<E>());
this(new LinkedHashSet<>());
}
public BeanSet(BeanCollectionLoader loader, EntityBean ownerBean, String propertyName) {
@@ -61,7 +61,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
@SuppressWarnings("unchecked")
public void loadFrom(BeanCollection<?> other) {
if (set == null) {
set = new LinkedHashSet<E>();
set = new LinkedHashSet<>();
}
set.addAll((Collection<? extends E>) other.getActualDetails());
}
@@ -76,7 +76,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
@SuppressWarnings("unchecked")
public void internalAdd(Object bean) {
if (set == null) {
set = new LinkedHashSet<E>();
set = new LinkedHashSet<>();
}
if (bean != null) {
set.add((E) bean);
@@ -100,7 +100,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
public boolean checkEmptyLazyLoad() {
if (set == null) {
set = new LinkedHashSet<E>();
set = new LinkedHashSet<>();
return true;
} else {
return false;
@@ -113,7 +113,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
if (modifyListening) {
lazyLoadCollection(true);
} else {
set = new LinkedHashSet<E>();
set = new LinkedHashSet<>();
}
}
}
@@ -256,10 +256,10 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
public Iterator<E> iterator() {
init();
if (isReadOnly()) {
return new ReadOnlyIterator<E>(set.iterator());
return new ReadOnlyIterator<>(set.iterator());
}
if (modifyListening) {
return new ModifyIterator<E>(this, set.iterator());
return new ModifyIterator<>(this, set.iterator());
}
return set.iterator();
}
@@ -72,7 +72,7 @@ class ModifyCollection<E> implements Collection<E> {
@Override
public Iterator<E> iterator() {
Iterator<E> it = c.iterator();
return new ModifyIterator<E>(owner, it);
return new ModifyIterator<>(owner, it);
}
@Override
@@ -21,16 +21,16 @@ class ModifyHolder<E> implements Serializable {
/**
* Deletions list for manyToMany persistence.
*/
private Set<E> modifyDeletions = new LinkedHashSet<E>();
private Set<E> modifyDeletions = new LinkedHashSet<>();
/**
* Additions list for manyToMany persistence.
*/
private Set<E> modifyAdditions = new LinkedHashSet<E>();
private Set<E> modifyAdditions = new LinkedHashSet<>();
void reset() {
modifyDeletions = new LinkedHashSet<E>();
modifyAdditions = new LinkedHashSet<E>();
modifyDeletions = new LinkedHashSet<>();
modifyAdditions = new LinkedHashSet<>();
}
/**
@@ -61,11 +61,11 @@ class ModifyList<E> extends ModifyCollection<E> implements List<E> {
}
public ListIterator<E> listIterator() {
return new ModifyListIterator<E>(owner, list.listIterator());
return new ModifyListIterator<>(owner, list.listIterator());
}
public ListIterator<E> listIterator(int index) {
return new ModifyListIterator<E>(owner, list.listIterator(index));
return new ModifyListIterator<>(owner, list.listIterator(index));
}
public E remove(int index) {
@@ -82,7 +82,7 @@ class ModifyList<E> extends ModifyCollection<E> implements List<E> {
}
public List<E> subList(int fromIndex, int toIndex) {
return new ModifyList<E>(owner, list.subList(fromIndex, toIndex));
return new ModifyList<>(owner, list.subList(fromIndex, toIndex));
}
}
@@ -78,8 +78,8 @@ public class DbConstraintNormalise {
public boolean notQuoted(String tableName) {
// remove quoted identifier characters
for (int i = 0; i < quotedIdentifiers.length; i++) {
if (tableName.contains(quotedIdentifiers[i])) {
for (String quotedIdentifier : quotedIdentifiers) {
if (tableName.contains(quotedIdentifier)) {
return false;
}
}
@@ -95,8 +95,8 @@ public class DbConstraintNormalise {
return "";
}
// remove quoted identifier characters
for (int i = 0; i < quotedIdentifiers.length; i++) {
tableName = tableName.replace(quotedIdentifiers[i], "");
for (String quotedIdentifier : quotedIdentifiers) {
tableName = tableName.replace(quotedIdentifier, "");
}
return tableName;
}
@@ -0,0 +1,123 @@
package com.avaje.ebean.config;
import com.avaje.ebean.config.dbplatform.DbType;
import com.avaje.ebean.config.dbplatform.IdType;
import java.util.ArrayList;
import java.util.List;
/**
* Configuration for DB types such as UUID, Geometry etc.
*/
public class DbTypeConfig {
/**
* The Geometry SRID value (default 4326).
*/
private int geometrySRID = 4326;
/**
* Set for DB's that support both Sequence and Identity (and the default choice is not desired).
*/
private IdType idType;
/**
* Setting to indicate if UUID should be stored as binary(16) or varchar(40) or native DB type (for H2 and Postgres).
*/
private ServerConfig.DbUuid dbUuid = ServerConfig.DbUuid.AUTO_VARCHAR;
/**
* Modify the default mapping of standard types such as default precision for DECIMAL etc.
*/
private List<CustomDbTypeMapping> customDbTypeMappings = new ArrayList<>();
/**
* Return the Geometry SRID.
*/
public int getGeometrySRID() {
return geometrySRID;
}
/**
* Set the Geometry SRID.
*/
public void setGeometrySRID(int geometrySRID) {
this.geometrySRID = geometrySRID;
}
/**
* Return the DB type used to store UUID.
*/
public ServerConfig.DbUuid getDbUuid() {
return dbUuid;
}
/**
* Set the DB type used to store UUID.
*/
public void setDbUuid(ServerConfig.DbUuid dbUuid) {
this.dbUuid = dbUuid;
}
/**
* Return the IdType to use (or null for the default choice).
*/
public IdType getIdType() {
return idType;
}
/**
* Set the IdType to use (when the DB supports both SEQUENCE and IDENTITY and the default is not desired).
*/
public void setIdType(IdType idType) {
this.idType = idType;
}
/**
* Add a custom type mapping.
* <p>
* <pre>{@code
*
* // set the default mapping for BigDecimal.class/decimal
* serverConfig.addCustomMapping(DbType.DECIMAL, "decimal(18,6)");
*
* // set the default mapping for String.class/varchar but only for Postgres
* serverConfig.addCustomMapping(DbType.VARCHAR, "text", Platform.POSTGRES);
*
* }</pre>
*
* @param type The DB type this mapping should apply to
* @param columnDefinition The column definition that should be used
* @param platform Optionally specify the platform this mapping should apply to.
*/
public void addCustomMapping(DbType type, String columnDefinition, Platform platform) {
customDbTypeMappings.add(new CustomDbTypeMapping(type, columnDefinition, platform));
}
/**
* Add a custom type mapping that applies to all platforms.
* <p>
* <pre>{@code
*
* // set the default mapping for BigDecimal/decimal
* serverConfig.addCustomMapping(DbType.DECIMAL, "decimal(18,6)");
*
* // set the default mapping for String/varchar
* serverConfig.addCustomMapping(DbType.VARCHAR, "text");
*
* }</pre>
*
* @param type The DB type this mapping should apply to
* @param columnDefinition The column definition that should be used
*/
public void addCustomMapping(DbType type, String columnDefinition) {
customDbTypeMappings.add(new CustomDbTypeMapping(type, columnDefinition));
}
/**
* Return the list of custom type mappings.
*/
public List<CustomDbTypeMapping> getCustomTypeMappings() {
return customDbTypeMappings;
}
}
@@ -16,7 +16,7 @@ public final class PropertyMap implements Serializable {
private static final long serialVersionUID = 1L;
private final LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
private final LinkedHashMap<String, String> map = new LinkedHashMap<>();
/**
* Return properties loaded from test-ebean.properties.
@@ -77,16 +77,20 @@ public class ServerConfig {
*/
private String name = "db";
/**
* When false (default) H2 automatically uses DDL generate and run
* (i.e. assumes we are running tests using in memory h2).
*/
private boolean h2ProductionMode;
/**
* Typically configuration type objects that are passed by this ServerConfig
* to plugins. For example - IgniteConfiguration passed to Ignite plugin.
*/
private Map<String, Object> serviceObject = new HashMap<String, Object>();
private Map<String, Object> serviceObject = new HashMap<>();
private ContainerConfig containerConfig;
private List<CustomDbTypeMapping> customDbTypeMappings = new ArrayList<CustomDbTypeMapping>();
/**
* The underlying properties that were used during configuration.
*/
@@ -112,22 +116,17 @@ public class ServerConfig {
*/
private boolean disableClasspathSearch;
/**
* The Geometry SRID value (default 4326).
*/
private int geometrySRID = 4326;
/**
* List of interesting classes such as entities, embedded, ScalarTypes,
* Listeners, Finders, Controllers etc.
*/
private List<Class<?>> classes = new ArrayList<Class<?>>();
private List<Class<?>> classes = new ArrayList<>();
/**
* The packages that are searched for interesting classes. Only used when
* classes is empty/not explicitly specified.
*/
private List<String> packages = new ArrayList<String>();
private List<String> packages = new ArrayList<>();
/**
* Configuration for the ElasticSearch integration.
@@ -326,20 +325,19 @@ public class ServerConfig {
private boolean updatesDeleteMissingChildren = true;
/**
* Setting to indicate if UUID should be stored as binary(16) or varchar(40) or native DB type (for H2 and Postgres).
* Database type configuration.
*/
private DbUuid dbUuid = DbUuid.AUTO_VARCHAR;
private DbTypeConfig dbTypeConfig = new DbTypeConfig();
private List<IdGenerator> idGenerators = new ArrayList<IdGenerator>();
private List<BeanFindController> findControllers = new ArrayList<BeanFindController>();
private List<BeanPersistController> persistControllers = new ArrayList<BeanPersistController>();
private List<BeanPostLoad> postLoaders = new ArrayList<BeanPostLoad>();
private List<BeanPostConstructListener> postConstructListeners = new ArrayList<BeanPostConstructListener>();
private List<BeanPersistListener> persistListeners = new ArrayList<BeanPersistListener>();
private List<BeanQueryAdapter> queryAdapters = new ArrayList<BeanQueryAdapter>();
private List<BulkTableEventListener> bulkTableEventListeners = new ArrayList<BulkTableEventListener>();
private List<ServerConfigStartup> configStartupListeners = new ArrayList<ServerConfigStartup>();
private List<IdGenerator> idGenerators = new ArrayList<>();
private List<BeanFindController> findControllers = new ArrayList<>();
private List<BeanPersistController> persistControllers = new ArrayList<>();
private List<BeanPostLoad> postLoaders = new ArrayList<>();
private List<BeanPostConstructListener> postConstructListeners = new ArrayList<>();
private List<BeanPersistListener> persistListeners = new ArrayList<>();
private List<BeanQueryAdapter> queryAdapters = new ArrayList<>();
private List<BulkTableEventListener> bulkTableEventListeners = new ArrayList<>();
private List<ServerConfigStartup> configStartupListeners = new ArrayList<>();
/**
* By default inserts are included in the change log.
@@ -509,6 +507,27 @@ public class ServerConfig {
this.name = name;
}
/**
* Return true if H2 should be used in production mode.
* <p>
* Otherwise it is assumed we are using H2 for testing and DDL generate and run is turned on.
* </p>
*/
public boolean isH2ProductionMode() {
return h2ProductionMode;
}
/**
* Set to true for H2 to be used in production mode.
* <p>
* Do this when we want to use H2 and not have the DDL generation and run automatically turned on.
* Otherwise it is assumed we are using H2 for testing purposes.
* </p>
*/
public void setH2ProductionMode(boolean h2ProductionMode) {
this.h2ProductionMode = h2ProductionMode;
}
/**
* Return the container / clustering configuration.
* <p/>
@@ -885,14 +904,14 @@ public class ServerConfig {
* Return the Geometry SRID.
*/
public int getGeometrySRID() {
return geometrySRID;
return dbTypeConfig.getGeometrySRID();
}
/**
* Set the Geometry SRID.
*/
public void setGeometrySRID(int geometrySRID) {
this.geometrySRID = geometrySRID;
dbTypeConfig.setGeometrySRID(geometrySRID);
}
/**
@@ -1444,6 +1463,11 @@ public class ServerConfig {
*/
public void setDatabasePlatform(DatabasePlatform databasePlatform) {
this.databasePlatform = databasePlatform;
if (!h2ProductionMode && databasePlatform != null && databasePlatform.isPlatform(Platform.H2)) {
// we are using H2 to run tests so turn on DDL generation and run
this.ddlGenerate = true;
this.ddlRun = true;
}
}
/**
@@ -1536,17 +1560,17 @@ public class ServerConfig {
}
/**
* Return the DB type used to store UUID.
* Return the configuration for DB types (such as UUID and custom mappings).
*/
public DbUuid getDbUuid() {
return dbUuid;
public DbTypeConfig getDbTypeConfig() {
return dbTypeConfig;
}
/**
* Set the DB type used to store UUID.
*/
public void setDbUuid(DbUuid dbUuid) {
this.dbUuid = dbUuid;
this.dbTypeConfig.setDbUuid(dbUuid);
}
/**
@@ -1726,7 +1750,7 @@ public class ServerConfig {
*/
public void addClass(Class<?> cls) {
if (classes == null) {
classes = new ArrayList<Class<?>>();
classes = new ArrayList<>();
}
classes.add(cls);
}
@@ -1739,7 +1763,7 @@ public class ServerConfig {
*/
public void addPackage(String packageName) {
if (packages == null) {
packages = new ArrayList<String>();
packages = new ArrayList<>();
}
packages.add(packageName);
}
@@ -1974,7 +1998,7 @@ public class ServerConfig {
* @param platform Optionally specify the platform this mapping should apply to.
*/
public void addCustomMapping(DbType type, String columnDefinition, Platform platform) {
customDbTypeMappings.add(new CustomDbTypeMapping(type, columnDefinition, platform));
dbTypeConfig.addCustomMapping(type, columnDefinition, platform);
}
/**
@@ -1994,14 +2018,7 @@ public class ServerConfig {
* @param columnDefinition The column definition that should be used
*/
public void addCustomMapping(DbType type, String columnDefinition) {
customDbTypeMappings.add(new CustomDbTypeMapping(type, columnDefinition));
}
/**
* Return the list of custom type mappings.
*/
public List<CustomDbTypeMapping> getCustomTypeMappings() {
return customDbTypeMappings;
dbTypeConfig.addCustomMapping(type, columnDefinition);
}
/**
@@ -2085,7 +2102,7 @@ public class ServerConfig {
*/
public void add(BeanPostConstructListener listener) {
postConstructListeners.add(listener);
}
}
/**
* Return the list of BeanFindController instances.
*/
@@ -2311,7 +2328,6 @@ public class ServerConfig {
* @param key properties key
* @param instance existing instance
*/
@SuppressWarnings("unchecked")
protected <T> T createInstance(PropertiesWrapper properties, Class<T> pluginType, String key, T instance) {
if (instance != null) {
@@ -2327,6 +2343,7 @@ public class ServerConfig {
* @param pluginType the type of plugin
* @param classname the implementation class as per properties
*/
@SuppressWarnings("unchecked")
protected <T> T createInstance(Class<T> pluginType, String classname) {
return classname == null ? null : (T) classLoadConfig.newInstance(classname);
}
@@ -2382,7 +2399,11 @@ public class ServerConfig {
}
loadDocStoreSettings(p);
geometrySRID = p.getInt("geometrySRID", geometrySRID);
int srid = p.getInt("geometrySRID", 0);
if (srid > 0) {
dbTypeConfig.setGeometrySRID(srid);
}
disableL2Cache = p.getBoolean("disableL2Cache", disableL2Cache);
explicitTransactionBeginMode = p.getBoolean("explicitTransactionBeginMode", explicitTransactionBeginMode);
autoCommitMode = p.getBoolean("autoCommitMode", autoCommitMode);
@@ -2442,9 +2463,13 @@ public class ServerConfig {
databaseBooleanTrue = p.get("databaseBooleanTrue", databaseBooleanTrue);
databaseBooleanFalse = p.get("databaseBooleanFalse", databaseBooleanFalse);
databasePlatformName = p.get("databasePlatformName", databasePlatformName);
dbUuid = p.getEnum(DbUuid.class, "dbuuid", dbUuid);
DbUuid dbUuid = p.getEnum(DbUuid.class, "dbuuid", null);
if (dbUuid != null) {
dbTypeConfig.setDbUuid(dbUuid);
}
if (p.getBoolean("uuidStoreAsBinary", false)) {
dbUuid = DbUuid.BINARY;
dbTypeConfig.setDbUuid(DbUuid.BINARY);
}
localTimeWithNanos = p.getBoolean("localTimeWithNanos", localTimeWithNanos);
jodaLocalTimeMode = p.get("jodaLocalTimeMode", jodaLocalTimeMode);
@@ -2460,6 +2485,7 @@ public class ServerConfig {
jsonDateTime = JsonConfig.DateTime.MILLIS;
}
h2ProductionMode = p.getBoolean("h2ProductionMode", h2ProductionMode);
ddlGenerate = p.getBoolean("ddl.generate", ddlGenerate);
ddlRun = p.getBoolean("ddl.run", ddlRun);
ddlCreateOnly = p.getBoolean("ddl.createOnly", ddlCreateOnly);
@@ -2488,11 +2514,11 @@ public class ServerConfig {
return classes;
}
List<Class<?>> classes = new ArrayList<Class<?>>();
List<Class<?>> classes = new ArrayList<>();
String[] split = classNames.split("[ ,;]");
for (int i = 0; i < split.length; i++) {
String cn = split[i].trim();
for (String aSplit : split) {
String cn = aSplit.trim();
if (!cn.isEmpty() && !"class".equalsIgnoreCase(cn)) {
try {
classes.add(Class.forName(cn));
@@ -2507,13 +2533,13 @@ public class ServerConfig {
private List<String> getSearchJarsPackages(String searchPackages) {
List<String> hitList = new ArrayList<String>();
List<String> hitList = new ArrayList<>();
if (searchPackages != null) {
String[] entries = searchPackages.split("[ ,;]");
for (int i = 0; i < entries.length; i++) {
hitList.add(entries[i].trim());
for (String entry : entries) {
hitList.add(entry.trim());
}
}
return hitList;
@@ -3,6 +3,7 @@ package com.avaje.ebean.config.dbplatform;
import com.avaje.ebean.BackgroundExecutor;
import com.avaje.ebean.Query;
import com.avaje.ebean.config.CustomDbTypeMapping;
import com.avaje.ebean.config.DbTypeConfig;
import com.avaje.ebean.config.PersistBatch;
import com.avaje.ebean.config.Platform;
import com.avaje.ebean.config.ServerConfig;
@@ -180,15 +181,27 @@ public class DatabasePlatform {
/**
* Configure UUID Storage etc based on ServerConfig settings.
*/
public void configure(ServerConfig serverConfig) {
dbTypeMap.config(nativeUuidType, serverConfig.getDbUuid());
for (CustomDbTypeMapping mapping : serverConfig.getCustomTypeMappings()) {
public void configure(DbTypeConfig config) {
addGeoTypes(config.getGeometrySRID());
configureIdType(config.getIdType());
dbTypeMap.config(nativeUuidType, config.getDbUuid());
for (CustomDbTypeMapping mapping : config.getCustomTypeMappings()) {
if (platformMatch(mapping.getPlatform())) {
dbTypeMap.put(mapping.getType(), parse(mapping.getColumnDefinition()));
}
}
}
protected void configureIdType(IdType idType) {
if (idType != null) {
this.dbIdentity.setIdType(idType);
}
}
protected void addGeoTypes(int srid) {
// default has no geo type support
}
private DbPlatformType parse(String columnDefinition) {
return DbPlatformType.parse(columnDefinition);
}
@@ -197,6 +210,13 @@ public class DatabasePlatform {
return platform == null || platform.name().equalsIgnoreCase(name);
}
/**
* Return true if this matches the given platform.
*/
public boolean isPlatform(Platform platform) {
return platform.name().equalsIgnoreCase(name);
}
/**
* Return the name of the DatabasePlatform.
* <p>
@@ -23,7 +23,7 @@ public class DbDefaultValue {
*/
public static final String NOW = "now";
protected Map<String,String> map = new LinkedHashMap<String,String>();
protected Map<String,String> map = new LinkedHashMap<>();
/**
* Set the DB now function.
@@ -135,9 +135,9 @@ public class DbIdentity {
return supportsSequence ? IdType.SEQUENCE : idType;
case IDENTITY:
return supportsIdentity ? IdType.IDENTITY : idType;
default:
return idType;
}
// use the default
return idType;
}
}
@@ -11,12 +11,12 @@ class DbPlatformTypeLookup {
/**
* A map to lookup the type by name.
*/
private Map<String, DbType> nameLookup = new HashMap<String, DbType>();
private Map<String, DbType> nameLookup = new HashMap<>();
/**
* A map to lookup the type by JDBC int value.
*/
private Map<Integer, DbType> idLookup = new HashMap<Integer, DbType>();
private Map<Integer, DbType> idLookup = new HashMap<>();
DbPlatformTypeLookup() {
addAll();
@@ -2,7 +2,6 @@ package com.avaje.ebean.config.dbplatform;
import com.avaje.ebean.config.ServerConfig;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;
@@ -26,7 +25,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<DbType, DbPlatformType>();
private final Map<DbType, DbPlatformType> typeMap = new HashMap<>();
/**
* Return the DbTypeMap with standard (not platform specific) types.
@@ -104,7 +103,8 @@ public class DbPlatformTypeMapping {
put(DbType.JSONCLOB, JSON_CLOB_PLACEHOLDER);
put(DbType.JSONBLOB, JSON_BLOB_PLACEHOLDER);
put(DbType.JSONVARCHAR, JSON_VARCHAR_PLACEHOLDER);
put(DbType.UUID, UUID_PLACEHOLDER);
// use reasonable default of varchar(40) - ideally set via DatabasePlatform.configure(DbTypeConfig)
put(DbType.UUID, get(DbType.VARCHAR).withLength(40));
}
}
@@ -30,20 +30,7 @@ public class H2Platform extends DatabasePlatform {
// escape clause for now noting that backslash is an escape char for like in H2
this.likeClause = "like ?";
// H2 data types match default JDBC types
// so no changes to dbTypeMap required
}
@Override
public void configure(ServerConfig serverConfig) {
super.configure(serverConfig);
Properties properties = serverConfig.getProperties();
if (properties != null) {
String idType = properties.getProperty("ebean.h2.idtype");
if (idType != null) {
this.dbIdentity.setIdType(IdType.valueOf(idType));
}
}
dbTypeMap.put(DbType.UUID, new DbPlatformType("uuid", false));
}
/**
@@ -7,7 +7,6 @@ import com.avaje.ebean.dbmigration.ddlgeneration.platform.PostgresDdl;
import javax.sql.DataSource;
import java.sql.Types;
import java.util.Properties;
/**
* Postgres v9 specific platform.
@@ -44,6 +43,7 @@ public class PostgresPlatform extends DatabasePlatform {
DbPlatformType dbTypeText = new DbPlatformType("text");
DbPlatformType dbBytea = new DbPlatformType("bytea", false);
dbTypeMap.put(DbType.UUID, new DbPlatformType("uuid", false));
dbTypeMap.put(DbType.HSTORE, new DbPlatformType("hstore", false));
dbTypeMap.put(DbType.JSON, new DbPlatformType("json", false));
dbTypeMap.put(DbType.JSONB, new DbPlatformType("jsonb", false));
@@ -63,21 +63,7 @@ public class PostgresPlatform extends DatabasePlatform {
dbTypeMap.put(DbType.LONGVARCHAR, dbTypeText);
}
@Override
public void configure(ServerConfig serverConfig) {
super.configure(serverConfig);
Properties properties = serverConfig.getProperties();
if (properties != null) {
String tsType = properties.getProperty("ebean.postgres.timestamp");
if (tsType != null) {
// set timestamp type to "timestamp" without time zone
dbTypeMap.put(DbType.TIMESTAMP, new DbPlatformType(tsType));
}
}
addGeoTypes(serverConfig.getGeometrySRID());
}
private void addGeoTypes(int srid) {
protected void addGeoTypes(int srid) {
dbTypeMap.put(DbType.POINT, geoType("point",srid));
dbTypeMap.put(DbType.POLYGON, geoType("polygon",srid));
dbTypeMap.put(DbType.LINESTRING, geoType("linestring",srid));
@@ -40,7 +40,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
protected final BackgroundExecutor backgroundExecutor;
protected final ArrayList<Long> idList = new ArrayList<Long>(50);
protected final ArrayList<Long> idList = new ArrayList<>(50);
protected final int batchSize;
@@ -98,11 +98,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
protected void loadLargeAllocation(final int allocateSize) {
// preAllocateIds was called with a relatively large batchSize
// so we will just go ahead and load those anyway in background
backgroundExecutor.execute(new Runnable() {
public void run() {
loadMoreIds(allocateSize, null);
}
});
backgroundExecutor.execute(() -> loadMoreIds(allocateSize, null));
}
/**
@@ -145,12 +141,10 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
currentlyBackgroundLoading = batchSize;
backgroundExecutor.execute(new Runnable() {
public void run() {
loadMoreIds(batchSize, null);
synchronized (backgroundLoadMonitor) {
currentlyBackgroundLoading = 0;
}
backgroundExecutor.execute(() -> {
loadMoreIds(batchSize, null);
synchronized (backgroundLoadMonitor) {
currentlyBackgroundLoading = 0;
}
});
}
@@ -165,8 +159,8 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
}
synchronized (monitor) {
for (int i = 0; i < newIds.size(); i++) {
idList.add(newIds.get(i));
for (Long newId : newIds) {
idList.add(newId);
}
}
}
@@ -178,7 +172,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
String sql = getSql(loadSize);
ArrayList<Long> newIds = new ArrayList<Long>(loadSize);
ArrayList<Long> newIds = new ArrayList<>(loadSize);
boolean useTxnConnection = t != null;
@@ -79,7 +79,7 @@ public class DbMigration {
protected DatabasePlatform databasePlatform;
protected List<Pair> platforms = new ArrayList<Pair>();
protected List<Pair> platforms = new ArrayList<>();
protected ServerConfig serverConfig;
@@ -53,7 +53,7 @@ public class BaseTableDdl implements TableDdl {
/**
* Used when unique constraints specifically for OneToOne can't be created normally (MsSqlServer).
*/
protected List<Column> externalUnique = new ArrayList<Column>();
protected List<Column> externalUnique = new ArrayList<>();
// counters used when constraint names are truncated due to maximum length
// and these counters are used to keep the constraint name unique
@@ -66,7 +66,7 @@ public class BaseTableDdl implements TableDdl {
* Base tables that have associated history tables that need their triggers/functions regenerated as
* columns have been added, removed, included or excluded.
*/
protected Map<String, HistoryTableUpdate> regenerateHistoryTriggers = new LinkedHashMap<String, HistoryTableUpdate>();
protected Map<String, HistoryTableUpdate> regenerateHistoryTriggers = new LinkedHashMap<>();
/**
* Construct with a naming convention and platform specific DDL.
@@ -499,7 +499,7 @@ public class BaseTableDdl implements TableDdl {
* Return the list of columns that make the primary key.
*/
protected List<Column> determinePrimaryKeyColumns(List<Column> columns) {
List<Column> pk = new ArrayList<Column>(3);
List<Column> pk = new ArrayList<>(3);
for (Column column : columns) {
if (isTrue(column.isPrimaryKey())) {
pk.add(column);
@@ -43,7 +43,7 @@ public class HistoryTableUpdate {
private final String baseTable;
private final List<Column> columnChanges = new ArrayList<Column>();
private final List<Column> columnChanges = new ArrayList<>();
/**
* Construct with a given base table name.
@@ -47,8 +47,8 @@ public class MsSqlServerDdl extends PlatformDdl {
sb.append(columns[i]);
}
sb.append(") where");
for (int i = 0; i < columns.length; i++) {
sb.append(" ").append(columns[i]).append(" is not null");
for (String column : columns) {
sb.append(" ").append(column).append(" is not null");
}
return sb.toString();
}
@@ -1,6 +1,7 @@
package com.avaje.ebean.dbmigration.ddlgeneration.platform.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@@ -8,7 +9,7 @@ import java.util.List;
*/
public class IndexColumns {
List<String> columns = new ArrayList<String>(4);
List<String> columns = new ArrayList<>(4);
/**
* Construct representing as a single column index.
@@ -21,9 +22,7 @@ public class IndexColumns {
* Construct representing index.
*/
public IndexColumns(String[] columnNames) {
for (int i = 0; i < columnNames.length; i++) {
columns.add(columnNames[i]);
}
Collections.addAll(columns, columnNames);
}
/**
@@ -11,7 +11,7 @@ import java.util.List;
*/
public class IndexSet {
private List<IndexColumns> indexes = new ArrayList<IndexColumns>();
private List<IndexColumns> indexes = new ArrayList<>();
/**
* Clear the indexes (for each table).
@@ -36,8 +36,8 @@ public class IndexSet {
*/
public boolean add(String[] columns) {
IndexColumns newIndex = new IndexColumns(columns);
for (int i = 0; i < indexes.size(); i++) {
if (indexes.get(i).isMatch(newIndex)) {
for (IndexColumns indexe : indexes) {
if (indexe.isMatch(newIndex)) {
return false;
}
}
@@ -70,7 +70,7 @@ public class AddColumn {
*/
public List<Column> getColumn() {
if (column == null) {
column = new ArrayList<Column>();
column = new ArrayList<>();
}
return this.column;
}
@@ -61,7 +61,7 @@ public class Applications {
*/
public List<Application> getApplication() {
if (application == null) {
application = new ArrayList<Application>();
application = new ArrayList<>();
}
return this.application;
}
@@ -113,7 +113,7 @@ public class ChangeSet {
*/
public List<Object> getChangeSetChildren() {
if (changeSetChildren == null) {
changeSetChildren = new ArrayList<Object>();
changeSetChildren = new ArrayList<>();
}
return this.changeSetChildren;
}
@@ -105,7 +105,7 @@ public class CreateTable {
*/
public List<Column> getColumn() {
if (column == null) {
column = new ArrayList<Column>();
column = new ArrayList<>();
}
return this.column;
}
@@ -134,7 +134,7 @@ public class CreateTable {
*/
public List<UniqueConstraint> getUniqueConstraint() {
if (uniqueConstraint == null) {
uniqueConstraint = new ArrayList<UniqueConstraint>();
uniqueConstraint = new ArrayList<>();
}
return this.uniqueConstraint;
}
@@ -163,7 +163,7 @@ public class CreateTable {
*/
public List<ForeignKey> getForeignKey() {
if (foreignKey == null) {
foreignKey = new ArrayList<ForeignKey>();
foreignKey = new ArrayList<>();
}
return this.foreignKey;
}
@@ -63,7 +63,7 @@ public class Migration {
*/
public List<ChangeSet> getChangeSet() {
if (changeSet == null) {
changeSet = new ArrayList<ChangeSet>();
changeSet = new ArrayList<>();
}
return this.changeSet;
}
@@ -16,8 +16,8 @@ import java.io.InputStream;
*/
public class MigrationXmlReader {
private static final MigrationXmlReader INSTANCE = new MigrationXmlReader();
private MigrationXmlReader() {}
/**
* Read and return a Migration from an xml document at the given resource path.
*/
@@ -28,7 +28,7 @@ public class MigrationXmlReader {
throw new IllegalArgumentException("No resource found for path [" + resourcePath + "]");
}
return INSTANCE.read(is);
return read(is);
}
/**
@@ -45,10 +45,7 @@ public class MigrationXmlWriter {
writer.close();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (JAXBException e) {
} catch (IOException | JAXBException e) {
throw new RuntimeException(e);
}
}
@@ -16,8 +16,8 @@ public class MCompoundForeignKey {
private String name;
private final String referenceTable;
private final List<String> columns = new ArrayList<String>();
private final List<String> referenceColumns = new ArrayList<String>();
private final List<String> columns = new ArrayList<>();
private final List<String> referenceColumns = new ArrayList<>();
private String indexName;
public MCompoundForeignKey(String name, String referenceTable, String indexName) {
@@ -4,6 +4,7 @@ import com.avaje.ebean.dbmigration.migration.CreateIndex;
import com.avaje.ebean.dbmigration.migration.DropIndex;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@@ -15,7 +16,7 @@ public class MIndex {
private String indexName;
private List<String> columns = new ArrayList<String>();
private List<String> columns = new ArrayList<>();
/**
* Create a single column non unique index.
@@ -32,9 +33,7 @@ public class MIndex {
public MIndex(String indexName, String tableName, String[] columnNames) {
this.tableName = tableName;
this.indexName = indexName;
for (int i = 0; i < columnNames.length; i++) {
this.columns.add(columnNames[i]);
}
Collections.addAll(this.columns, columnNames);
}
public MIndex(CreateIndex createIndex) {
@@ -101,7 +100,6 @@ public class MIndex {
* Return true if the index has changed.
*/
private boolean changed(MIndex newIndex) {
if (!tableName.equals(newIndex.getTableName())) {
return true;
}
@@ -119,12 +117,9 @@ public class MIndex {
private List<String> split(String columns) {
List<String> colList = new ArrayList<String>();
List<String> colList = new ArrayList<>();
String[] cols = columns.split(",");
for (int i = 0; i <cols.length; i++) {
colList.add(cols[i]);
}
Collections.addAll(colList, cols);
return colList;
}
@@ -99,17 +99,17 @@ public class MTable {
/**
* The columns on the table.
*/
private Map<String, MColumn> columns = new LinkedHashMap<String, MColumn>();
private Map<String, MColumn> columns = new LinkedHashMap<>();
/**
* Compound unique constraints.
*/
private List<MCompoundUniqueConstraint> uniqueConstraints = new ArrayList<MCompoundUniqueConstraint>();
private List<MCompoundUniqueConstraint> uniqueConstraints = new ArrayList<>();
/**
* Compound foreign keys.
*/
private List<MCompoundForeignKey> compoundKeys = new ArrayList<MCompoundForeignKey>();
private List<MCompoundForeignKey> compoundKeys = new ArrayList<>();
/**
* Column name for the 'When created' column. This can be used for the initial effective start date when adding
@@ -122,7 +122,7 @@ public class MTable {
*/
private AddColumn addColumn;
private List<String> droppedColumns = new ArrayList<String>();
private List<String> droppedColumns = new ArrayList<>();
/**
* Create a copy of this table structure as a 'draft' table.
@@ -369,7 +369,7 @@ public class MTable {
public List<String> allHistoryColumns(boolean includeDropped) {
List<String> columnNames = new ArrayList<String>(columns.size());
List<String> columnNames = new ArrayList<>(columns.size());
for (MColumn column : columns.values()) {
if (column.isIncludeInHistory()) {
columnNames.add(column.getName());
@@ -444,7 +444,7 @@ public class MTable {
* Return the list of columns that make the primary key.
*/
public List<MColumn> primaryKeyColumns() {
List<MColumn> pk = new ArrayList<MColumn>(3);
List<MColumn> pk = new ArrayList<>(3);
for (MColumn column : allColumns()) {
if (column.isPrimaryKey()) {
pk.add(column);
@@ -590,7 +590,7 @@ public class MTable {
* Return true if the foreign key names are not unique.
*/
private boolean hasDuplicateForeignKeys() {
Set<String> fkNames = new HashSet<String>();
Set<String> fkNames = new HashSet<>();
for (MCompoundForeignKey fk : compoundKeys) {
if (!fkNames.add(fk.getName())) {
return true;
@@ -42,14 +42,9 @@ public class MigrationModel {
private void readMigrations() {
// find all the migration xml files
File[] xmlFiles = modelDirectory.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.getName().toLowerCase().endsWith(modelSuffix);
}
});
File[] xmlFiles = modelDirectory.listFiles(pathname -> pathname.getName().toLowerCase().endsWith(modelSuffix));
List<MigrationResource> resources = new ArrayList<MigrationResource>();
List<MigrationResource> resources = new ArrayList<>();
for (File xmlFile: xmlFiles) {
resources.add(new MigrationResource(xmlFile, createVersion(xmlFile)));
@@ -28,12 +28,12 @@ public class ModelContainer {
/**
* All the tables in the model.
*/
private final Map<String, MTable> tables = new LinkedHashMap<String, MTable>();
private final Map<String, MTable> tables = new LinkedHashMap<>();
/**
* All the non unique non foreign key indexes.
*/
private final Map<String, MIndex> indexes = new LinkedHashMap<String, MIndex>();
private final Map<String, MIndex> indexes = new LinkedHashMap<>();
private final PendingDrops pendingDrops = new PendingDrops();
@@ -30,12 +30,12 @@ public class ModelDiff {
/**
* List of 'create' type changes.
*/
private final List<Object> applyChanges = new ArrayList<Object>();
private final List<Object> applyChanges = new ArrayList<>();
/**
* List of 'drop' type changes. Expected to be placed into a separate DDL script.
*/
private final List<Object> dropChanges = new ArrayList<Object>();
private final List<Object> dropChanges = new ArrayList<>();
/**
* Construct with a base model.
@@ -16,7 +16,7 @@ import java.util.List;
*/
public class PendingDrops {
private final LinkedHashMap<String, Entry> map = new LinkedHashMap<String, Entry>();
private final LinkedHashMap<String, Entry> map = new LinkedHashMap<>();
/**
* Add a 'pending drops' changeSet for the given version.
@@ -36,7 +36,7 @@ public class PendingDrops {
*/
public List<String> pendingDrops() {
List<String> versions = new ArrayList<String>();
List<String> versions = new ArrayList<>();
for (Entry value : map.values()) {
if (value.hasPendingDrops()) {
versions.add(value.version.asString());
@@ -143,7 +143,7 @@ public class PendingDrops {
final MigrationVersion version;
final List<ChangeSet> list = new ArrayList<ChangeSet>();
final List<ChangeSet> list = new ArrayList<>();
Entry(MigrationVersion version) {
this.version = version;
@@ -60,7 +60,7 @@ public class ModelBuildIntersectionTable {
intersectionTable.checkDuplicateForeignKeys();
}
private void buildFkConstraints(BeanDescriptor<?> desc, TableJoinColumn[] columns, boolean direction) {
String tableName = intersectionTableJoin.getTable();
@@ -71,11 +71,11 @@ public class ModelBuildIntersectionTable {
MCompoundForeignKey foreignKey = new MCompoundForeignKey(fkName, desc.getBaseTable(), fkIndex);
intersectionTable.addForeignKey(foreignKey);
for (int i = 0; i < columns.length; i++) {
String localCol = direction ? columns[i].getForeignDbColumn() : columns[i].getLocalDbColumn();
String refCol = !direction ? columns[i].getForeignDbColumn() : columns[i].getLocalDbColumn();
for (TableJoinColumn column : columns) {
String localCol = direction ? column.getForeignDbColumn() : column.getLocalDbColumn();
String refCol = !direction ? column.getForeignDbColumn() : column.getLocalDbColumn();
foreignKey.addColumnPair(localCol, refCol);
}
}
}
private MTable createTable() {
@@ -93,14 +93,14 @@ public class ModelBuildIntersectionTable {
table.setPkName(ctx.primaryKeyName(tableName));
TableJoinColumn[] columns = intersectionTableJoin.columns();
for (int i = 0; i < columns.length; i++) {
addColumn(table, localDesc, columns[i].getForeignDbColumn(), columns[i].getLocalDbColumn());
}
for (TableJoinColumn column : columns) {
addColumn(table, localDesc, column.getForeignDbColumn(), column.getLocalDbColumn());
}
TableJoinColumn[] otherColumns = tableJoin.columns();
for (int i = 0; i < otherColumns.length; i++) {
addColumn(table, targetDesc, otherColumns[i].getLocalDbColumn(), otherColumns[i].getForeignDbColumn());
}
for (TableJoinColumn otherColumn : otherColumns) {
addColumn(table, targetDesc, otherColumn.getLocalDbColumn(), otherColumn.getForeignDbColumn());
}
return table;
}
@@ -54,8 +54,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
private void addIndexes(IndexDefinition[] indexes) {
if (indexes != null) {
for (int i = 0; i < indexes.length; i++) {
IndexDefinition index = indexes[i];
for (IndexDefinition index : indexes) {
String[] columns = index.getColumns();
indexSet.add(columns);
@@ -166,7 +165,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
ImportedId importedId = p.getImportedId();
List<MColumn> modelColumns = new ArrayList<MColumn>(columns.length);
List<MColumn> modelColumns = new ArrayList<>(columns.length);
MCompoundForeignKey compoundKey = null;
if (columns.length > 1) {
@@ -178,9 +177,9 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
table.addForeignKey(compoundKey);
}
for (int i = 0; i < columns.length; i++) {
for (TableJoinColumn column : columns) {
String dbCol = columns[i].getLocalDbColumn();
String dbCol = column.getLocalDbColumn();
BeanProperty importedProperty = importedId.findMatchImport(dbCol);
if (importedProperty == null) {
throw new RuntimeException("Imported BeanProperty not found?");
@@ -369,4 +368,4 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
return val != null && !val.isEmpty();
}
}
}
@@ -64,9 +64,8 @@ public class VisitAllUsing {
}
BeanProperty[] propertiesNonTransient = desc.propertiesNonTransient();
for (int i = 0; i < propertiesNonTransient.length; i++) {
BeanProperty p = propertiesNonTransient[i];
if (!p.isFormula() && !p.isSecondaryTable()) {
for (BeanProperty p : propertiesNonTransient) {
if (p.isDDLColumn()) {
visit(propertyVisitor, p);
}
}
@@ -91,8 +90,8 @@ public class VisitAllUsing {
// Embedded bean
pv.visitEmbedded(assocOne);
BeanProperty[] embProps = assocOne.getProperties();
for (int i = 0; i < embProps.length; i++) {
pv.visitEmbeddedScalar(embProps[i], assocOne);
for (BeanProperty embProp : embProps) {
pv.visitEmbeddedScalar(embProp, assocOne);
}
} else if (assocOne.isOneToOneExported()) {
@@ -110,8 +109,8 @@ public class VisitAllUsing {
pv.visitCompound(compound);
BeanProperty[] properties = compound.getScalarProperties();
for (int i = 0; i < properties.length; i++) {
pv.visitCompoundScalar(compound, properties[i]);
for (BeanProperty property : properties) {
pv.visitCompoundScalar(compound, property);
}
} else {
@@ -151,8 +150,8 @@ public class VisitAllUsing {
public void visit(InheritInfo inheritInfo) {
BeanProperty[] propertiesLocal = inheritInfo.desc().propertiesLocal();
for (int i = 0; i < propertiesLocal.length; i++) {
owner.visit(pv, propertiesLocal[i]);
for (BeanProperty aPropertiesLocal : propertiesLocal) {
owner.visit(pv, aPropertiesLocal);
}
}
}
@@ -13,8 +13,7 @@ import java.util.Set;
public abstract class AbstractBeanPersistListener implements BeanPersistListener {
/**
* Notified that a bean has been inserted locally. Return true if you want the
* cluster to be notified of the event.
* Notified that a bean has been inserted.
*
* @param bean The bean that was inserted.
*/
@@ -23,8 +22,7 @@ public abstract class AbstractBeanPersistListener implements BeanPersistListener
}
/**
* Notified that a bean has been updated locally. Return true if you want the
* cluster to be notified of the event.
* Notified that a bean has been updated.
*
* @param bean The bean that was updated.
* @param updatedProperties The properties that were modified by this update.
@@ -34,8 +32,7 @@ public abstract class AbstractBeanPersistListener implements BeanPersistListener
}
/**
* Notified that a bean has been deleted locally. Return true if you want the
* cluster to be notified of the event.
* Notified that a bean has been deleted.
*
* @param bean The bean that was deleted.
*/
@@ -43,4 +40,12 @@ public abstract class AbstractBeanPersistListener implements BeanPersistListener
public void deleted(Object bean) {
}
/**
* Notified that a bean has been soft deleted.
*
* @param bean The bean that was deleted.
*/
@Override
public void softDeleted(Object bean) {
}
}
@@ -46,6 +46,13 @@ public abstract class BeanPersistAdapter implements BeanPersistController {
return true;
}
/**
* Returns true indicating normal processing should continue.
*/
public boolean preSoftDelete(BeanPersistRequest<?> request) {
return true;
}
/**
* Does nothing by default.
*/
@@ -64,4 +71,10 @@ public abstract class BeanPersistAdapter implements BeanPersistController {
public void postUpdate(BeanPersistRequest<?> request) {
}
/**
* Does nothing by default.
*/
public void postSoftDelete(BeanPersistRequest<?> request) {
}
}
@@ -89,6 +89,12 @@ public interface BeanPersistController {
*/
boolean preDelete(BeanPersistRequest<?> request);
/**
* Prior to a soft delete perform some action. Return true if you want the
* default functionality to continue.
*/
boolean preSoftDelete(BeanPersistRequest<?> request);
/**
* Called after the insert was performed.
*/
@@ -104,4 +110,8 @@ public interface BeanPersistController {
*/
void postDelete(BeanPersistRequest<?> request);
/**
* Called after the soft delete was performed.
*/
void postSoftDelete(BeanPersistRequest<?> request);
}
@@ -67,4 +67,12 @@ public interface BeanPersistListener {
*/
void deleted(Object bean);
/**
* Notified that a bean has been soft deleted.
*
* @param bean
* The bean that was soft deleted.
*/
void softDeleted(Object bean);
}
@@ -1,7 +1,6 @@
package com.avaje.ebean.event;
import com.avaje.ebean.EbeanServer;
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
/**
* Fired after a bean is constructed, but not yet loaded from database.
@@ -49,7 +49,7 @@ public class ChangeSet {
/**
* The bean changes.
*/
List<BeanChange> changes = new ArrayList<BeanChange>();
List<BeanChange> changes = new ArrayList<>();
/**
* Construct with a txnId.
@@ -182,7 +182,7 @@ public class ChangeSet {
*/
public Map<String,String> getUserContext() {
if (userContext == null) {
userContext = new LinkedHashMap<String, String>();
userContext = new LinkedHashMap<>();
}
return userContext;
}
@@ -159,7 +159,7 @@ public class ReadEvent {
*/
public Map<String, String> getUserContext() {
if (userContext == null) {
userContext = new LinkedHashMap<String, String>();
userContext = new LinkedHashMap<>();
}
return userContext;
}
@@ -13,5 +13,5 @@ public interface ExtraTypeFactory {
/**
* Provide extra types to Ebean.
*/
List<? extends ScalarType> createTypes(ServerConfig config, Object objectMapper);
List<? extends ScalarType<?>> createTypes(ServerConfig config, Object objectMapper);
}
@@ -38,7 +38,6 @@ package com.avaje.ebean.search;
public class TextQueryString {
public static final int DEFAULT_FUZZY_MAX_EXPANSIONS = 50;
public static final int DEFAULT_MAX_DETERMINIZED_STATES = 10000;
protected final String[] fields;
@@ -62,8 +61,6 @@ public class TextQueryString {
protected boolean lowercaseExpandedTerms = true;
protected boolean enablePositionIncrements = true;
protected int fuzzyMaxExpansions = DEFAULT_FUZZY_MAX_EXPANSIONS;
protected String fuzziness;
@@ -78,8 +75,6 @@ public class TextQueryString {
protected boolean autoGeneratePhraseQueries;
protected int maxDeterminizedStates = DEFAULT_MAX_DETERMINIZED_STATES;
protected String minShouldMatch;
protected boolean lenient;
@@ -192,14 +187,6 @@ public class TextQueryString {
return this;
}
/**
* Set enable position increments mode.
*/
public TextQueryString enablePositionIncrements(boolean enablePositionIncrements) {
this.enablePositionIncrements = enablePositionIncrements;
return this;
}
/**
* Set fuzzy max expansions.
*/
@@ -255,14 +242,6 @@ public class TextQueryString {
return this;
}
/**
* Set the max determinized states.
*/
public TextQueryString maxDeterminizedStates(int maxDeterminizedStates) {
this.maxDeterminizedStates = maxDeterminizedStates;
return this;
}
/**
* Set the time zone.
*/
@@ -363,13 +342,6 @@ public class TextQueryString {
return lowercaseExpandedTerms;
}
/**
* Return the enable position increments mode.
*/
public boolean isEnablePositionIncrements() {
return enablePositionIncrements;
}
/**
* Return the fuzzy max expansions.
*/
@@ -419,13 +391,6 @@ public class TextQueryString {
return autoGeneratePhraseQueries;
}
/**
* Return the max determinized states.
*/
public int getMaxDeterminizedStates() {
return maxDeterminizedStates;
}
/**
* Return the time zone.
*/
@@ -42,7 +42,7 @@ public class PathProperties implements FetchPath {
*/
public PathProperties() {
this.rootProps = new Props(this, null, null);
this.pathMap = new LinkedHashMap<String, Props>();
this.pathMap = new LinkedHashMap<>();
this.pathMap.put(null, rootProps);
}
@@ -172,7 +172,7 @@ public class PathProperties implements FetchPath {
}
private Props(PathProperties owner, String parentPath, String path) {
this(owner, parentPath, path, new LinkedHashSet<String>());
this(owner, parentPath, path, new LinkedHashSet<>());
}
public String getPath() {
@@ -286,11 +286,11 @@ class EJsonReader {
private String key;
ObjectContext() {
map = new LinkedHashMap<String, Object>();
map = new LinkedHashMap<>();
}
ObjectContext(ModifyAwareOwner owner) {
map = new ModifyAwareMap<String, Object>(owner, new LinkedHashMap<String, Object>());
map = new ModifyAwareMap<>(owner, new LinkedHashMap<>());
}
public void popContext(Context temp) {
@@ -319,11 +319,11 @@ class EJsonReader {
private final List<Object> values;
ArrayContext() {
values = new ArrayList<Object>();
values = new ArrayList<>();
}
ArrayContext(ModifyAwareOwner owner) {
values = new ModifyAwareList<Object>(owner, new ArrayList<Object>());
values = new ModifyAwareList<>(owner, new ArrayList<>());
}
public void popContext(Context temp) {
@@ -8,6 +8,8 @@ package com.avaje.ebean.text.json;
*/
public class JsonIOException extends RuntimeException {
private static final long serialVersionUID = 3062982368161342209L;
/**
* Construct with an underlying cause.
*/
@@ -29,7 +29,7 @@ public class JsonReadOptions {
* Default constructor.
*/
public JsonReadOptions() {
this.visitorMap = new LinkedHashMap<String, JsonReadBeanVisitor<?>>();
this.visitorMap = new LinkedHashMap<>();
}
/**
@@ -85,7 +85,7 @@ public class JsonWriteOptions {
*/
public JsonWriteOptions setPathVisitor(String path, JsonWriteBeanVisitor<?> visitor) {
if (visitorMap == null) {
visitorMap = new HashMap<String, JsonWriteBeanVisitor<?>>();
visitorMap = new HashMap<>();
}
visitorMap.put(path, visitor);
return this;
@@ -37,7 +37,7 @@ public class StringHelper {
throw new RuntimeException("missing quoted value at the end of " + tag);
}
HashMap<String, String> map = new HashMap<String, String>();
HashMap<String, String> map = new HashMap<>();
// recursively parse out the name value pairs...
return parseNameQuotedValue(map, tag, 0);
}
@@ -111,7 +111,7 @@ public class StringHelper {
* Parses out a list of Name Value pairs that are delimited together. Will
* always return a StringMap. If allNameValuePairs is null, or no name values
* can be parsed out an empty StringMap is returned.
*
*
* @param allNameValuePairs
* the entire string to be parsed.
* @param listDelimiter
@@ -122,7 +122,7 @@ public class StringHelper {
public static Map<String, String> delimitedToMap(String allNameValuePairs,
String listDelimiter, String nameValueSeparator) {
HashMap<String, String> params = new HashMap<String, String>();
HashMap<String, String> params = new HashMap<>();
if ((allNameValuePairs == null) || (allNameValuePairs.isEmpty())) {
return params;
}
@@ -133,7 +133,7 @@ public class StringHelper {
/**
* Trims off recurring strings from the front of a string.
*
*
* @param source
* the source string
* @param trim
@@ -219,7 +219,7 @@ public class StringHelper {
* Convert a string that has delimited values (say comma delimited) in a
* String[]. You must explicitly choose whether or not to include empty values
* (say two commas that a right beside each other.
*
*
* <P>
* e.g. "alpha,beta,,theta"<br>
* With keepEmpties true, this results in a String[] of size 4 with the third
@@ -237,7 +237,7 @@ public class StringHelper {
*/
public static String[] delimitedToArray(String str, String delimiter, boolean keepEmpties) {
ArrayList<String> list = new ArrayList<String>();
ArrayList<String> list = new ArrayList<>();
int startPos = 0;
delimiter(str, delimiter, keepEmpties, startPos, list);
String[] result = new String[list.size()];
@@ -272,7 +272,7 @@ public class StringHelper {
* This returns the FIRST string in str that is bounded on the left by
* leftBound, and bounded on the right by rightBound. This will return null if
* the leftBound is not found within str.
*
*
* <P>
* If leftBound can't be found this returns null.
* </P>
@@ -280,7 +280,7 @@ public class StringHelper {
* This rightBound can't be found then this throws a
* StringIndexOutOfBoundsException.
* </P>
*
*
* @param str
* the base string that we will search for the bounded string.
* @param leftBound
@@ -364,7 +364,7 @@ public class StringHelper {
/**
* This method takes a String and will replace all occurrences of the match
* String with that of the replace String.
*
*
* @param source
* the source string
* @param match
@@ -462,7 +462,7 @@ public class StringHelper {
* <p>
* Useful when converting CRNL CR and NL all to a BR tag for example.
* </p>
*
*
* <pre>
* <code>
* String[] multi = { &quot;\r\n&quot;, &quot;\r&quot;, &quot;\n&quot; };
@@ -580,8 +580,8 @@ public class StringHelper {
}
private static boolean charMatch(int iChr, char[] chr) {
for (int i = 0; i < chr.length; i++) {
if (iChr == chr[i]) {
for (char aChr : chr) {
if (iChr == aChr) {
return true;
}
}
@@ -20,10 +20,10 @@ public class BindParams implements Serializable {
private static final long serialVersionUID = 4541081933302086285L;
private final List<Param> positionedParameters = new ArrayList<Param>();
private final List<Param> positionedParameters = new ArrayList<>();
private final Map<String, Param> namedParameters = new LinkedHashMap<>();
private final Map<String, Param> namedParameters = new LinkedHashMap<String, Param>();
/**
* This is the sql. For named parameters this is the sql after the named
* parameters have been replaced with question mark place holders and the
@@ -37,14 +37,14 @@ public class BindParams implements Serializable {
*/
private int[] bindHash;
public BindParams() {
public BindParams() {
}
public int queryBindHash() {
int hc = namedParameters.hashCode();
for (int i = 0; i < positionedParameters.size(); i++) {
hc = hc * 31 + positionedParameters.get(i).hashCode();
}
for (Param positionedParameter : positionedParameters) {
hc = hc * 31 + positionedParameter.hashCode();
}
return hc;
}
@@ -97,14 +97,14 @@ public class BindParams implements Serializable {
}
return copy;
}
/**
* Return true if there are no bind parameters.
*/
public boolean isEmpty() {
return positionedParameters.isEmpty() && namedParameters.isEmpty();
}
/**
* Return a Natural Key bind param if supported.
*/
@@ -209,7 +209,7 @@ public class BindParams implements Serializable {
* Set a named In parameter that is not null.
*/
public Param setParameter(String name, Object value) {
Param p = getParam(name);
p.setInValue(value);
return p;
@@ -302,62 +302,62 @@ public class BindParams implements Serializable {
* </p>
*/
public static final class OrderedList {
private final List<Param> paramList;
private final StringBuilder preparedSql;
public OrderedList() {
this(new ArrayList<Param>());
this(new ArrayList<>());
}
public OrderedList(List<Param> paramList) {
this.paramList = paramList;
this.preparedSql = new StringBuilder();
}
/**
* Add a parameter in the correct binding order.
*/
public void add(Param param) {
paramList.add(param);
}
/**
* Return the number of bind parameters in this list.
*/
public int size() {
return paramList.size();
}
/**
* Returns the ordered list of bind parameters.
*/
public List<Param> list() {
return paramList;
}
/**
* Append parsedSql that has named parameters converted into ?.
*/
public void appendSql(String parsedSql) {
preparedSql.append(parsedSql);
}
public String getPreparedSql() {
return preparedSql.toString();
}
}
/**
* A In Out capable parameter for the CallableStatement.
*/
public static final class Param implements Serializable {
private static final long serialVersionUID = 1L;
private boolean encryptionKey;
private boolean isInParam;
private boolean isOutParam;
@@ -381,9 +381,9 @@ public class BindParams implements Serializable {
if (inValue instanceof Collection<?>){
return ((Collection<?>)inValue).size();
}
return 1;
return 1;
}
/**
* Create a deep copy of the Param.
*/
@@ -396,20 +396,20 @@ public class BindParams implements Serializable {
copy.outValue = outValue;
return copy;
}
public int hashCode() {
int hc = getClass().hashCode();
hc = hc * 31 + (isInParam ? 0 : 1);
hc = hc * 31 + (isOutParam ? 0 : 1);
hc = hc * 31 + (type);
hc = hc * 31 + (inValue == null ? 0 : inValue.hashCode());
hc = hc * 31 + (inValue == null ? 0 : inValue.hashCode());
return hc;
}
public boolean equals(Object o) {
return o != null && (o == this || (o instanceof Param) && hashCode() == o.hashCode());
}
/**
* Return true if this is an In parameter that needs to be bound before
* execution.
@@ -458,7 +458,7 @@ public class BindParams implements Serializable {
this.isInParam = true;
this.encryptionKey = true;
}
/**
* Specify that the In parameter is NULL and the specific type that it
* is.
@@ -95,11 +95,10 @@ public class LoadBeanRequest extends LoadRequest {
*/
public List<Object> getIdList(int batchSize) {
List<Object> idList = new ArrayList<Object>(batchSize);
List<Object> idList = new ArrayList<>(batchSize);
BeanDescriptor<?> desc = loadBuffer.getBeanDescriptor();
for (int i = 0; i < batch.size(); i++) {
EntityBeanIntercept ebi = batch.get(i);
for (EntityBeanIntercept ebi : batch) {
EntityBean bean = ebi.getOwner();
idList.add(desc.getId(bean));
}
@@ -150,12 +149,12 @@ public class LoadBeanRequest extends LoadRequest {
*/
public void postLoad(List<?> list) {
Set<Object> loadedIds = new HashSet<Object>();
Set<Object> loadedIds = new HashSet<>();
BeanDescriptor<?> desc = loadBuffer.getBeanDescriptor();
// collect Ids and maybe load bean cache
for (int i = 0; i < list.size(); i++) {
EntityBean loadedBean = (EntityBean) list.get(i);
for (Object aList : list) {
EntityBean loadedBean = (EntityBean) aList;
loadedIds.add(desc.getId(loadedBean));
if (isLoadCache()) {
desc.cacheBeanPut(loadedBean);
@@ -163,10 +162,9 @@ public class LoadBeanRequest extends LoadRequest {
}
if (lazyLoadProperty != null) {
for (int i = 0; i < batch.size(); i++) {
for (EntityBeanIntercept ebi : batch) {
// check if the underlying row in DB was deleted. Mark the bean as 'failed' if
// necessary but allow processing to continue until it is accessed by client code
EntityBeanIntercept ebi = batch.get(i);
Object id = desc.getId(ebi.getOwner());
if (!loadedIds.contains(id)) {
if (desc.isSoftDelete()) {
@@ -101,11 +101,10 @@ public class LoadManyRequest extends LoadRequest {
private List<Object> getParentIdList(int batchSize) {
ArrayList<Object> idList = new ArrayList<Object>(batchSize);
ArrayList<Object> idList = new ArrayList<>(batchSize);
BeanPropertyAssocMany<?> many = getMany();
for (int i = 0; i < batch.size(); i++) {
BeanCollection<?> bc = batch.get(i);
for (BeanCollection<?> bc : batch) {
idList.add(many.getParentId(bc.getOwnerBean()));
}
int extraIds = batchSize - batch.size();
@@ -177,8 +176,7 @@ public class LoadManyRequest extends LoadRequest {
// check for BeanCollection's that where never processed
// in the +query or +lazy load due to no rows (predicates)
for (int i = 0; i < batch.size(); i++) {
BeanCollection<?> bc = batch.get(i);
for (BeanCollection<?> bc : batch) {
if (bc.checkEmptyLazyLoad()) {
if (logger.isDebugEnabled()) {
EntityBean ownerBean = bc.getOwnerBean();
@@ -19,12 +19,14 @@ public class ManyWhereJoins implements Serializable {
private static final long serialVersionUID = -6490181101871795417L;
private final TreeMap<String, PropertyJoin> joins = new TreeMap<String, PropertyJoin>();
private final TreeMap<String, PropertyJoin> joins = new TreeMap<>();
private StringBuilder formulaProperties = new StringBuilder();
private boolean formulaWithJoin;
private boolean aggregation;
/**
* 'Mode' indicating that joins added while this is true are required to be outer joins.
*/
@@ -93,10 +95,10 @@ public class ManyWhereJoins implements Serializable {
}
/**
* Return true if there are no extra many where joins.
* Return true if this is an aggregation query or if there are no extra many where joins.
*/
public boolean isEmpty() {
return joins.isEmpty();
public boolean requireSqlDistinct() {
return !aggregation && !joins.isEmpty();
}
/**
@@ -111,7 +113,7 @@ public class ManyWhereJoins implements Serializable {
*/
public TreeSet<String> getPropertyNames() {
TreeSet<String> propertyNames = new TreeSet<String>();
TreeSet<String> propertyNames = new TreeSet<>();
for (PropertyJoin join : joins.values()) {
propertyNames.add(join.getProperty());
}
@@ -146,4 +148,18 @@ public class ManyWhereJoins implements Serializable {
return formulaProperties.toString();
}
/**
* Mark this as part of an aggregation query (so using group by clause).
*/
public void setAggregation() {
aggregation = true;
}
/**
* Ensure we have the join required to support the aggregation properties.
*/
public void addAggregationJoin(String property) {
this.aggregation = true;
joins.put(property, new PropertyJoin(property, SqlJoinType.INNER));
}
}
@@ -221,8 +221,8 @@ public class ScopeTrans implements Thread.UncaughtExceptionHandler {
}
if (noRollbackFor != null) {
for (int i = 0; i < noRollbackFor.size(); i++) {
if (noRollbackFor.get(i).equals(e.getClass())) {
for (Class<? extends Throwable> aNoRollbackFor : noRollbackFor) {
if (aNoRollbackFor.equals(e.getClass())) {
// explicit no rollback for this one
return false;
@@ -231,8 +231,8 @@ public class ScopeTrans implements Thread.UncaughtExceptionHandler {
}
if (rollbackFor != null) {
for (int i = 0; i < rollbackFor.size(); i++) {
if (rollbackFor.get(i).equals(e.getClass())) {
for (Class<? extends Throwable> aRollbackFor : rollbackFor) {
if (aRollbackFor.equals(e.getClass())) {
// explicit rollback for this one
return true;
}
@@ -6,11 +6,10 @@ import com.avaje.ebean.bean.PersistenceContext;
import com.avaje.ebean.config.PersistBatch;
import com.avaje.ebean.event.changelog.BeanChange;
import com.avaje.ebean.event.changelog.ChangeSet;
import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship;
import com.avaje.ebeaninternal.server.core.PersistRequest;
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship;
import com.avaje.ebeaninternal.server.persist.BatchControl;
import javax.persistence.PersistenceException;
import javax.persistence.RollbackException;
import java.io.IOException;
@@ -369,6 +368,11 @@ public class ScopedTransaction implements SpiTransaction {
transaction.flushBatchOnCascade();
}
@Override
public void flushBatchOnRollback() {
transaction.flushBatchOnRollback();
}
@Override
public void markNotQueryOnly() {
transaction.markNotQueryOnly();
@@ -145,7 +145,7 @@ public interface SpiEbeanServer extends EbeanServer, BeanLoader, BeanCollectionL
* the query has finished (if executing in a background thread).
* </p>
*/
<A> List<A> findIdsWithCopy(Query<?> query, Transaction t);
<A, T> List<A> findIdsWithCopy(Query<T> query, Transaction t);
/**
* Execute the findRowCount query but without copying the query.
@@ -1,6 +1,7 @@
package com.avaje.ebeaninternal.api;
import com.avaje.ebean.ExpressionList;
import com.avaje.ebean.Junction;
import com.avaje.ebeaninternal.server.expression.DocQueryContext;
import java.io.IOException;
@@ -11,16 +12,21 @@ import java.util.List;
*/
public interface SpiExpressionList<T> extends ExpressionList<T>, SpiExpression {
/**
* Return the expression list as a Junction (for ElasticSearch).
*/
Junction<T> toJunction();
/**
* Return the underlying list of expressions.
*/
List<SpiExpression> getUnderlyingList();
/**
* Return a copy of the ExpressionList with the path trimmed for filterMany() expressions.
*/
SpiExpressionList<?> trimPath(int prefixTrim);
/**
* Return true if this list is empty.
*/
@@ -12,7 +12,7 @@ public class SpiExpressionValidation {
private final BeanType<?> desc;
private final LinkedHashSet<String> unknown = new LinkedHashSet<String>();
private final LinkedHashSet<String> unknown = new LinkedHashSet<>();
public SpiExpressionValidation(BeanType<?> desc) {
this.desc = desc;
@@ -166,6 +166,11 @@ public interface SpiQuery<T> extends Query<T> {
*/
PersistenceContextScope getPersistenceContextScope();
/**
* Return the origin key.
*/
String getOriginKey();
/**
* Return the default lazy load batch size.
*/
@@ -39,9 +39,4 @@ public interface SpiSqlQuery extends SqlQuery {
*/
int getBufferFetchSizeHint();
/**
* Set the PreparedStatement for the purposes of supporting cancel.
*/
void setPreparedStatement(PreparedStatement pstmt);
}
@@ -5,11 +5,10 @@ import com.avaje.ebean.annotation.DocStoreMode;
import com.avaje.ebean.bean.PersistenceContext;
import com.avaje.ebean.event.changelog.BeanChange;
import com.avaje.ebean.event.changelog.ChangeSet;
import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship;
import com.avaje.ebeaninternal.server.core.PersistRequest;
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship;
import com.avaje.ebeaninternal.server.persist.BatchControl;
import java.sql.Connection;
/**
@@ -117,6 +116,7 @@ public interface SpiTransaction extends Transaction {
* Returning 0 implies to use the system wide default batch size.
* </p>
*/
@Override
int getBatchSize();
/**
@@ -235,6 +235,11 @@ public interface SpiTransaction extends Transaction {
*/
void flushBatchOnCascade();
/**
* If batch was on then effectively clear the batch such that we can handle exceptions and continue.
*/
void flushBatchOnRollback();
/**
* Mark the transaction explicitly as not being query only.
*/
@@ -126,8 +126,8 @@ public class TransactionEvent implements Serializable {
List<PersistRequestBean<?>> persistRequestBeans = getPersistRequestBeans();
if (persistRequestBeans != null) {
for (int i=0; i< persistRequestBeans.size(); i++) {
persistRequestBeans.get(i).addDocStoreUpdates(docStoreUpdates);
for (PersistRequestBean<?> persistRequestBean : persistRequestBeans) {
persistRequestBean.addDocStoreUpdates(docStoreUpdates);
}
}
}
@@ -15,7 +15,7 @@ import com.avaje.ebeaninternal.server.core.PersistRequestBean;
*/
public class TransactionEventBeans {
final ArrayList<PersistRequestBean<?>> requests = new ArrayList<PersistRequestBean<?>>();
final ArrayList<PersistRequestBean<?>> requests = new ArrayList<>();
/**
* Return the list of PersistRequests that BeanListeners are interested in.
@@ -36,9 +36,9 @@ public class TransactionEventBeans {
* Collect the cache changes.
*/
public void notifyCache(CacheChangeSet changeSet) {
for (int i = 0; i < requests.size(); i++) {
requests.get(i).notifyCache(changeSet);
}
for (PersistRequestBean<?> request : requests) {
request.notifyCache(changeSet);
}
}
}
@@ -16,7 +16,7 @@ public final class TransactionEventTable implements Serializable {
private static final long serialVersionUID = 2236555729767483264L;
private final Map<String, TableIUD> map = new HashMap<String, TableIUD>();
private final Map<String, TableIUD> map = new HashMap<>();
public String toString() {
return "TransactionEventTable " + map.values();
@@ -63,7 +63,7 @@ public class ExtraDdl {
*/
public List<DdlScript> getDdlScript() {
if (ddlScript == null) {
ddlScript = new ArrayList<DdlScript>();
ddlScript = new ArrayList<>();
}
return this.ddlScript;
}
@@ -11,7 +11,7 @@ import java.util.List;
*/
public class AutoTuneCollection {
List<Entry> entries = new ArrayList<Entry>();
List<Entry> entries = new ArrayList<>();
public Entry add(ObjectGraphOrigin origin, OrmQueryDetail detail, String sourceQuery) {
Entry entry = new Entry(origin, detail, sourceQuery);
@@ -46,7 +46,7 @@ public class AutoTuneCollection {
/**
* Summary execution statistics for queries related to this origin point.
*/
private final List<EntryQuery> queries = new ArrayList<EntryQuery>();
private final List<EntryQuery> queries = new ArrayList<>();
public Entry(ObjectGraphOrigin origin, OrmQueryDetail detail, String originalQuery) {
this.origin = origin;
@@ -70,7 +70,7 @@ public class Autotune {
*/
public List<Origin> getOrigin() {
if (origin == null) {
origin = new ArrayList<Origin>();
origin = new ArrayList<>();
}
return this.origin;
}
@@ -61,7 +61,7 @@ public class ProfileDiff {
*/
public List<Origin> getOrigin() {
if (origin == null) {
origin = new ArrayList<Origin>();
origin = new ArrayList<>();
}
return this.origin;
}
@@ -61,7 +61,7 @@ public class ProfileEmpty {
*/
public List<Origin> getOrigin() {
if (origin == null) {
origin = new ArrayList<Origin>();
origin = new ArrayList<>();
}
return this.origin;
}
@@ -61,7 +61,7 @@ public class ProfileNew {
*/
public List<Origin> getOrigin() {
if (origin == null) {
origin = new ArrayList<Origin>();
origin = new ArrayList<>();
}
return this.origin;
}
@@ -30,7 +30,7 @@ public class BaseQueryTuner {
/**
* Map of the tuned query details per profile query point.
*/
private final Map<String, TunedQueryInfo> tunedQueryInfoMap = new ConcurrentHashMap<String, TunedQueryInfo>();
private final Map<String, TunedQueryInfo> tunedQueryInfoMap = new ConcurrentHashMap<>();
private final SpiEbeanServer server;
@@ -63,7 +63,7 @@ public class DefaultAutoTuneService implements AutoTuneService {
this.queryTuner = new BaseQueryTuner(config, server, profileManager);
this.skipGarbageCollectionOnShutdown = config.isSkipGarbageCollectionOnShutdown();
this.skipProfileReportingOnShutdown = config.isSkipProfileReportingOnShutdown();
this.defaultGarbageCollectionWait = (long) config.getGarbageCollectionWait();
this.defaultGarbageCollectionWait = config.getGarbageCollectionWait();
}
/**
@@ -31,7 +31,7 @@ public class ProfileManager implements ProfilingListener {
/**
* Map of the usage and query statistics gathered.
*/
private final Map<String, ProfileOrigin> profileMap = new ConcurrentHashMap<String, ProfileOrigin>();
private final Map<String, ProfileOrigin> profileMap = new ConcurrentHashMap<>();
private final Object monitor = new Object();

Some files were not shown because too many files have changed in this diff Show More