Compare commits

...
Author SHA1 Message Date
Rob Bygrave 74321277ff [maven-release-plugin] prepare release ebean-parent-13.9.1 2022-09-02 09:16:01 +12:00
Rob Bygrave c60362f6e1 Bump ebean-agent to 13.9.1 - no effective change 2022-09-02 09:10:15 +12:00
Rob BygraveandGitHub c1320e4184 Merge pull request #2815 from ebean-orm/feature/2814-nestedUseSavepoint
#2814 - Change setNestedUseSavepoint() to use 'ScopeTrans' rather than the underlying Transaction
2022-09-02 08:20:53 +12:00
Rob BygraveandGitHub a7ea2cf3ef Merge pull request #2820 from ebean-orm/feature/2818-fix-concurrentModOfTransactionEvent
#2818 - Fix Concurrent modification of listenerNotify TransactionEvent list
2022-09-02 08:19:03 +12:00
Rob BygraveandGitHub f86a0ac973 Merge pull request #2819 from ebean-orm/feature/enh-addRollbackAndContinue
ENH: Add Transaction.rollbackAndContinue()
2022-09-02 08:18:25 +12:00
Rob Bygrave bcc21b1c04 #2818 - Fix Concurrent modification of listenerNotify TransactionEvent list
The issue fixed here is that SavepointTransaction was effectively using the
TransactionEvent of the underlying 'parent' transaction. The fix is for
SavepointTransaction to have its own TransactionEvent.
2022-09-01 22:45:17 +12:00
Rob Bygrave d517dea27f ENH: Add Transaction.rollbackAndContinue() 2022-09-01 22:26:52 +12:00
Rob Bygrave 7df168f232 ENH: Add Transaction.rollbackAndContinue()
Typically useful for handling DuplicateKeyException where we expect
DuplicateKeyException to be thrown and catch it with the intention of
continuing processing using the same transaction.

Note that some databases like Oracle do not require this explicit
rollback() and would work without the rollbackAndContinue(). Postgres
in particular requires the rollback() call on the underlying connection
such that we can continue using that transaction/java.sql.Connection.

Note that in the existing test we can see that rollbackAndContinue()
is pretty close to being syntactic sugar. I think adding rollbackAndContinue()
is justified and complements the existing commitAndContinue().
2022-09-01 17:08:11 +12:00
Rob Bygrave 563340edbd Bump to 13.9.1-SNAPSHOT after release 2022-09-01 16:47:22 +12:00
Rob Bygrave 28d70cf9c4 [maven-release-plugin] prepare for next development iteration 2022-09-01 12:33:08 +12:00
Rob Bygrave 25d0675532 [maven-release-plugin] prepare release ebean-parent-13.9.0 2022-09-01 12:33:01 +12:00
Rob Bygrave c8ffad2831 Fix TestSubQuery for postgres compatible syntax with ANY(?) 2022-09-01 12:25:50 +12:00
Rob Bygrave 8233058d2e Bump ebean-agent to 13.9.0 (no effective change) 2022-09-01 12:23:00 +12:00
Rob Bygrave f7e00aab78 #2457 #2810 - Add ebean-joda-time as a dependency to ebean composite
- Add ebean-joda-time as a dependency to ebean composite
- Add ebean-joda-time to BOM
2022-09-01 11:37:28 +12:00
Rob BygraveandGitHub a111f3ff10 Merge pull request #2816 from ebean-orm/feature/2813-subQueryCompile-raceCondition
#2813 - Sometimes subquery use wrong alias in SQL
2022-09-01 11:18:23 +12:00
Rob Bygrave 29e2b81092 #2813 - Sometimes subquery use wrong alias in SQL
The reason for this is that as part of DefaultOrmQuery.copy() it uses
DefaultExpressionList.copy() and that assumed that expressions were
safe to share which is NOT the case for IN and EXISTS sub-query expressions
so InQueryExpression and ExistsQueryExpression

The effective fix for this is that DefaultExpressionList.copy() changes
to call SpiExpression.copy() and for InQueryExpression and ExistsQueryExpression
to implement that copy() by creating a copy of the sub-query.

A "side-fix" is that in DefaultOrmQuery.createExtraJoinsToSupportManyWhereClause()
it was creating an instance of ManyWhereJoins, then mutating it ... and if we
change that to only doing the assignment at the end (object assignment is atomic)
then racy access reading ManyWhereJoins would always get a fully completed non-mutating
instance of ManyWhereJoins. Noting this because it kind of points to where I think
the race condition is (in createExtraJoinsToSupportManyWhereClause()) but noting that
with the change to DefaultExpressionList.copy() this "side-fix" isn't required per say.
2022-08-31 17:24:55 +12:00
Rob Bygrave 0dda3e0e93 #2814 - Change setNestedUseSavepoint() to use 'ScopeTrans' rather than the underlying Transaction
The reason for this is that ScopedTransaction holds a stack of ScopeTrans and Transaction, but
the actual transaction in this stack is often the same instance / shared when nesting. The issue
is that currently setNestedUseSavepoint() sets this flag on the *_underlying transaction_* and
this instance is the same / shared when 'nesting'.

This change moves the nestedUseSavepoint flag for ScopedTransaction to be on ScopeTrans
(from the underlying transaction).
2022-08-31 11:39:02 +12:00
Rob Bygrave f07c7411fa No effective change - tidy SqlTreeAlias only 2022-08-30 12:37:27 +12:00
Rob BygraveandGitHub b4d037fa18 Merge pull request #2812 from ebean-orm/feature/inspect-tidy
IntelliJ inspect various improvements
2022-08-30 11:58:54 +12:00
Rob Bygrave e46bbcf8cf NaturalKeyQueryData use the matchSingleProperty + IntelliJ Inspect various improvements
The non-use of the matchSingleProperty meant it fell back to the multi-property match
2022-08-27 23:10:13 +12:00
Rob Bygrave 0c2ab729bc IntelliJ Inspect various improvements 2022-08-27 22:37:48 +12:00
Rob Bygrave 81ef967d9f IntelliJ Inspect various improvements 2022-08-27 22:02:32 +12:00
Rob BygraveandGitHub 2d733795c7 Merge pull request #2811 from ebean-orm/feature/refactor-json-docstore-methods
Refactor method names SpiJsonReader and DocStore types
2022-08-27 20:16:03 +12:00
Rob Bygrave 7ce85fe5f2 Refactor method names SpiJsonReader and DocStore types 2022-08-27 20:09:27 +12:00
Rob Bygrave e3e30cafdd Refactor tidy error and log messages - part 2 2022-08-27 17:15:08 +12:00
Rob Bygrave e51ac7de36 Refactor tidy error and log messages 2022-08-27 16:50:54 +12:00
Rob Bygrave ee71c79125 Tidy DefaultTypeManager, reduce unnecessary fields 2022-08-27 16:08:30 +12:00
Rob Bygrave bce2dec1cd Remove unused imports in DefaultTypeManager 2022-08-27 15:40:06 +12:00
Rob Bygrave 3f2d0ef520 Bump to 13.9.0-SNAPSHOT 2022-08-26 17:49:01 +12:00
Rob BygraveandGitHub bbb3ad9333 Merge pull request #2810 from ebean-orm/feature/extract-joda-time-module
Refactor extract ebean-joda-time module - move joda ScalarTypes
2022-08-26 17:34:28 +12:00
Rob Bygrave b7e62df371 Refactor extract ebean-joda-time module - move joda ScalarTypes
Moves the joda-time ScalarTypes into a new ebean-joda-time module. Include
the ebean-joda-time module in the classpath, and the extra types will be
service loaded (by DefaultTypeManager).
2022-08-26 17:32:31 +12:00
Rob BygraveandGitHub 7b3405ca25 Merge pull request #2809 from ebean-orm/feature/refactor-move-BasicTypeConverter
Refactor move BasicTypeConverter to ebean-core-type module
2022-08-26 15:30:16 +12:00
Rob Bygrave 9984b53070 Refactor move BasicTypeConverter to ebean-core-type module
Doing this in preparation for moving the joda-type ScalarTypes into their own module
2022-08-26 15:21:30 +12:00
Rob BygraveandGitHub 5e1aef1953 Merge pull request #2808 from ebean-orm/feature/refactor-move-internal-bindAndJson
Refactor move package - server.type.DataBind to server.bind, server.text.json -> server.json
2022-08-26 14:52:02 +12:00
Rob Bygrave 4c13a3a779 Refactor move package - server.type.DataBind to server.bind, server.text.json -> server.json
The DataBind classes don't need to be in with server.type anymore.
The server.text.json package can just reduce package nesting.
2022-08-26 14:51:19 +12:00
Rob BygraveandGitHub 100719ac1f Merge pull request #2807 from ebean-orm/feature/move-scalarTypeBaseVarchar
Refactor move ScalarTypeBaseDate, ScalarTypeBaseDateTime, ScalarTypeBaseVarchar in ebean-core-type
2022-08-26 13:22:23 +12:00
Rob Bygrave a13f581a65 Refactor ScalarTypeBaseDateTime, merge into ScalarTypeUtils both IsoJsonDateTimeParser and DecimalUtils
That is, merge the static util methods into ScalarTypeUtils
2022-08-26 13:15:55 +12:00
Rob Bygrave f319ee66ad Refactor move ScalarTypeBaseDateTime to ebean-core-type module 2022-08-26 13:02:42 +12:00
Rob Bygrave 6f249c7b72 No effective change, tidy ScalarTypeBaseDate only 2022-08-26 12:36:04 +12:00
Rob Bygrave 09e20934d7 Refactor move ScalarTypeBaseDate to ebean-core-type module 2022-08-26 12:30:50 +12:00
Rob Bygrave 5b22506b9b Refactor move ScalarTypeBaseVarchar to ebean-core-type module 2022-08-26 12:28:29 +12:00
Rob Bygrave 13a913428e DecimalUtils - remove unused methods converting between Instance and BigDecimal 2022-08-26 12:24:15 +12:00
Rob Bygrave 5667f1b118 ScalarTypeCharArray - remove unused method jsonWrite() with incorrect params 2022-08-26 12:20:36 +12:00
Rob BygraveandGitHub fcb8e4ca64 Merge pull request #2806 from ebean-orm/feature/refactor-scalarType-convertFromMillis
Refactor ScalarType, remove convertFromMillis() method (no longer needed)
2022-08-25 22:49:03 +12:00
Rob Bygrave c5e8b217e3 Refactor ScalarType, remove convertFromMillis() method (no longer needed)
Due to the move and change of CsvReader using StringParser ScalarType no longer
needs that general convertFromMillis() method. Note that date and dateTime ScalarTypes
still retain this conversion method.
2022-08-25 22:37:47 +12:00
Rob BygraveandGitHub f98b6b0e2a Merge pull request #2805 from ebean-orm/feature/extract-csv-reader-module
Extract csv reader module
2022-08-25 22:24:07 +12:00
Rob Bygrave f01d8174e8 Extract CsvReader - fix parent pom version 2022-08-25 22:17:20 +12:00
Rob Bygrave ccf790a630 Extract CsvReader - provider scope for ebean-core 2022-08-25 22:15:15 +12:00
Rob Bygrave efe80a534c Extract CsvReader - remove built in date, time, dateTime parsing - use StringParser instead
Just always use our own StringParser lambda function instead for parsing date, time and dateTime types.
2022-08-25 22:09:38 +12:00
Rob Bygrave 1aac01ead0 Extract CsvReader - move DefaultCsvCallback and add module-info 2022-08-25 17:49:11 +12:00
Rob Bygrave 216c43eea6 Extract CsvReader into separate ebean-csv-reader module 2022-08-25 17:25:49 +12:00
Rob BygraveandGitHub 5b2a8cdacb Merge pull request #2804 from ebean-orm/feature/refactor-move-ScalarTypeBase
Refactor move ScalarTypeBase + remove loadIgnore()
2022-08-25 13:47:14 +12:00
Rob Bygrave d2da4f7e52 Reorder methods on ScalarType only 2022-08-25 13:12:35 +12:00
Rob Bygrave 186019da7f Refactor ScalarType move format() default method from ScalarTypeBase to ScalarType 2022-08-25 13:00:30 +12:00
Rob Bygrave 7d1772cb54 Refactor ScalarType remove loadIgnore() method to implement in BeanProperty & DynamicPropertyBase 2022-08-25 12:53:44 +12:00
Rob Bygrave cd30c47951 Refactor move ScalarTypeBase to the ebean-core-type module (for external reuse)
Doing this in preparation for moving the joda-time scalar types into their own module
(so that they can become optional).
2022-08-25 12:42:12 +12:00
Rob BygraveandGitHub 4b11147b83 Merge pull request #2801 from ebean-orm/feature/drop-feature-OnQueryOnly
Remove the OnQueryOnly (rollback) feature
2022-08-25 12:30:16 +12:00
Rob BygraveandGitHub 6d7a5f07f0 Merge pull request #2803 from ebean-orm/feature/refactor-scalarType-methodNames
Refactor ScalarType methods from getters to accessors
2022-08-25 12:30:05 +12:00
Rob Bygrave 26f0605d72 Refactor ScalarType methods from getters to accessors 2022-08-25 12:25:38 +12:00
Rob BygraveandGitHub 4959053ce0 Merge pull request #2802 from ebean-orm/feature/remove-ScalarType-isDateTimeCapable
Remove ScalarType.isDateTimeCapable() ... (only used by CSV reader)
2022-08-25 12:17:26 +12:00
Rob Bygrave 10c9b2addd Remove ScalarType.isDateTimeCapable() ... (only used by CSV reader)
So the complexity cost doesn't justify itself against only being used
by CSV reader to validate when assigning a date/time format to a property
/ expression path.
2022-08-25 12:16:37 +12:00
Rob BygraveandGitHub 3092b59622 Merge pull request #2800 from ebean-orm/feature/refactor-databasePlatform
Refactor database platform - remove unused tableExists() method, rename getters to accessors
2022-08-25 12:01:49 +12:00
Rob Bygrave 8b086e0e49 Bump to 13.8.2-SNAPSHOT after release 2022-08-25 11:48:18 +12:00
Rob Bygrave 981c3595a8 [maven-release-plugin] prepare for next development iteration 2022-08-25 11:34:05 +12:00
Rob Bygrave 5414fa17cf [maven-release-plugin] prepare release ebean-parent-13.8.1 2022-08-25 11:33:58 +12:00
Rob Bygrave 807b017463 Bump to ebean-agent 13.8.1 2022-08-25 11:29:25 +12:00
Rob Bygrave 96b674114c Remove the OnQueryOnly (rollback) feature
The better approach these days is to use the read-only datasource with autoCommit
2022-08-25 11:26:55 +12:00
Rob Bygrave 456086fb3c Refactor DatabasePlatform - rename getters to accessors
Although this is public API these getters are not expected to be used
by application code so, I feel comfortable making this change.
2022-08-25 10:34:39 +12:00
Rob Bygrave 341b9a7449 Refactor DatabasePlatform - remove unused method tableExists() 2022-08-25 10:23:14 +12:00
Rob Bygrave 6c7cedc1f1 #2799 - Remove unused DatabasePlatform.treatEmptyStringsAsNull 2022-08-25 10:19:11 +12:00
Rob Bygrave 01155c3466 #2798 - SQL Anywhere: invalid escape character on like expression 2022-08-23 18:16:51 +12:00
Rob Bygrave c297ebda5a No effective change, fix typo in DatabasePlatform variable name 2022-08-23 16:09:45 +12:00
Rob BygraveandGitHub cec7492c10 Merge pull request #2797 from ebean-orm/feature/systemLogger-logging
Use AppLog and System.Logger for logging rather than slf4j-api
2022-08-23 15:36:49 +12:00
Rob Bygrave 4252445eb4 Use AppLog and System.Logger for logging - static imports 2022-08-23 15:18:46 +12:00
Rob Bygrave a23f241fff Use AppLog and System.Logger for logging rather than slf4j-api
The avaje-applog-slf4j dependency means this is still using
slf4j-api for implementation. Remove that dependency and
service load the desired implementation.
2022-08-18 22:44:31 +12:00
Rob BygraveandGitHub d145e6494d Merge pull request #2796 from ebean-orm/feature/final-mods-querybeans
Add missing final modifier on methods of query bean types
2022-08-18 16:55:43 +12:00
Rob Bygrave 2563d52ecf Fix versions after release 2022-08-18 16:52:10 +12:00
Rob Bygrave 8632aef268 Add missing final modifier on methods of query bean types 2022-08-18 16:49:39 +12:00
Rob Bygrave f827a292ff [maven-release-plugin] prepare for next development iteration 2022-08-18 16:04:31 +12:00
Rob Bygrave a027c630b1 [maven-release-plugin] prepare release ebean-parent-13.8.0 2022-08-18 16:04:25 +12:00
Rob Bygrave ab1a49abee Include ebean-types and persistence-api in BOM 2022-08-18 15:42:55 +12:00
Rob Bygrave bc5cf0e326 Bump to ebean-agent 13.8.0 (no effective change) 2022-08-18 15:36:48 +12:00
Rob Bygrave 348535ec6c Bump to 13.8.0-SNAPSHOT 2022-08-18 15:35:17 +12:00
Rob BygraveandGitHub 273f994cdf Merge pull request #2795 from ebean-orm/feature/refactor-methodNames-query
Refactor rename internal methods - io.ebeaninternal.server.query
2022-08-18 13:26:55 +12:00
Rob Bygrave c0a3f7e05d Refactor rename internal methods - io.ebeaninternal.server.query 2022-08-18 11:11:12 +12:00
Rob Bygrave 1bc9bab988 #2794 - ebean-test-containers - Handle SQLServer specific occasional fail on start 2022-08-18 10:19:02 +12:00
Rob Bygrave dc730fd97b #2788 - Support mapping @DbArray List<Float> to Postgres float4[] 2022-08-18 08:23:52 +12:00
Rob Bygrave 6c15115530 #2786 - Support logging Ebean version unknown
We don't really care if we can't determine the version so only log when we can read it.
2022-08-17 17:42:39 +12:00
Rob BygraveandGitHub 841b268fc7 Merge pull request #2791 from ebean-orm/feature/InternString
Just use String.intern() now that we are on min Java 11 runtime.
2022-08-17 17:38:41 +12:00
Rob BygraveandGitHub 6c8db9dec7 Merge pull request #2793 from ebean-orm/feature/2782-mariaDb-driver-update
#2782 - Support MariaDB jdbc driver update - Batched JDBC SQLException translation, SqlRow BLOB reading
2022-08-17 17:27:07 +12:00
Rob Bygrave 51d2f52d19 #2782 - Support MariaDB jdbc driver update - Batched JDBC SQLException translation, SqlRow BLOB reading
- Batched JDBC SQLException translation - Need to dig into nested exception to get cause error state
- SqlRow BLOB reading - BLOB can come as LONGVARBINARY (TestRawSqlBuilder)
- Fix test for history using system time (TestHistoryInsert)
- Fix SqlQueryCancelTest
- Fix TestSqlUpdateExceptions
2022-08-17 17:25:28 +12:00
Rob BygraveandGitHub ff45f9ab63 Merge pull request #2792 from ebean-orm/feature/2782-fwdOnlyFetchSize
#2782 #2783 - Forward only fetchSize() for MySql and MariaDB is Integer.MIN_VALUE and 1 respectively
2022-08-17 16:19:22 +12:00
Rob Bygrave 507027df0a #2782 #2783 - Forward only fetchSize() for MySql and MariaDB is Integer.MIN_VALUE and 1 respectively 2022-08-17 16:17:26 +12:00
Rob Bygrave 50d45c6da9 Just use String.intern() now that we are on min Java 11 runtime. 2022-08-17 15:21:16 +12:00
Rob BygraveandGitHub f5e9356451 Merge pull request #2783 from Wooza/patch-1
Bump mariadb-java-client to 3.0.7
2022-08-17 14:55:20 +12:00
Rob BygraveandGitHub dfe46cc011 Merge pull request #2779 from ebean-orm/feature/refactor-rename-queryplan-methods
Refactor rename internal methods for SpiQueryPlan and DbReadContext
2022-08-17 14:42:54 +12:00
Rob BygraveandGitHub 34cdbc5620 Merge pull request #2787 from ebean-orm/revert-2722-feature/jakarta-jaxb
Revert "Migrate to Jakarta JAXB (jakarta.xml.bind <- javax.xml.bind)"
2022-08-16 17:05:27 +12:00
Rob Bygrave 595c057964 #2784 - Fix @Return javadoc for TQRootBean.findSingleAttribute() 2022-08-16 17:03:07 +12:00
Rob BygraveandGitHub 73bc9e516e Revert "Migrate to Jakarta JAXB (jakarta.xml.bind <- javax.xml.bind)" 2022-08-15 15:14:57 +12:00
Rob BygraveandGitHub 6a4cfb231d Merge pull request #2785 from ebean-orm/feature/2784-findSingleAttribute-nullable
#2784 - Correct documentation for TQRootBean.findSingleAttribute with @Nullable
2022-08-12 15:54:28 +12:00
Rob Bygrave 4523db85c3 Fix for generated migration index files in test 2022-08-12 15:54:09 +12:00
Rob Bygrave d703709f14 #2784 - Correct documentation for TQRootBean.findSingleAttribute with @Nullable 2022-08-12 15:50:17 +12:00
FloandGitHub e8afba7ed2 Use fetch size 1 instead of Integer.MIN_VALUE 2022-08-10 19:26:40 +02:00
FloandGitHub dd5bb3edff Bump mariadb-java-client to 3.0.7 2022-08-10 12:48:02 +02:00
Rob Bygrave 475b05052e Refactor rename internal methods for SpiQueryPlan and DbReadContext
Change the getter methods to use accessor style
2022-08-09 15:43:16 +12:00
Rob Bygrave 4cc012b974 Bump to 13.7.1-SNAPSHOT 2022-08-09 14:26:04 +12:00
609 changed files with 3846 additions and 4236 deletions
+9 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>composites</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean-clickhouse</name>
@@ -16,13 +16,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -35,14 +35,18 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-clickhouse</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
<scm>
<tag>ebean-parent-13.9.1</tag>
</scm>
</project>
+9 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>composites</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean-cockroach</name>
@@ -16,13 +16,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -35,14 +35,18 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
<scm>
<tag>ebean-parent-13.9.1</tag>
</scm>
</project>
+9 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>composites</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean-db2</name>
@@ -16,13 +16,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -35,14 +35,18 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-db2</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
<scm>
<tag>ebean-parent-13.9.1</tag>
</scm>
</project>
+9 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>composites</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean-h2</name>
@@ -16,13 +16,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -35,14 +35,18 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-h2</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
<scm>
<tag>ebean-parent-13.9.1</tag>
</scm>
</project>
+9 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>composites</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean-hana</name>
@@ -16,13 +16,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -35,14 +35,18 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-hana</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
<scm>
<tag>ebean-parent-13.9.1</tag>
</scm>
</project>
+9 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>composites</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean-mariadb</name>
@@ -16,13 +16,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -35,14 +35,18 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-mariadb</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
<scm>
<tag>ebean-parent-13.9.1</tag>
</scm>
</project>
+9 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>composites</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean-mysql</name>
@@ -16,13 +16,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -35,14 +35,18 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-mysql</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
<scm>
<tag>ebean-parent-13.9.1</tag>
</scm>
</project>
+9 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>composites</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean-nuodb</name>
@@ -16,13 +16,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -35,14 +35,18 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-nuodb</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
<scm>
<tag>ebean-parent-13.9.1</tag>
</scm>
</project>
+9 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>composites</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean-oracle</name>
@@ -16,13 +16,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -35,14 +35,18 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-oracle</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
<scm>
<tag>ebean-parent-13.9.1</tag>
</scm>
</project>
+9 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>composites</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean-postgres</name>
@@ -16,13 +16,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -35,14 +35,18 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
<scm>
<tag>ebean-parent-13.9.1</tag>
</scm>
</project>
+9 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>composites</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean-sqlite</name>
@@ -16,13 +16,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -35,14 +35,18 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-sqlite</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
<scm>
<tag>ebean-parent-13.9.1</tag>
</scm>
</project>
+9 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>composites</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean-sqlserver</name>
@@ -16,13 +16,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -35,14 +35,18 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-sqlserver</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
<scm>
<tag>ebean-parent-13.9.1</tag>
</scm>
</project>
+9 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>composites</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean-yugabyte</name>
@@ -16,13 +16,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -35,14 +35,18 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
<scm>
<tag>ebean-parent-13.9.1</tag>
</scm>
</project>
+15 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>composites</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean (all platforms)</name>
@@ -16,13 +16,19 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-joda-time</artifactId>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -35,14 +41,18 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-all</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
<scm>
<tag>ebean-parent-13.9.1</tag>
</scm>
</project>
+1 -1
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<artifactId>composites</artifactId>
+21 -17
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean api</name>
@@ -13,15 +13,17 @@
<dependencies>
<!--
Projects are expected to explicit depend on version
of slf4j that they want to use
-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
<scope>provided</scope>
<groupId>io.avaje</groupId>
<artifactId>avaje-applog</artifactId>
<version>1.0</version>
</dependency>
<!-- exclude avaje-applog-slf4j to direct logging to something else -->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-applog-slf4j</artifactId>
<version>1.0</version>
</dependency>
<dependency>
@@ -30,12 +32,6 @@
<version>2.2</version>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-applog-slf4j</artifactId>
<version>1.0</version>
</dependency>
<!--
Class retention Nonnull and Nullable annotations
to assist with IDE auto-completion with Ebean API
@@ -49,7 +45,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>persistence-api</artifactId>
<version>3.0</version>
<version>${ebean-persistence-api.version}</version>
</dependency>
<dependency>
@@ -61,7 +57,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-types</artifactId>
<version>3.0</version>
<version>${ebean-types.version}</version>
</dependency>
<dependency>
@@ -70,6 +66,14 @@
<version>${ebean-datasource.version}</version>
</dependency>
<!-- Support MdcBackgroundExecutorWrapper -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
<optional>true</optional>
</dependency>
<!-- Jackson core used internally by Ebean -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
-7
View File
@@ -5,7 +5,6 @@ import io.avaje.lang.Nullable;
import io.ebean.annotation.TxIsolation;
import io.ebean.cache.ServerCacheManager;
import io.ebean.plugin.Property;
import io.ebean.text.csv.CsvReader;
import io.ebean.text.json.JsonContext;
import javax.persistence.OptimisticLockException;
@@ -785,12 +784,6 @@ public final class DB {
return getDefault().createUpdate(beanType, ormUpdate);
}
/**
* Create a CsvReader for a given beanType.
*/
public static <T> CsvReader<T> createCsvReader(Class<T> beanType) {
return getDefault().createCsvReader(beanType);
}
/**
* Create a named query.
@@ -9,7 +9,6 @@ import io.ebean.config.DatabaseConfig;
import io.ebean.meta.MetaInfoManager;
import io.ebean.plugin.Property;
import io.ebean.plugin.SpiServer;
import io.ebean.text.csv.CsvReader;
import io.ebean.text.json.JsonContext;
import javax.persistence.OptimisticLockException;
@@ -204,10 +203,6 @@ public interface Database {
*/
<T> T createEntityBean(Class<T> type);
/**
* Create a CsvReader for a given beanType.
*/
<T> CsvReader<T> createCsvReader(Class<T> beanType);
/**
* Create an Update query to perform a bulk update.
@@ -2,20 +2,20 @@ package io.ebean;
import io.ebean.config.BeanNotEnhancedException;
import io.ebean.datasource.DataSourceConfigurationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.persistence.PersistenceException;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
import static java.lang.System.Logger.Level.ERROR;
/**
* Holds Database instances.
*/
final class DbContext {
private static final Logger log = LoggerFactory.getLogger("io.ebean");
private static final System.Logger log = EbeanVersion.log;
static {
EbeanVersion.getVersion();
}
@@ -23,14 +23,9 @@ final class DbContext {
private static final DbContext INSTANCE = new DbContext();
private final ConcurrentHashMap<String, Database> concMap = new ConcurrentHashMap<>();
private final HashMap<String, Database> syncMap = new HashMap<>();
private final ReentrantLock lock = new ReentrantLock();
/**
* The 'default' Database.
*/
private Database defaultDatabase;
private DbContext() {
@@ -52,7 +47,7 @@ final class DbContext {
throw new DataSourceConfigurationException(msg, e);
} catch (Throwable e) {
log.error("Error trying to create the default Database", e);
log.log(ERROR, "Error trying to create the default Database", e);
throw new RuntimeException(e);
}
}
@@ -69,9 +64,9 @@ final class DbContext {
*/
Database getDefault() {
if (defaultDatabase == null) {
String msg = "The default Database has not been defined?";
msg += " This is normally set via the ebean.datasource.default property.";
msg += " Otherwise it should be registered programmatically via registerServer()";
String msg = "The default Database has not been defined?"
+ " This is normally set via the ebean.datasource.default property."
+ " Otherwise it should be registered programmatically via registerServer()";
throw new PersistenceException(msg);
}
return defaultDatabase;
@@ -2,6 +2,28 @@ package io.ebean;
/**
* Thrown when a duplicate is attempted on a unique constraint.
* <p>
* In terms of catching this exception with the view of continuing processing
* using the same transaction look to use {@link Transaction#rollbackAndContinue()}.
*
* <pre>{@code
*
* try (Transaction txn = database.beginTransaction()) {
*
* try {
* ...
* database.save(bean);
* database.flush();
* } catch (DuplicateKeyException e) {
* // carry on processing using the transaction
* txn.rollbackAndContinue();
* ...
* }
*
* txn.commit();
* }
*
* }</pre>
*/
public class DuplicateKeyException extends DataIntegrityException {
private static final long serialVersionUID = -4771932723285724817L;
@@ -1,11 +1,15 @@
package io.ebean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.avaje.applog.AppLog;
import java.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.Properties;
import static java.lang.System.Logger.Level.*;
/**
* Class to determine the ebean version.
*
@@ -13,7 +17,7 @@ import java.util.Properties;
*/
public final class EbeanVersion {
private static final Logger log = LoggerFactory.getLogger("io.ebean");
public static final System.Logger log = AppLog.getLogger("io.ebean");
/**
* Maintain the minimum ebean-agent version manually based on required ebean-agent bug fixes.
@@ -21,6 +25,7 @@ public final class EbeanVersion {
private static final int MIN_AGENT_MAJOR_VERSION = 12;
private static final int MIN_AGENT_MINOR_VERSION = 12;
private static String version = "unknown";
static {
readVersion();
checkAgentVersion();
@@ -32,12 +37,12 @@ public final class EbeanVersion {
if (in != null) {
try (LineNumberReader reader = new LineNumberReader(new InputStreamReader(in))) {
version = reader.readLine();
log.log(INFO, "ebean version: {0}", version);
}
}
}
log.info("ebean version: {}", version);
} catch (IOException e) {
log.warn("Could not determine ebean version: {}", e.getMessage());
log.log(WARNING, "Could not determine ebean version: {0}", e.getMessage());
}
}
@@ -49,13 +54,13 @@ public final class EbeanVersion {
String agentVersion = readVersion(in);
if (agentVersion != null) {
if (checkMinAgentVersion(agentVersion)) {
log.error("Expected minimum ebean-agent version {}.{}.0 but we have {}, please update the ebean-agent", MIN_AGENT_MAJOR_VERSION, MIN_AGENT_MINOR_VERSION, agentVersion);
log.log(ERROR, "Expected minimum ebean-agent version {0}.{1}.0 but we have {2}, please update the ebean-agent", MIN_AGENT_MAJOR_VERSION, MIN_AGENT_MINOR_VERSION, agentVersion);
}
}
}
}
} catch (IOException e) {
log.warn("Could not check minimum ebean-agent version {}.{}.0 required due to - {}", MIN_AGENT_MAJOR_VERSION, MIN_AGENT_MINOR_VERSION, e.getMessage());
log.log(WARNING, "Could not check minimum ebean-agent version {0}.{1}.0 required due to - {2}", MIN_AGENT_MAJOR_VERSION, MIN_AGENT_MINOR_VERSION, e.getMessage());
}
}
+2 -1
View File
@@ -931,7 +931,7 @@ public interface Query<T> extends CancelableQuery {
<A> Set<A> findSingleAttributeSet();
/**
* Execute a query returning a single value of a single property/column.
* Execute a query returning a single value or null for a single property/column.
* <p>
* <pre>{@code
*
@@ -943,6 +943,7 @@ public interface Query<T> extends CancelableQuery {
*
* }</pre>
*/
@Nullable
<A> A findSingleAttribute();
/**
@@ -144,6 +144,35 @@ public interface Transaction extends AutoCloseable {
*/
void rollback(Throwable e) throws PersistenceException;
/**
* Performs a rollback on the underlying JDBC connection with the intention of
* continuing to use this same transaction and performing a commit or rollback
* later to complete the transaction.
* <p>
* Typically used when catching {@link DuplicateKeyException} where we wish to
* rollback work done at that point but carry on processing using the transaction.
*
* <pre>{@code
*
* try (Transaction txn = database.beginTransaction()) {
*
* try {
* ...
* database.save(bean);
* database.flush();
* } catch (DuplicateKeyException e) {
* // carry on processing using the transaction
* txn.rollbackAndContinue();
* ...
* }
*
* txn.commit();
* }
*
* }</pre>
*/
void rollbackAndContinue();
/**
* Set when we want nested transactions to use Savepoint's.
* <p>
@@ -237,7 +237,7 @@ public abstract class AbstractNamingConvention implements NamingConvention {
}
buffer.append(rhsTableName);
int maxTableNameLength = databasePlatform.getMaxTableNameLength();
int maxTableNameLength = databasePlatform.maxTableNameLength();
// maxConstraintNameLength is used as the max table name length.
if (buffer.length() > maxTableNameLength) {
@@ -3024,7 +3024,7 @@ public class DatabaseConfig {
public PersistBatch appliedPersistBatchOnCascade() {
if (persistBatchOnCascade == PersistBatch.INHERIT) {
// use the platform default (ALL except SQL Server which has NONE)
return databasePlatform.getPersistBatchOnCascade();
return databasePlatform.persistBatchOnCascade();
}
return persistBatchOnCascade;
}
@@ -1,49 +1,26 @@
package io.ebean.config.dbplatform;
import io.ebean.BackgroundExecutor;
import io.ebean.EbeanVersion;
import io.ebean.Query;
import io.ebean.annotation.PartitionMode;
import io.ebean.annotation.PersistBatch;
import io.ebean.annotation.Platform;
import io.ebean.config.CustomDbTypeMapping;
import io.ebean.config.PlatformConfig;
import io.ebean.util.JdbcClose;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.persistence.PersistenceException;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
import java.sql.*;
import static java.lang.System.Logger.Level.*;
/**
* Database platform specific settings.
*/
public class DatabasePlatform {
private static final Logger log = LoggerFactory.getLogger("io.ebean");
/**
* Behavior used when ending a query only transaction (at read committed isolation level).
*/
public enum OnQueryOnly {
/**
* Rollback the transaction.
*/
ROLLBACK,
/**
* Commit the transaction
*/
COMMIT
}
private static final System.Logger log = EbeanVersion.log;
/**
* Set to true for MySql, no other jdbc drivers need this workaround.
@@ -60,16 +37,11 @@ public class DatabasePlatform {
* Can we use native java time API objects in
* {@link ResultSet#getObject(int, Class)} and
* {@link PreparedStatement#setObject(int, Object)}.
*
* <p>
* Not all drivers (DB2 e.g.) will support this.
*/
protected boolean supportsNativeJavaTime = true;
/**
* The behaviour used when ending a read only transaction at read committed isolation level.
*/
protected OnQueryOnly onQueryOnly = OnQueryOnly.COMMIT;
/**
* The open quote used by quoted identifiers.
*/
@@ -146,11 +118,6 @@ public class DatabasePlatform {
*/
protected int clobDbType = Types.CLOB;
/**
* For Oracle treat empty strings as null.
*/
protected boolean treatEmptyStringsAsNull;
/**
* The database platform name.
*/
@@ -165,7 +132,7 @@ public class DatabasePlatform {
* want to use quoted identifiers for. The backticks get converted to the
* appropriate characters in convertQuotedIdentifiers
*/
private static final char[] QUOTED_IDENTIFIERS = new char[] { '"', '\'', '[', ']', '`' };
private static final char[] QUOTED_IDENTIFIERS = new char[]{'"', '\'', '[', ']', '`'};
/**
* The non-escaped like clause (to stop slash being escaped on some platforms).
@@ -299,7 +266,7 @@ public class DatabasePlatform {
/**
* Return the platform key.
*/
public Platform getPlatform() {
public Platform platform() {
return platform;
}
@@ -309,14 +276,14 @@ public class DatabasePlatform {
* "generic" is returned when no specific database platform has been set or found.
* </p>
*/
public String getName() {
public String name() {
return platform.name().toLowerCase();
}
/**
* Return true if we are using Sequence batch mode rather than STEP.
*/
public boolean isSequenceBatchMode() {
public boolean sequenceBatchMode() {
return sequenceBatchMode;
}
@@ -330,52 +297,52 @@ public class DatabasePlatform {
/**
* Return true if this database platform supports native ILIKE expression.
*/
public boolean isSupportsNativeIlike() {
public boolean supportsNativeIlike() {
return supportsNativeIlike;
}
/**
* Return true if the platform supports delete statements with table alias.
*/
public boolean isSupportsDeleteTableAlias() {
public boolean supportsDeleteTableAlias() {
return supportsDeleteTableAlias;
}
/**
* Return true if the collation is case sensitive.
* Return true if the collation is case-sensitive.
* <p>
* This is expected to be used for testing only.
* </p>
*/
public boolean isCaseSensitiveCollation() {
public boolean caseSensitiveCollation() {
return caseSensitiveCollation;
}
/**
* Return true if the platform supports SavepointId values.
*/
public boolean isSupportsSavepointId() {
public boolean supportsSavepointId() {
return supportsSavepointId;
}
/**
* Return true if migrations should use stored procedures.
*/
public boolean isUseMigrationStoredProcedures() {
public boolean useMigrationStoredProcedures() {
return useMigrationStoredProcedures;
}
/**
* Return true if the platform supports LIMIT with sql update.
*/
public boolean isInlineSqlUpdateLimit() {
public boolean inlineSqlUpdateLimit() {
return inlineSqlUpdateLimit;
}
/**
* Return the maximum number of bind values this database platform allows or zero for no limit.
*/
public int getMaxInBinding() {
public int maxInBinding() {
return maxInBinding;
}
@@ -385,14 +352,14 @@ public class DatabasePlatform {
* This is used when deriving names of intersection tables.
* </p>
*/
public int getMaxTableNameLength() {
public int maxTableNameLength() {
return maxTableNameLength;
}
/**
* Return the maximum constraint name allowed for the platform.
*/
public int getMaxConstraintNameLength() {
public int maxConstraintNameLength() {
return maxConstraintNameLength;
}
@@ -420,24 +387,10 @@ public class DatabasePlatform {
return null;
}
/**
* Return the behaviour to use when ending a read only transaction.
*/
public OnQueryOnly getOnQueryOnly() {
return onQueryOnly;
}
/**
* Set the behaviour to use when ending a read only transaction.
*/
public void setOnQueryOnly(OnQueryOnly onQueryOnly) {
this.onQueryOnly = onQueryOnly;
}
/**
* Return the DbEncrypt handler for this DB platform.
*/
public DbEncrypt getDbEncrypt() {
public DbEncrypt dbEncrypt() {
return dbEncrypt;
}
@@ -451,7 +404,7 @@ public class DatabasePlatform {
/**
* Return the history support for this database platform.
*/
public DbHistorySupport getHistorySupport() {
public DbHistorySupport historySupport() {
return historySupport;
}
@@ -465,14 +418,14 @@ public class DatabasePlatform {
/**
* So no except for Postgres and CockroachDB.
*/
public boolean isNativeArrayType() {
public boolean nativeArrayType() {
return false;
}
/**
* Return true if the DB supports native UUID.
*/
public boolean isNativeUuidType() {
public boolean nativeUuidType() {
return nativeUuidType;
}
@@ -481,21 +434,21 @@ public class DatabasePlatform {
*
* @return the db type map
*/
public DbPlatformTypeMapping getDbTypeMap() {
public DbPlatformTypeMapping dbTypeMap() {
return dbTypeMap;
}
/**
* Return the mapping for DB column default values.
*/
public DbDefaultValue getDbDefaultValue() {
public DbDefaultValue dbDefaultValue() {
return dbDefaultValue;
}
/**
* Return the column alias prefix.
*/
public String getColumnAliasPrefix() {
public String columnAliasPrefix() {
return columnAliasPrefix;
}
@@ -509,21 +462,21 @@ public class DatabasePlatform {
/**
* Return the close quote for quoted identifiers.
*/
public String getCloseQuote() {
public String closeQuote() {
return closeQuote;
}
/**
* Return the open quote for quoted identifiers.
*/
public String getOpenQuote() {
public String openQuote() {
return openQuote;
}
/**
* Return the JDBC type used to store booleans.
*/
public int getBooleanDbType() {
public int booleanDbType() {
return booleanDbType;
}
@@ -534,7 +487,7 @@ public class DatabasePlatform {
* example.
* </p>
*/
public int getBlobDbType() {
public int blobDbType() {
return blobDbType;
}
@@ -544,25 +497,16 @@ public class DatabasePlatform {
* This is typically Types.CLOB but for Postgres is Types.VARCHAR.
* </p>
*/
public int getClobDbType() {
public int clobDbType() {
return clobDbType;
}
/**
* Return true if empty strings should be treated as null.
*
* @return true, if checks if is treat empty strings as null
*/
public boolean isTreatEmptyStringsAsNull() {
return treatEmptyStringsAsNull;
}
/**
* Return true if a compound ID in (...) type expression needs to be in
* expanded form of (a=? and b=?) or (a=? and b=?) or ... rather than (a,b) in
* ((?,?),(?,?),...);
*/
public boolean isIdInExpandedForm() {
public boolean idInExpandedForm() {
return idInExpandedForm;
}
@@ -573,7 +517,7 @@ public class DatabasePlatform {
* This specifically is required for MySql when processing large results.
* </p>
*/
public boolean isForwardOnlyHintOnFindIterate() {
public boolean forwardOnlyHintOnFindIterate() {
return forwardOnlyHintOnFindIterate;
}
@@ -591,7 +535,7 @@ public class DatabasePlatform {
* This specifically is required for Hana which doesn't support CONCUR_UPDATABLE
* </p>
*/
public boolean isSupportsResultSetConcurrencyModeUpdatable() {
public boolean supportsResultSetConcurrencyModeUpdatable() {
return supportsResultSetConcurrencyModeUpdatable;
}
@@ -611,7 +555,7 @@ public class DatabasePlatform {
*
* @return the db identity
*/
public DbIdentity getDbIdentity() {
public DbIdentity dbIdentity() {
return dbIdentity;
}
@@ -624,14 +568,14 @@ public class DatabasePlatform {
*
* @return the sql limiter
*/
public SqlLimiter getSqlLimiter() {
public SqlLimiter sqlLimiter() {
return sqlLimiter;
}
/**
* Return the BasicSqlLimiter for limit/offset of SqlQuery queries.
*/
public BasicSqlLimiter getBasicSqlLimiter() {
public BasicSqlLimiter basicSqlLimiter() {
return basicSqlLimiter;
}
@@ -666,7 +610,7 @@ public class DatabasePlatform {
if (isQuote(dbName.charAt(dbName.length() - 1))) {
return openQuote + dbName.substring(1, dbName.length() - 1) + closeQuote;
} else {
log.error("Missing backquote on [" + dbName + "]");
log.log(ERROR, "Missing backquote on [" + dbName + "]");
}
} else if (allQuotedIdentifiers) {
return openQuote + dbName + closeQuote;
@@ -676,8 +620,8 @@ public class DatabasePlatform {
}
private boolean isQuote(char ch) {
for (char identifer : QUOTED_IDENTIFIERS) {
if (identifer == ch) {
for (char identifier : QUOTED_IDENTIFIERS) {
if (identifier == ch) {
return true;
}
}
@@ -700,14 +644,14 @@ public class DatabasePlatform {
/**
* Set to true if select count against anonymous view requires an alias.
*/
public boolean isSelectCountWithAlias() {
public boolean selectCountWithAlias() {
return selectCountWithAlias;
}
/**
* Return true if select count with subquery needs column alias (SQL Server).
*/
public boolean isSelectCountWithColumnAlias() {
public boolean selectCountWithColumnAlias() {
return selectCountWithColumnAlias;
}
@@ -729,7 +673,7 @@ public class DatabasePlatform {
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
// silently assume the database does not support the "for update" clause.
log.info("it seems your database does not support the 'for update' clause");
log.log(INFO, "it seems your database does not support the 'for update' clause");
return sql;
}
@@ -738,14 +682,14 @@ public class DatabasePlatform {
* <p>
* This may include an escape clause to disable a default escape character.
*/
public String getLikeClause(boolean rawLikeExpression) {
public String likeClause(boolean rawLikeExpression) {
return rawLikeExpression ? likeClauseRaw : likeClauseEscaped;
}
/**
* Return the platform default JDBC batch mode for persist cascade.
*/
public PersistBatch getPersistBatchOnCascade() {
public PersistBatch persistBatchOnCascade() {
return persistBatchOnCascade;
}
@@ -763,7 +707,7 @@ public class DatabasePlatform {
if (!schemaExists(dbSchema, connection)) {
Statement query = connection.createStatement();
try {
log.debug("create schema:{}", dbSchema);
log.log(DEBUG, "create schema:{0}", dbSchema);
query.executeUpdate("create schema " + dbSchema);
} finally {
JdbcClose.close(query);
@@ -789,19 +733,6 @@ public class DatabasePlatform {
return false;
}
/**
* Return true if the table exists.
*/
public boolean tableExists(Connection connection, String catalog, String schema, String table) throws SQLException {
DatabaseMetaData metaData = connection.getMetaData();
ResultSet tables = metaData.getTables(catalog, schema, table, null);
try {
return tables.next();
} finally {
JdbcClose.close(tables);
}
}
/**
* Escapes the like string for this DB-Platform
*/
@@ -1,10 +1,9 @@
package io.ebean.config.dbplatform;
import io.avaje.applog.AppLog;
import io.ebean.BackgroundExecutor;
import io.ebean.Transaction;
import io.ebean.util.JdbcClose;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.persistence.PersistenceException;
import javax.sql.DataSource;
@@ -19,12 +18,15 @@ import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantLock;
import static java.lang.System.Logger.Level.DEBUG;
import static java.lang.System.Logger.Level.ERROR;
/**
* Database sequence based IdGenerator.
*/
public abstract class SequenceIdGenerator implements PlatformIdGenerator {
protected static final Logger log = LoggerFactory.getLogger("io.ebean.SEQ");
protected static final System.Logger log = AppLog.getLogger("io.ebean.SEQ");
private final ReentrantLock lock = new ReentrantLock();
protected final String seqName;
@@ -120,7 +122,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
protected void loadInBackground(final int requestSize) {
if (currentlyBackgroundLoading.get()) {
// skip as already background loading
log.debug("... skip background sequence load (another load in progress)");
log.log(DEBUG, "... skip background sequence load (another load in progress)");
return;
}
currentlyBackgroundLoading.set(true);
@@ -152,9 +154,6 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
resultSet = statement.executeQuery();
List<Long> newIds = readIds(resultSet, requestSize);
if (log.isTraceEnabled()) {
log.trace("seq:{} loaded:{} sql:{}", seqName, newIds.size(), sql);
}
if (newIds.isEmpty()) {
throw new PersistenceException("Always expecting more than 1 row from " + sql);
}
@@ -164,7 +163,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
} catch (SQLException e) {
if (e.getMessage().contains("Database is already closed")) {
String msg = "Error getting SEQ when DB shutting down " + e.getMessage();
log.error(msg);
log.log(ERROR, msg);
System.out.println(msg);
return Collections.emptyList();
} else {
@@ -32,7 +32,12 @@ public class SqlCodeTranslator implements SqlExceptionTranslator {
}
private DataErrorType getErrorType(SQLException e) {
DataErrorType errorType = map.get(e.getSQLState());
String sqlState = e.getSQLState();
while (sqlState == null && e.getCause() instanceof SQLException) {
e = (SQLException)e.getCause();
sqlState = e.getSQLState();
}
DataErrorType errorType = map.get(sqlState);
if (errorType == null) {
// fall back to error code
errorType = map.get(String.valueOf(e.getErrorCode()));
@@ -1,9 +1,8 @@
package io.ebean.event;
import io.ebean.Database;
import io.ebean.EbeanVersion;
import io.ebean.service.SpiContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Driver;
import java.sql.DriverManager;
@@ -13,6 +12,8 @@ import java.util.Enumeration;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
import static java.lang.System.Logger.Level.*;
/**
* Manages the shutdown of Ebean.
* <p>
@@ -20,13 +21,14 @@ import java.util.concurrent.locks.ReentrantLock;
*/
public final class ShutdownManager {
private static final Logger log = LoggerFactory.getLogger("io.ebean");
private static final System.Logger log = EbeanVersion.log;
private static final ReentrantLock lock = new ReentrantLock();
private static final List<Database> databases = new ArrayList<>();
private static final ShutdownHook shutdownHook = new ShutdownHook();
private static boolean stopping;
private static SpiContainer container;
static {
// Register the Shutdown hook
registerShutdownHook();
@@ -120,9 +122,7 @@ public final class ShutdownManager {
// Already run shutdown...
return;
}
if (log.isDebugEnabled()) {
log.debug("Ebean shutting down");
}
log.log(DEBUG, "Ebean shutting down");
stopping = true;
deregisterShutdownHook();
@@ -133,7 +133,7 @@ public final class ShutdownManager {
Runnable r = (Runnable) ClassUtil.newInstance(shutdownRunner);
r.run();
} catch (Exception e) {
log.error("Error running custom shutdown runnable", e);
log.log(ERROR, "Error running custom shutdown runnable", e);
}
}
@@ -147,7 +147,7 @@ public final class ShutdownManager {
try {
server.shutdown();
} catch (Exception ex) {
log.error("Error executing shutdown runnable", ex);
log.log(ERROR, "Error executing shutdown runnable", ex);
ex.printStackTrace();
}
}
@@ -165,10 +165,10 @@ public final class ShutdownManager {
while (drivers.hasMoreElements()) {
Driver driver = drivers.nextElement();
try {
log.info("De-registering jdbc driver: " + driver);
log.log(INFO, "De-registering jdbc driver: " + driver);
DriverManager.deregisterDriver(driver);
} catch (SQLException e) {
log.error("Error de-registering driver " + driver, e);
log.log(ERROR, "Error de-registering driver " + driver, e);
}
}
}
@@ -204,6 +204,7 @@ public final class ShutdownManager {
private ShutdownHook() {
super("EbeanHook");
}
@Override
public void run() {
ShutdownManager.shutdown();
@@ -39,18 +39,6 @@ public interface ExpressionPath {
*/
StringParser stringParser();
/**
* For DateTime capable scalar types convert the long systemTimeMillis into
* an appropriate java time (Date,Timestamp,Time,Calendar, JODA type etc).
*/
Object parseDateTime(long systemTimeMillis);
/**
* Return true if the last type is "DateTime capable" - can support
* {@link #parseDateTime(long)}.
*/
boolean isDateTimeCapable();
/**
* Return the underlying JDBC type or 0 if this is not a scalar type.
*/
@@ -6,6 +6,7 @@ package io.ebean.text;
* Basic interface to support CSV, JSON and XML processing.
* </p>
*/
@FunctionalInterface
public interface StringFormatter {
/**
@@ -5,6 +5,7 @@ package io.ebean.text;
* <p>
* Basic interface to support CSV, JSON and XML processing.
*/
@FunctionalInterface
public interface StringParser {
/**
@@ -1,171 +0,0 @@
package io.ebean.text.csv;
import io.ebean.text.StringParser;
import java.io.Reader;
import java.util.Locale;
/**
* Reads CSV data turning it into object graphs that you can be saved (inserted)
* or processed yourself.
* <p>
* This first example doesn't use a {@link CsvCallback} and this means it will
* automatically create a transaction, save the customers and commit the
* transaction when successful.
* </p>
*
* <pre>{@code
* try {
* File f = new File("src/test/resources/test1.csv");
*
* FileReader reader = new FileReader(f, encoding);
*
* CsvReader<Customer> csvReader = DB.createCsvReader(Customer.class);
*
* csvReader.setPersistBatchSize(20);
*
* csvReader.addProperty("status");
* // ignore the next property
* csvReader.addIgnore();
* csvReader.addProperty("name");
* csvReader.addDateTime("anniversary", "dd-MMM-yyyy");
* csvReader.addProperty("billingAddress.line1");
* csvReader.addProperty("billingAddress.city");
*
* csvReader.process(reader);
*
* } catch (Exception e) {
* throw new RuntimeException(e);
* }
* }</pre>
*
* @param <T> the entity bean type
*/
public interface CsvReader<T> {
/**
* Explicitly set the default Locale.
*/
void setDefaultLocale(Locale defaultLocale);
/**
* Set the default format to use for Time types.
*/
void setDefaultTimeFormat(String defaultTimeFormat);
/**
* Set the default format to use for Date types.
*/
void setDefaultDateFormat(String defaultDateFormat);
/**
* Set the default format to use for Timestamp types.
*/
void setDefaultTimestampFormat(String defaultTimestampFormat);
/**
* Set the batch size for using JDBC statement batching.
* <p>
* By default this is set to 20 and setting this to 1 will disable the use of
* JDBC statement batching.
* </p>
*/
void setPersistBatchSize(int persistBatchSize);
/**
* Set to true if there is a header row that should be ignored.
* <p>
* If addPropertiesFromHeader is true then all the properties are added using
* the default time,date and timestamp formats.
* <p>
* If you have a mix of dateTime formats you can not use this method and must
* add the properties yourself.
* </p>
*/
void setHasHeader(boolean hasHeader, boolean addPropertiesFromHeader);
/**
* Same as setHasHeader(true,true);
* <p>
* This will use a header to define all the properties to load using the
* default formats for time, date and datetime types.
* </p>
*/
void setAddPropertiesFromHeader();
/**
* Same as setHasHeader(true, false);
* <p>
* This indicates that there is a header but that it should be ignored.
* </p>
*/
void setIgnoreHeader();
/**
* Set the frequency with which a INFO message will be logged showing the
* progress of the processing. You might set this to 1000 or 10000 etc.
* <p>
* If this is not set then no INFO messages will be logged.
* </p>
*/
void setLogInfoFrequency(int logInfoFrequency);
/**
* Ignore the next column of data.
*/
void addIgnore();
/**
* Define the property which will be loaded from the next column of data.
* <p>
* This takes into account the data type of the property and handles the
* String to object conversion automatically.
* </p>
*/
void addProperty(String propertyName);
/**
* Define the next property and use a custom StringParser to convert the
* string content into the appropriate type for the property.
*/
void addProperty(String propertyName, StringParser parser);
/**
* Add a property with a custom Date/Time/Timestamp format using the default
* Locale. This will convert the string into the appropriate java type for the
* given property (Date, Calendar, SQL Date, Time, Timestamp, JODA etc).
*/
void addDateTime(String propertyName, String dateTimeFormat);
/**
* Add a property with a custom Date/Time/Timestamp format. This will convert
* the string into the appropriate java type for the given property (Date,
* Calendar, SQL Date, Time, Timestamp, JODA etc).
*/
void addDateTime(String propertyName, String dateTimeFormat, Locale locale);
/**
* Automatically create a transaction if required to process all the CSV
* content from the reader.
* <p>
* This will check for a current transaction. If there is no current
* transaction then one is started and will commit (or rollback) at the end of
* processing. This will also set the persistBatchSize on the transaction.
* </p>
*/
void process(Reader reader) throws Exception;
/**
* Process the CSV content passing the bean to the CsvCallback after each row.
* <p>
* This provides you with the ability to modify and process the bean.
* </p>
* <p>
* When using a CsvCallback the reader WILL NOT create a transaction or save
* the bean(s) for you. If you want to insert the processed beans you must
* create your own transaction and save the bean(s) yourself.
* </p>
*/
void process(Reader reader, CsvCallback<T> callback) throws Exception;
}
@@ -1,4 +0,0 @@
/**
* CSV processing objects.
*/
package io.ebean.text.csv;
@@ -1,19 +1,20 @@
package io.ebean.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.ebean.EbeanVersion;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import static java.lang.System.Logger.Level.WARNING;
/**
* Utility for closing raw Jdbc resources.
*/
public final class JdbcClose {
private static final Logger log = LoggerFactory.getLogger("io.ebean");
private static final System.Logger log = EbeanVersion.log;
/**
* Close the resultSet logging if an error occurs.
@@ -24,7 +25,7 @@ public final class JdbcClose {
statement.close();
}
} catch (SQLException e) {
log.warn("Error closing statement", e);
log.log(WARNING, "Error closing statement", e);
}
}
@@ -37,7 +38,7 @@ public final class JdbcClose {
resultSet.close();
}
} catch (SQLException e) {
log.warn("Error closing resultSet", e);
log.log(WARNING, "Error closing resultSet", e);
}
}
@@ -50,7 +51,7 @@ public final class JdbcClose {
connection.close();
}
} catch (SQLException e) {
log.warn("Error closing connection", e);
log.log(WARNING, "Error closing connection", e);
}
}
@@ -63,7 +64,7 @@ public final class JdbcClose {
connection.rollback();
}
} catch (SQLException e) {
log.warn("Error on connection rollback", e);
log.log(WARNING, "Error on connection rollback", e);
}
}
@@ -76,7 +77,7 @@ public final class JdbcClose {
stmt.cancel();
}
} catch (SQLException e) {
log.warn("Error on cancelling statement", e);
log.log(WARNING, "Error on cancelling statement", e);
}
}
}
+2 -2
View File
@@ -15,8 +15,9 @@ module io.ebean.api {
requires transitive persistence.api;
requires transitive io.ebean.annotation;
requires transitive io.ebean.datasource.api;
requires transitive org.slf4j;
requires transitive io.avaje.applog;
requires static org.slf4j;
requires static io.ebean.types;
requires static com.fasterxml.jackson.core;
requires static com.fasterxml.jackson.databind;
@@ -39,7 +40,6 @@ module io.ebean.api {
exports io.ebean.service;
exports io.ebean.text;
exports io.ebean.text.json;
exports io.ebean.text.csv;
exports io.ebean.util;
}
+8 -13
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<!-- <parent>-->
<!-- <groupId>org.avaje</groupId>-->
@@ -14,7 +14,7 @@
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>HEAD</tag>
<tag>ebean-parent-13.9.1</tag>
</scm>
<name>ebean autotune</name>
@@ -26,21 +26,16 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
<scope>provided</scope>
</dependency>
<!-- needed for java 11+ -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>4.0.0</version>
<scope>runtime</scope>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.6</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -60,7 +55,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-h2</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
<scope>test</scope>
</dependency>
@@ -1,9 +1,9 @@
package io.ebeaninternal.server.autotune.model;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;
@@ -1,6 +1,6 @@
package io.ebeaninternal.server.autotune.model;
import jakarta.xml.bind.annotation.XmlRegistry;
import javax.xml.bind.annotation.XmlRegistry;
/**
@@ -1,10 +1,10 @@
package io.ebeaninternal.server.autotune.model;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
@@ -1,9 +1,9 @@
package io.ebeaninternal.server.autotune.model;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;
@@ -1,9 +1,9 @@
package io.ebeaninternal.server.autotune.model;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;
@@ -1,9 +1,9 @@
package io.ebeaninternal.server.autotune.model;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;
@@ -1,2 +1,2 @@
@jakarta.xml.bind.annotation.XmlSchema(namespace = "http://ebean-orm.github.io/xml/ns/autotune", elementFormDefault = jakarta.xml.bind.annotation.XmlNsForm.QUALIFIED)
@javax.xml.bind.annotation.XmlSchema(namespace = "http://ebean-orm.github.io/xml/ns/autotune", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package io.ebeaninternal.server.autotune.model;
@@ -3,9 +3,9 @@ package io.ebeaninternal.server.autotune.service;
import io.ebeaninternal.server.autotune.model.Autotune;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -3,9 +3,9 @@ package io.ebeaninternal.server.autotune.service;
import io.ebeaninternal.server.autotune.model.Autotune;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.autotune.service;
import io.avaje.applog.AppLog;
import io.ebean.config.AutoTuneConfig;
import io.ebean.config.DatabaseConfig;
import io.ebeaninternal.api.SpiEbeanServer;
@@ -7,8 +8,6 @@ import io.ebeaninternal.api.SpiQuery;
import io.ebeaninternal.server.autotune.AutoTuneService;
import io.ebeaninternal.server.autotune.model.Autotune;
import io.ebeaninternal.server.autotune.model.Origin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@@ -16,12 +15,14 @@ import java.io.InputStream;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import static java.lang.System.Logger.Level.*;
/**
* Implementation of the AutoTuneService which is comprised of profiling and query tuning.
*/
public class DefaultAutoTuneService implements AutoTuneService {
private static final Logger logger = LoggerFactory.getLogger(DefaultAutoTuneService.class);
private static final System.Logger logger = AppLog.getLogger(DefaultAutoTuneService.class);
private final ReentrantLock lock = new ReentrantLock();
@@ -111,7 +112,7 @@ public class DefaultAutoTuneService implements AutoTuneService {
if (stream != null) {
loadAutoTuneProfiling(AutoTuneXmlReader.read(stream));
} else {
logger.warn("AutoTune file {} not found - no initial automatic query tuning", tuningFile);
logger.log(WARNING, "AutoTune file {0} not found - no initial automatic query tuning", tuningFile);
}
} catch (IOException e) {
throw new IllegalStateException("Error on auto close of " + tuningFile, e);
@@ -120,7 +121,7 @@ public class DefaultAutoTuneService implements AutoTuneService {
}
private void loadAutoTuneProfiling(Autotune profiling) {
logger.info("AutoTune loading {} tuning entries", profiling.getOrigin().size());
logger.log(INFO, "AutoTune loading {0} tuning entries", profiling.getOrigin().size());
for (Origin origin : profiling.getOrigin()) {
queryTuner.put(origin);
}
@@ -141,17 +142,17 @@ public class DefaultAutoTuneService implements AutoTuneService {
event.process();
if (event.isEmpty()) {
long exeMillis = System.currentTimeMillis() - start;
logger.debug("No query tuning updates for server:{} executionMillis:{}", serverName, exeMillis);
logger.log(DEBUG, "No query tuning updates for server:{0} executionMillis:{1}", serverName, exeMillis);
} else {
// report the query tuning changes that have been made
runtimeChangeCount += event.getChangeCount();
event.writeFile(profilingFile + "-" + serverName + "-update");
long exeMillis = System.currentTimeMillis() - start;
logger.info("query tuning updates - new:{} diff:{} for server:{} executionMillis:{}", event.getNewCount(), event.getDiffCount(), serverName, exeMillis);
logger.log(INFO, "query tuning updates - new:{0} diff:{1} for server:{2} executionMillis:{3}", event.getNewCount(), event.getDiffCount(), serverName, exeMillis);
}
} catch (Throwable e) {
logger.error("Error collecting or applying automatic query tuning", e);
logger.log(ERROR, "Error collecting or applying automatic query tuning", e);
}
} finally {
lock.unlock();
@@ -172,11 +173,11 @@ public class DefaultAutoTuneService implements AutoTuneService {
AutoTuneDiffCollection event = new AutoTuneDiffCollection(profiling, queryTuner, false);
event.process();
if (event.isEmpty()) {
logger.info("No new or diff entries for profiling server:{}", serverName);
logger.log(INFO, "No new or diff entries for profiling server:{0}", serverName);
} else {
event.writeFile(profilingFile + "-" + serverName);
logger.info("writing new:{} diff:{} profiling entries for server:{}", event.getNewCount(), event.getDiffCount(), serverName);
logger.log(INFO, "writing new:{0} diff:{1} profiling entries for server:{2}", event.getNewCount(), event.getDiffCount(), serverName);
}
}
} finally {
@@ -196,7 +197,7 @@ public class DefaultAutoTuneService implements AutoTuneService {
private void outputAllTuning() {
if (runtimeChangeCount == 0) {
logger.info("no runtime query tuning changes for server:{}", serverName);
logger.log(INFO, "no runtime query tuning changes for server:{0}", serverName);
} else {
AutoTuneAllCollection event = new AutoTuneAllCollection(queryTuner);
@@ -205,12 +206,12 @@ public class DefaultAutoTuneService implements AutoTuneService {
if (existingTuning.exists()) {
// rename the existing autotune.xml file (appending 'now')
if (!existingTuning.renameTo(new File(tuningFile + "." + AutoTuneXmlWriter.now()))) {
logger.warn("Failed to rename autotune file [{}]", tuningFile);
logger.log(WARNING, "Failed to rename autotune file [{0}]", tuningFile);
}
}
event.writeFile(tuningFile, false);
logger.info("query tuning detected [{}] changes, writing all [{}] tuning entries for server:{}", runtimeChangeCount, size, serverName);
logger.log(INFO, "query tuning detected [{0}] changes, writing all [{1}] tuning entries for server:{2}", runtimeChangeCount, size, serverName);
}
}
@@ -279,7 +280,7 @@ public class DefaultAutoTuneService implements AutoTuneService {
} catch (InterruptedException e) {
// restore the interrupted status
Thread.currentThread().interrupt();
logger.warn("Error while sleeping after System.gc() request.", e);
logger.log(WARNING, "Error while sleeping after System.gc() request.", e);
}
}
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.autotune.service;
import io.avaje.applog.AppLog;
import io.ebean.bean.NodeUsageCollector;
import io.ebean.text.PathProperties;
import io.ebean.util.SplitName;
@@ -7,19 +8,19 @@ import io.ebeaninternal.server.deploy.BeanDescriptor;
import io.ebeaninternal.server.deploy.BeanProperty;
import io.ebeaninternal.server.deploy.BeanPropertyAssoc;
import io.ebeaninternal.server.el.ElPropertyValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
import static java.lang.System.Logger.Level.WARNING;
/**
* Collects usages statistics for a given node in the object graph.
*/
public class ProfileOriginNodeUsage {
private static final Logger logger = LoggerFactory.getLogger(ProfileOriginNodeUsage.class);
private static final System.Logger logger = AppLog.getLogger(ProfileOriginNodeUsage.class);
private final ReentrantLock lock = new ReentrantLock();
@@ -45,7 +46,7 @@ public class ProfileOriginNodeUsage {
if (path != null) {
ElPropertyValue elGetValue = rootDesc.elGetValue(path);
if (elGetValue == null) {
logger.warn("AutoTune: Can't find join for path[" + path + "] for " + rootDesc.name());
logger.log(WARNING, "AutoTune: Can't find join for path[" + path + "] for " + rootDesc.name());
return;
} else {
BeanProperty beanProperty = elGetValue.beanProperty();
@@ -61,7 +62,7 @@ public class ProfileOriginNodeUsage {
for (String propName : aggregateUsed) {
BeanProperty beanProp = desc.findPropertyFromPath(propName);
if (beanProp == null) {
logger.warn("AutoTune: Can't find property[" + propName + "] for " + desc.name());
logger.log(WARNING, "AutoTune: Can't find property[" + propName + "] for " + desc.name());
} else {
if (beanProp.isId()) {
@@ -10,5 +10,6 @@ module io.ebean.autotune {
requires io.ebean.api;
requires io.ebean.core;
requires jakarta.xml.bind;
requires java.xml;
requires java.xml.bind;
}
+32 -15
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<name>ebean bom</name>
@@ -18,12 +18,23 @@
<!-- dependencies external to this ebean.git build -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>persistence-api</artifactId>
<version>${ebean-persistence-api.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-annotation</artifactId>
<version>${ebean-annotation.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-types</artifactId>
<version>${ebean-types.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
@@ -78,88 +89,94 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-joda-time</artifactId>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-xml</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-autotune</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>kotlin-querybean-generator</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgis</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-redis</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
</dependencies>
+9 -2
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<artifactId>ebean-core-type</artifactId>
@@ -16,7 +16,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -26,6 +26,13 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@@ -1,8 +1,5 @@
package io.ebeaninternal.server.core;
package io.ebean.core.type;
import io.ebeaninternal.server.type.ScalarTypeUUIDBinary;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
@@ -14,14 +11,9 @@ import java.util.Calendar;
import java.util.UUID;
/**
* Default implementation of TypeConverter.
* <p>
* Converts objects to the required type if required.
* </p>
* Helper to converts objects to the basic types if required.
*/
public final class BasicTypeConverter implements Serializable {
private static final long serialVersionUID = 7691463236204070311L;
public final class BasicTypeConverter {
/**
* Type code for java.util.Calendar.
@@ -43,7 +35,6 @@ public final class BasicTypeConverter implements Serializable {
* @param toDataType the dataType as per java.sql.Types.
*/
public static Object convert(Object value, int toDataType) {
try {
switch (toDataType) {
case UTIL_DATE: {
@@ -58,7 +49,8 @@ public final class BasicTypeConverter implements Serializable {
case Types.INTEGER: {
return toInteger(value);
}
case Types.BIT: {
case Types.BIT:
case Types.BOOLEAN: {
return toBoolean(value);
}
case Types.TINYINT: {
@@ -67,59 +59,42 @@ public final class BasicTypeConverter implements Serializable {
case Types.SMALLINT: {
return toShort(value);
}
case Types.NUMERIC: {
return toBigDecimal(value);
}
case Types.NUMERIC:
case Types.DECIMAL: {
return toBigDecimal(value);
}
case Types.REAL: {
return toFloat(value);
}
case Types.DOUBLE: {
return toDouble(value);
}
case Types.DOUBLE:
case Types.FLOAT: {
return toDouble(value);
}
case Types.BOOLEAN: {
return toBoolean(value);
}
case Types.TIMESTAMP: {
return toTimestamp(value);
}
case Types.DATE: {
return toDate(value);
}
case Types.VARCHAR: {
return toString(value);
}
case Types.VARCHAR:
case Types.CHAR: {
return toString(value);
}
case Types.OTHER: {
return value;
}
case Types.JAVA_OBJECT: {
return value;
}
case Types.OTHER:
case Types.BINARY:
case Types.LONGVARBINARY:
case Types.BLOB: {
return value;
}
case Types.BLOB:
case Types.JAVA_OBJECT:
case Types.LONGVARCHAR:
case Types.CLOB: {
return value;
}
default: {
String msg = "Unhandled data type [" + toDataType + "] converting [" + value + "]";
throw new RuntimeException(msg);
throw new RuntimeException("Unhandled data type - " + toDataType);
}
}
} catch (ClassCastException e) {
String m = "ClassCastException converting to data type [" + toDataType + "] value [" + value + "]";
throw new RuntimeException(m);
throw new RuntimeException("ClassCastException converting to data type: " + toDataType + " value: " + value);
}
}
@@ -127,7 +102,6 @@ public final class BasicTypeConverter implements Serializable {
* Convert the value to a String.
*/
public static String toString(Object value) {
if (value == null) {
return null;
}
@@ -137,7 +111,6 @@ public final class BasicTypeConverter implements Serializable {
if (value instanceof char[]) {
return String.valueOf((char[]) value);
}
return value.toString();
}
@@ -145,8 +118,7 @@ public final class BasicTypeConverter implements Serializable {
/**
* Convert the value to a Boolean with an explicit String true value.
*/
public static Boolean toBoolean(Object value, String dbTrueValue) {
public static Boolean toBoolean(Object value, String trueValue) {
if (value == null) {
return null;
}
@@ -156,8 +128,7 @@ public final class BasicTypeConverter implements Serializable {
if (value instanceof Number) {
return ((Number) value).intValue() == 1;
}
String s = value.toString();
return s.equalsIgnoreCase(dbTrueValue);
return value.toString().equalsIgnoreCase(trueValue);
}
/**
@@ -165,14 +136,12 @@ public final class BasicTypeConverter implements Serializable {
* "true" or "false".
*/
public static Boolean toBoolean(Object value) {
if (value == null) {
return null;
}
if (value instanceof Boolean) {
return (Boolean) value;
}
return Boolean.valueOf(value.toString());
}
@@ -180,7 +149,6 @@ public final class BasicTypeConverter implements Serializable {
* Convert the value to a UUID.
*/
public static UUID toUUID(Object value, boolean optimizedBinary) {
if (value == null) {
return null;
}
@@ -191,17 +159,15 @@ public final class BasicTypeConverter implements Serializable {
return UUID.fromString((String) value);
}
if (value instanceof byte[]) {
return ScalarTypeUUIDBinary.convertFromBytes((byte[]) value, optimizedBinary);
return ScalarTypeUtils.uuidFromBytes((byte[]) value, optimizedBinary);
}
return UUID.fromString(value.toString());
}
/**
* convert the passed in object to a BigDecimal. It should be another
* numeric type.
* convert the passed in object to a BigDecimal. It should be another numeric type.
*/
public static BigDecimal toBigDecimal(Object value) {
if (value == null) {
return null;
}
@@ -212,7 +178,6 @@ public final class BasicTypeConverter implements Serializable {
}
public static Float toFloat(Object value) {
if (value == null) {
return null;
}
@@ -226,7 +191,6 @@ public final class BasicTypeConverter implements Serializable {
}
public static Short toShort(Object value) {
if (value == null) {
return null;
}
@@ -240,7 +204,6 @@ public final class BasicTypeConverter implements Serializable {
}
public static Byte toByte(Object value) {
if (value == null) {
return null;
}
@@ -251,11 +214,9 @@ public final class BasicTypeConverter implements Serializable {
}
/**
* convert the passed in object to a Integer. It should be another numeric
* type.
* convert the passed in object to an Integer.
*/
public static Integer toInteger(Object value) {
if (value == null) {
return null;
}
@@ -269,10 +230,9 @@ public final class BasicTypeConverter implements Serializable {
}
/**
* Convert the object to a Long. It should be another numeric type.
* Convert the object to a Long.
*/
public static Long toLong(Object value) {
if (value == null) {
return null;
}
@@ -294,8 +254,7 @@ public final class BasicTypeConverter implements Serializable {
return Long.valueOf(value.toString());
}
public static BigInteger toMathBigInteger(Object value) {
public static BigInteger toBigInteger(Object value) {
if (value == null) {
return null;
}
@@ -306,10 +265,9 @@ public final class BasicTypeConverter implements Serializable {
}
/**
* Convert the object to a Double. It should be another numberic type.
* Convert the object to a Double.
*/
public static Double toDouble(Object value) {
if (value == null) {
return null;
}
@@ -323,56 +281,42 @@ public final class BasicTypeConverter implements Serializable {
}
/**
* convert the passed in object to a Timestamp. It is expected to be a
* java.sql.Date really.
* convert the passed in object to a Timestamp.
*/
public static Timestamp toTimestamp(Object value) {
if (value == null) {
return null;
}
if (value instanceof Timestamp) {
return (Timestamp) value;
} else if (value instanceof java.util.Date) {
// no nanos here... so hopefully ok
return new Timestamp(((java.util.Date) value).getTime());
} else if (value instanceof Calendar) {
return new Timestamp(((Calendar) value).getTime().getTime());
} else if (value instanceof String) {
return Timestamp.valueOf((String) value);
} else if (value instanceof LocalDateTime) {
return Timestamp.valueOf((LocalDateTime) value);
} else if (value instanceof Number) {
return new Timestamp(((Number) value).longValue());
} else {
String msg = "Unable to convert [" + value.getClass().getName() + "] into a Timestamp.";
throw new RuntimeException(msg);
throw new RuntimeException("Unable to convert " + value);
}
}
public static java.sql.Time toTime(Object value) {
if (value == null) {
return null;
}
if (value instanceof java.sql.Time) {
return (java.sql.Time) value;
} else if (value instanceof String) {
return java.sql.Time.valueOf((String) value);
} else if (value instanceof LocalTime) {
return java.sql.Time.valueOf((LocalTime) value);
} else {
String m = "Unable to convert [" + value.getClass().getName() + "] into a java.sql.Date.";
throw new RuntimeException(m);
throw new RuntimeException("Unable to convert " + value);
}
}
@@ -380,31 +324,23 @@ public final class BasicTypeConverter implements Serializable {
* convert the passed in object to a java sql Date.
*/
public static java.sql.Date toDate(Object value) {
if (value == null) {
return null;
}
if (value instanceof java.sql.Date) {
return (java.sql.Date) value;
} else if (value instanceof java.util.Date) {
return new java.sql.Date(((java.util.Date) value).getTime());
} else if (value instanceof Calendar) {
return new java.sql.Date(((Calendar) value).getTime().getTime());
} else if (value instanceof String) {
return java.sql.Date.valueOf((String) value);
} else if (value instanceof Number) {
return new java.sql.Date(((Number) value).longValue());
} else if (value instanceof LocalDate) {
return java.sql.Date.valueOf((LocalDate)value);
return java.sql.Date.valueOf((LocalDate) value);
} else {
String m = "Unable to convert [" + value.getClass().getName() + "] into a java.sql.Date.";
throw new RuntimeException(m);
throw new RuntimeException("Unable to convert " + value);
}
}
@@ -412,7 +348,6 @@ public final class BasicTypeConverter implements Serializable {
* convert the passed in object to a java sql Date.
*/
public static java.util.Date toUtilDate(Object value) {
if (value == null) {
return null;
}
@@ -420,26 +355,19 @@ public final class BasicTypeConverter implements Serializable {
// loss of nanos precision
return new java.util.Date(((java.sql.Timestamp) value).getTime());
}
// DEVNOTE: strictly speaking do I need to convert a java.sql.Date to
// java.util.Date? equals() is symmetrical so perhaps this is not
// really required?
if (value instanceof java.sql.Date) {
return new java.util.Date(((java.sql.Date) value).getTime());
}
if (value instanceof java.util.Date) {
return (java.util.Date) value;
} else if (value instanceof Calendar) {
return ((Calendar) value).getTime();
} else if (value instanceof String) {
return new java.util.Date(Timestamp.valueOf((String) value).getTime());
} else if (value instanceof Number) {
return new java.util.Date(((Number) value).longValue());
} else {
throw new RuntimeException("Unable to convert [" + value.getClass().getName() + "] into a java.util.Date");
throw new RuntimeException("Unable to convert " + value);
}
}
@@ -447,37 +375,29 @@ public final class BasicTypeConverter implements Serializable {
* convert the passed in object to a java sql Date.
*/
public static Calendar toCalendar(Object value) {
if (value == null) {
return null;
}
if (value instanceof Calendar) {
return (Calendar) value;
} else if (value instanceof java.util.Date) {
java.util.Date date = ((java.util.Date) value);
return toCalendarFromDate(date);
} else if (value instanceof String) {
java.util.Date date = toUtilDate(value);
return toCalendarFromDate(date);
} else if (value instanceof Number) {
long timeMillis = ((Number) value).longValue();
java.util.Date date = new java.util.Date(timeMillis);
return toCalendarFromDate(date);
} else {
String m = "Unable to convert [" + value.getClass().getName() + "] into a java.util.Date";
throw new RuntimeException(m);
throw new RuntimeException("Unable to convert " + value);
}
}
private static Calendar toCalendarFromDate(java.util.Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return cal;
}
@@ -2,7 +2,6 @@ package io.ebean.core.type;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import io.ebean.text.StringFormatter;
import io.ebean.text.StringParser;
@@ -34,7 +33,7 @@ public interface ScalarType<T> extends StringParser, StringFormatter, ScalarData
/**
* Return true for types that do mutation detection based on json content.
*/
default boolean isJsonMapper() {
default boolean jsonMapper() {
return false;
}
@@ -42,14 +41,14 @@ public interface ScalarType<T> extends StringParser, StringFormatter, ScalarData
* Return true if this is a binary type and can not support parse() and format() from/to string.
* This allows Ebean to optimise marshalling types to string.
*/
default boolean isBinaryType() {
default boolean binary() {
return false;
}
/**
* Return true if this is a mutable scalar type (like hstore).
*/
default boolean isMutable() {
default boolean mutable() {
return false;
}
@@ -67,7 +66,7 @@ public interface ScalarType<T> extends StringParser, StringFormatter, ScalarData
* If a BeanProperty has no explicit length defined then this length should
* be assigned.
*/
default int getLength() {
default int length() {
return 0;
}
@@ -77,7 +76,7 @@ public interface ScalarType<T> extends StringParser, StringFormatter, ScalarData
* If it is native to JDBC then its values/instances do not need to be
* converted to and from an associated JDBC type.
*/
boolean isJdbcNative();
boolean jdbcNative();
/**
* Return the type as per java.sql.Types that this maps to.
@@ -85,14 +84,19 @@ public interface ScalarType<T> extends StringParser, StringFormatter, ScalarData
* This type should be consistent with the toJdbcType() method in converting
* the type to the appropriate type for binding to preparedStatements.
*/
int getJdbcType();
int jdbcType();
/**
* Return the type that matches the bean property type.
* <p>
* This represents the 'logical' type rather than the JDBC type this maps to.
*/
Class<T> getType();
Class<T> type();
/**
* Return the type this maps to for JSON document stores.
*/
DocPropertyType docType();
/**
* Read the value from the resultSet and convert if necessary to the logical
@@ -101,12 +105,6 @@ public interface ScalarType<T> extends StringParser, StringFormatter, ScalarData
@Override
T read(DataReader reader) throws SQLException;
/**
* Ignore the reading of this value. Typically, this means moving the index
* position in the ResultSet.
*/
void loadIgnore(DataReader reader);
/**
* Convert (if necessary) and bind the value to the preparedStatement.
* <p>
@@ -135,6 +133,14 @@ public interface ScalarType<T> extends StringParser, StringFormatter, ScalarData
*/
T toBeanType(Object value);
/**
* Convert the string value to the appropriate java object.
* <p>
* Mostly used to support CSV, JSON and XML parsing.
*/
@Override
T parse(String value);
/**
* Convert the type into a string representation.
*/
@@ -147,34 +153,10 @@ public interface ScalarType<T> extends StringParser, StringFormatter, ScalarData
* <p>
* This is so that ScalarType also implements the StringFormatter interface.
*/
@SuppressWarnings("unchecked")
@Override
String format(Object value);
/**
* Convert the string value to the appropriate java object.
* <p>
* Mostly used to support CSV, JSON and XML parsing.
*/
@Override
T parse(String value);
/**
* Return the type this maps to for JSON document stores.
*/
DocPropertyType getDocType();
/**
* Return true if the type can accept long systemTimeMillis input.
* <p>
* This is used to determine if it is sensible to use the
* {@link #convertFromMillis(long)} method.
* <p>
* This includes the Date, Calendar, sql Date, Time, Timestamp, JODA types
* as well as Long, BigDecimal and String (although it generally is not
* expected to parse systemTimeMillis to a String or BigDecimal).
*/
default boolean isDateTimeCapable() {
return false;
default String format(Object value) {
return formatValue((T) value);
}
/**
@@ -184,15 +166,6 @@ public interface ScalarType<T> extends StringParser, StringFormatter, ScalarData
throw new UnsupportedOperationException();
}
/**
* Convert the systemTimeMillis into the appropriate java object.
* <p>
* For non dateTime types this will throw an exception.
*/
default T convertFromMillis(long dateTime) {
throw new UnsupportedOperationException();
}
/**
* Read the value from binary input.
*/
@@ -0,0 +1,33 @@
package io.ebean.core.type;
/**
* Base ScalarType object.
*/
public abstract class ScalarTypeBase<T> implements ScalarType<T> {
protected final Class<T> type;
protected final boolean jdbcNative;
protected final int jdbcType;
public ScalarTypeBase(Class<T> type, boolean jdbcNative, int jdbcType) {
this.type = type;
this.jdbcNative = jdbcNative;
this.jdbcType = jdbcType;
}
@Override
public boolean jdbcNative() {
return jdbcNative;
}
@Override
public int jdbcType() {
return jdbcType;
}
@Override
public Class<T> type() {
return type;
}
}
@@ -1,4 +1,4 @@
package io.ebeaninternal.server.type;
package io.ebean.core.type;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
@@ -7,6 +7,7 @@ import io.ebean.config.JsonConfig;
import io.ebean.core.type.DataBinder;
import io.ebean.core.type.DataReader;
import io.ebean.core.type.DocPropertyType;
import io.ebean.core.type.ScalarTypeBase;
import java.io.DataInput;
import java.io.DataOutput;
@@ -18,15 +19,20 @@ import java.sql.Types;
/**
* Base class for Date types.
*/
abstract class ScalarTypeBaseDate<T> extends ScalarTypeBase<T> {
public abstract class ScalarTypeBaseDate<T> extends ScalarTypeBase<T> {
protected final JsonConfig.Date mode;
ScalarTypeBaseDate(JsonConfig.Date mode, Class<T> type, boolean jdbcNative, int jdbcType) {
public ScalarTypeBaseDate(JsonConfig.Date mode, Class<T> type, boolean jdbcNative, int jdbcType) {
super(type, jdbcNative, jdbcType);
this.mode = mode;
}
/**
* Convert the value to ISO8601 format.
*/
protected abstract String toIsoFormat(T value);
/**
* Convert the target value to millis.
*/
@@ -53,38 +59,27 @@ abstract class ScalarTypeBaseDate<T> extends ScalarTypeBase<T> {
@Override
public T read(DataReader reader) throws SQLException {
Date ts = reader.getDate();
return ts == null ? null : convertFromDate(ts);
final Date date = reader.getDate();
return date == null ? null : convertFromDate(date);
}
@Override
public String formatValue(T t) {
Date date = convertToDate(t);
// format all dates into epoch millis
long epochMillis = date.getTime();
return Long.toString(epochMillis);
public String formatValue(T value) {
final Date date = convertToDate(value);
return Long.toString(date.getTime());
}
@Override
public T parse(String value) {
try {
long epochMillis = Long.parseLong(value);
return convertFromDate(new Date(epochMillis));
return convertFromDate(new Date(Long.parseLong(value)));
} catch (NumberFormatException e) {
Date date = Date.valueOf(value);
return convertFromDate(date);
return convertFromDate(Date.valueOf(value));
}
}
@Override
public T convertFromMillis(long systemTimeMillis) {
Date ts = new Date(systemTimeMillis);
return convertFromDate(ts);
}
@Override
public boolean isDateTimeCapable() {
return true;
return convertFromDate(new Date(systemTimeMillis));
}
@Override
@@ -105,13 +100,8 @@ abstract class ScalarTypeBaseDate<T> extends ScalarTypeBase<T> {
}
}
/**
* Convert the value to ISO8601 format.
*/
protected abstract String toIsoFormat(T value);
@Override
public DocPropertyType getDocType() {
public DocPropertyType docType() {
return DocPropertyType.DATE;
}
@@ -120,9 +110,7 @@ abstract class ScalarTypeBaseDate<T> extends ScalarTypeBase<T> {
if (!dataInput.readBoolean()) {
return null;
} else {
long val = dataInput.readLong();
Date date = new Date(val);
return convertFromDate(date);
return convertFromDate(new Date(dataInput.readLong()));
}
}
@@ -132,8 +120,7 @@ abstract class ScalarTypeBaseDate<T> extends ScalarTypeBase<T> {
dataOutput.writeBoolean(false);
} else {
dataOutput.writeBoolean(true);
Date date = convertToDate(value);
dataOutput.writeLong(date.getTime());
dataOutput.writeLong(convertToDate(value).getTime());
}
}
@@ -1,11 +1,8 @@
package io.ebeaninternal.server.type;
package io.ebean.core.type;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import io.ebean.config.JsonConfig;
import io.ebean.core.type.DataBinder;
import io.ebean.core.type.DataReader;
import io.ebean.core.type.DocPropertyType;
import java.io.DataInput;
import java.io.DataOutput;
@@ -16,16 +13,14 @@ import java.sql.Timestamp;
import java.sql.Types;
import java.time.Instant;
import static io.ebeaninternal.server.type.IsoJsonDateTimeParser.parseIso;
/**
* Base type for DateTime types.
*/
abstract class ScalarTypeBaseDateTime<T> extends ScalarTypeBase<T> {
public abstract class ScalarTypeBaseDateTime<T> extends ScalarTypeBase<T> {
protected final JsonConfig.DateTime mode;
ScalarTypeBaseDateTime(JsonConfig.DateTime mode, Class<T> type, boolean jdbcNative, int jdbcType) {
public ScalarTypeBaseDateTime(JsonConfig.DateTime mode, Class<T> type, boolean jdbcNative, int jdbcType) {
super(type, jdbcNative, jdbcType);
this.mode = mode;
}
@@ -53,7 +48,6 @@ abstract class ScalarTypeBaseDateTime<T> extends ScalarTypeBase<T> {
/**
* Convert from epoch millis to the value.
*/
@Override
public abstract T convertFromMillis(long systemTimeMillis);
/**
@@ -75,7 +69,7 @@ abstract class ScalarTypeBaseDateTime<T> extends ScalarTypeBase<T> {
* Convert the value to ISO8601 format.
*/
protected T fromJsonISO8601(String value) {
return convertFromInstant(parseIso(value));
return convertFromInstant(ScalarTypeUtils.parseInstant(value));
}
@Override
@@ -101,7 +95,7 @@ abstract class ScalarTypeBaseDateTime<T> extends ScalarTypeBase<T> {
* Helper method that given epoch seconds and nanos return a JSON nanos formatted string.
*/
protected String toJsonNanos(long epochSecs, int nanos) {
return DecimalUtils.toDecimal(epochSecs, nanos);
return ScalarTypeUtils.toDecimal(epochSecs, nanos);
}
@Override
@@ -112,7 +106,7 @@ abstract class ScalarTypeBaseDateTime<T> extends ScalarTypeBase<T> {
}
case VALUE_NUMBER_FLOAT: {
BigDecimal value = parser.getDecimalValue();
Timestamp timestamp = DecimalUtils.toTimestamp(value);
Timestamp timestamp = ScalarTypeUtils.toTimestamp(value);
return convertFromTimestamp(timestamp);
}
default: {
@@ -139,7 +133,7 @@ abstract class ScalarTypeBaseDateTime<T> extends ScalarTypeBase<T> {
}
@Override
public DocPropertyType getDocType() {
public DocPropertyType docType() {
return DocPropertyType.DATETIME;
}
@@ -160,11 +154,6 @@ abstract class ScalarTypeBaseDateTime<T> extends ScalarTypeBase<T> {
}
}
@Override
public boolean isDateTimeCapable() {
return true;
}
@Override
public T readData(DataInput dataInput) throws IOException {
if (!dataInput.readBoolean()) {
@@ -1,11 +1,7 @@
package io.ebeaninternal.server.type;
package io.ebean.core.type;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import io.ebean.core.type.DataBinder;
import io.ebean.core.type.DataReader;
import io.ebean.core.type.DocPropertyType;
import io.ebean.text.TextException;
import java.io.DataInput;
import java.io.DataOutput;
@@ -17,13 +13,13 @@ import java.sql.Types;
* Base ScalarType for types which converts to and from a VARCHAR database
* column.
*/
abstract class ScalarTypeBaseVarchar<T> extends ScalarTypeBase<T> {
public abstract class ScalarTypeBaseVarchar<T> extends ScalarTypeBase<T> {
ScalarTypeBaseVarchar(Class<T> type) {
public ScalarTypeBaseVarchar(Class<T> type) {
super(type, false, Types.VARCHAR);
}
ScalarTypeBaseVarchar(Class<T> type, boolean jdbcNative, int jdbcType) {
public ScalarTypeBaseVarchar(Class<T> type, boolean jdbcNative, int jdbcType) {
super(type, jdbcNative, jdbcType);
}
@@ -88,12 +84,6 @@ abstract class ScalarTypeBaseVarchar<T> extends ScalarTypeBase<T> {
return format(value);
}
@Override
@SuppressWarnings("unchecked")
public String format(Object value) {
return formatValue((T) value);
}
@Override
public T readData(DataInput dataInput) throws IOException {
if (!dataInput.readBoolean()) {
@@ -108,7 +98,8 @@ abstract class ScalarTypeBaseVarchar<T> extends ScalarTypeBase<T> {
if (value == null) {
dataOutput.writeBoolean(false);
} else {
ScalarHelp.writeUTF(dataOutput, convertToDbString(value));
dataOutput.writeBoolean(true);
dataOutput.writeUTF(convertToDbString(value));
}
}
@@ -123,7 +114,7 @@ abstract class ScalarTypeBaseVarchar<T> extends ScalarTypeBase<T> {
}
@Override
public DocPropertyType getDocType() {
public DocPropertyType docType() {
return DocPropertyType.TEXT;
}
@@ -0,0 +1,179 @@
package io.ebean.core.type;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.time.Duration;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.UUID;
/**
* Utilities to aid in the translation of decimal types to/from multiple parts.
*
* @author Nick Williams
* @since 2.2.0
*/
public final class ScalarTypeUtils {
private static final char[] ZEROES = new char[]{'0', '0', '0', '0', '0', '0', '0', '0', '0'};
private static final BigDecimal ONE_BILLION = new BigDecimal(1000000000L);
private static final DateTimeFormatter ISO_MILLIS = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendInstant(3)
.toFormatter();
/**
* Parse using ISO8601.
*/
public static Instant parseInstant(String jsonDateTime) {
return Instant.parse(jsonDateTime);
}
/**
* Format using ISO8601.
*/
public static String formatInstant(Instant value) {
return ISO_MILLIS.format(value);
}
/**
* Convert decimal to duration with nanos.
*/
public static Duration toDuration(BigDecimal value) {
long seconds = value.longValue();
int nanoseconds = extractNanosecondDecimal(value, seconds);
return Duration.ofSeconds(seconds, nanoseconds);
}
/**
* Convert duration to decimal with nanos.
*/
public static BigDecimal toDecimal(Duration instant) {
return new BigDecimal(toDecimal(instant.getSeconds(), instant.getNano()));
}
/**
* Convert decimal to timestamp with nanos.
*/
public static Timestamp toTimestamp(BigDecimal value) {
long seconds = value.longValue();
int nanoseconds = extractNanosecondDecimal(value, seconds);
Timestamp ts = new Timestamp(seconds * 1000);
ts.setNanos(nanoseconds);
return ts;
}
/**
* Convert timestamp to decimal with nanos.
*/
public static BigDecimal toDecimal(Timestamp instant) {
long millis = instant.getTime();
long secs = millis / 1000;
return new BigDecimal(toDecimal(secs, instant.getNanos()));
}
/**
* Convert to decimal string with nanos.
*/
public static String toDecimal(long seconds, int nanoseconds) {
StringBuilder string = new StringBuilder(Integer.toString(nanoseconds));
if (string.length() < 9)
string.insert(0, ZEROES, 0, 9 - string.length());
return seconds + "." + string;
}
private static int extractNanosecondDecimal(BigDecimal value, long integer) {
return value.subtract(new BigDecimal(integer)).multiply(ONE_BILLION).intValue();
}
/**
* Convert from byte[] to UUID.
*/
public static UUID uuidFromBytes(byte[] bytes, boolean optimized) {
int usableBytes = Math.min(bytes.length, 16);
// Need exactly 16 bytes - pad the input if not enough bytes are provided
// Use provided bytes in the least significant position; if more than 16 bytes are given,
// then use the first 16 bytes from the array;
byte[] barr = new byte[16];
for (int i = 15, j = usableBytes - 1; j >= 0; i--, j--) {
barr[i] = bytes[j];
}
long msb;
if (optimized) {
msb = ((long)barr[4] << 56) + // XXXXXXXX-____-____-...
((long)(barr[5] & 255) << 48) + // -> put at end 4..7 of buf
((long)(barr[6] & 255) << 40) +
((long)(barr[7] & 255) << 32) +
((long)(barr[2] & 255) << 24) + // ________-XXXX-____-...
((barr[3] & 255) << 16) + // put at 2..3 in buf
((barr[0] & 255) << 8) + // ________-____-XXXX-...
((barr[1] & 255) << 0); // put at 0..1 in buf
} else {
msb = ((long)barr[0] << 56) + // XXXXXXXX-____-____-...
((long)(barr[1] & 255) << 48) +
((long)(barr[2] & 255) << 40) +
((long)(barr[3] & 255) << 32) +
((long)(barr[4] & 255) << 24) + // ________-XXXX-____-...
((barr[5] & 255) << 16) +
((barr[6] & 255) << 8) + // ________-____-XXXX-...
((barr[7] & 255) << 0);
}
long lsb = ((long)barr[8] << 56) +
((long)(barr[9] & 255) << 48) +
((long)(barr[10] & 255) << 40) +
((long)(barr[11] & 255) << 32) +
((long)(barr[12] & 255) << 24) +
((barr[13] & 255) << 16) +
((barr[14] & 255) << 8) +
((barr[15] & 255) << 0);
return new UUID(msb, lsb);
}
/**
* Convert from UUID to byte[].
*/
public static byte[] uuidToBytes(UUID uuid, boolean optimized) {
byte[] ret = new byte[16];
long l = uuid.getMostSignificantBits();
if (optimized) {
ret[0] = (byte) (l >>> 8); // was 6/7
ret[1] = (byte) (l >>> 0);
ret[2] = (byte) (l >>> 24); // was 4/5
ret[3] = (byte) (l >>> 16);
ret[4] = (byte) (l >>> 56); // was 0..3
ret[5] = (byte) (l >>> 48);
ret[6] = (byte) (l >>> 40);
ret[7] = (byte) (l >>> 32);
} else {
ret[0] = (byte) (l >>> 56);
ret[1] = (byte) (l >>> 48);
ret[2] = (byte) (l >>> 40);
ret[3] = (byte) (l >>> 32);
ret[4] = (byte) (l >>> 24);
ret[5] = (byte) (l >>> 16);
ret[6] = (byte) (l >>> 8);
ret[7] = (byte) (l >>> 0);
}
l = uuid.getLeastSignificantBits();
ret[8] = (byte) (l >>> 56);
ret[9] = (byte) (l >>> 48);
ret[10] = (byte) (l >>> 40);
ret[11] = (byte) (l >>> 32);
ret[12] = (byte) (l >>> 24);
ret[13] = (byte) (l >>> 16);
ret[14] = (byte) (l >>> 8);
ret[15] = (byte) (l >>> 0);
return ret;
}
}
@@ -0,0 +1,36 @@
package io.ebean.core.type;
import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.time.Duration;
import java.time.Instant;
import static org.junit.jupiter.api.Assertions.assertEquals;
class DecimalUtilsTest {
@Test
void testToDecimal() {
Instant now = Instant.now();
Timestamp sourceTimestamp = Timestamp.from(now);
BigDecimal decimal = ScalarTypeUtils.toDecimal(sourceTimestamp);
Timestamp timestamp = ScalarTypeUtils.toTimestamp(decimal);
assertEquals(now, timestamp.toInstant());
assertEquals(sourceTimestamp, timestamp);
}
@Test
void testDuration() {
Duration duration = Duration.ofSeconds(323, 1500000);
BigDecimal bigDecimal = ScalarTypeUtils.toDecimal(duration);
Duration duration1 = ScalarTypeUtils.toDuration(bigDecimal);
assertEquals(duration, duration1);
assertEquals("PT5M23.0015S", duration1.toString());
}
}
@@ -1,5 +1,4 @@
package io.ebeaninternal.server.type;
package io.ebean.core.type;
import org.junit.jupiter.api.Test;
@@ -7,43 +6,43 @@ import java.time.Instant;
import static org.assertj.core.api.Assertions.assertThat;
public class IsoJsonDateTimeParserTest {
class IsoJsonDateTimeParserTest {
private IsoJsonDateTimeParser parser = new IsoJsonDateTimeParser();
private ScalarTypeUtils parser = new ScalarTypeUtils();
@Test
public void parseFormat_when_hasMillis() {
void parseFormat_when_hasMillis() {
parseAndFormat("2016-02-28T20:39:00.123Z", "2016-02-28T20:39:00.123Z");
}
@Test
public void parseFormat_when_noMillis() {
void parseFormat_when_noMillis() {
parseAndFormat("2016-02-28T20:39:00Z", "2016-02-28T20:39:00.000Z");
}
@Test
public void parseFormat_when_millis_1dp() {
void parseFormat_when_millis_1dp() {
parseAndFormat("2016-02-28T20:39:00.0Z", "2016-02-28T20:39:00.000Z");
}
@Test
public void parseFormat_when_millis_2dp() {
void parseFormat_when_millis_2dp() {
parseAndFormat("2016-02-28T20:39:00.00Z", "2016-02-28T20:39:00.000Z");
}
@Test
public void parseFormat_when_millis_3dp() {
void parseFormat_when_millis_3dp() {
parseAndFormat("2016-02-28T20:39:00.000Z", "2016-02-28T20:39:00.000Z");
}
@Test
public void parseFormat_when_millis_3dp_2() {
void parseFormat_when_millis_3dp_2() {
parseAndFormat("2016-02-28T20:39:32.999000Z", "2016-02-28T20:39:32.999Z");
}
private void parseAndFormat(String input, String expected) {
Instant timestamp = parser.parseIso(input);
String format = parser.formatIso(timestamp);
Instant timestamp = parser.parseInstant(input);
String format = parser.formatInstant(timestamp);
assertThat(format).isEqualTo(expected);
}
}
@@ -0,0 +1,33 @@
package io.ebean.core.type;
import org.junit.jupiter.api.Test;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertEquals;
class ScalarTypeUtilsUuidBytesTest {
@Test
void testConversion() {
UUID id = UUID.randomUUID();
byte[] bytes = ScalarTypeUtils.uuidToBytes(id, false);
assertEquals(16, bytes.length);
UUID id2 = ScalarTypeUtils.uuidFromBytes(bytes, false);
assertEquals(id, id2);
}
@Test
void testConversionOptimized() {
UUID id = UUID.randomUUID();
byte[] bytes = ScalarTypeUtils.uuidToBytes(id, true);
assertEquals(16, bytes.length);
UUID id2 = ScalarTypeUtils.uuidFromBytes(bytes, true);
assertEquals(id, id2);
}
}
+8 -8
View File
@@ -3,7 +3,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.7.0</version>
<version>13.9.1</version>
</parent>
<artifactId>ebean-core</artifactId>
@@ -15,7 +15,7 @@
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>HEAD</tag>
<tag>ebean-parent-13.9.1</tag>
</scm>
<dependencies>
@@ -41,19 +41,19 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
</dependency>
<dependency>
@@ -144,21 +144,21 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-h2</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-sqlserver</artifactId>
<version>13.7.0</version>
<version>13.9.1</version>
<scope>test</scope>
</dependency>
@@ -228,10 +228,9 @@ public final class BindParams implements Serializable {
/**
* Set a named In parameter that is multi-valued.
*/
public Param setArrayParameter(String name, Collection<?> value) {
public void setArrayParameter(String name, Collection<?> value) {
Param p = getParam(name);
p.setInValue(new MultiValueWrapper(value));
return p;
}
/**
@@ -9,7 +9,7 @@ public interface CQueryPlanKey {
* Used by read audit such that we can log read audit entries without the full sql
* (which would make the read audit logs verbose).
*/
String getPartialKey();
String partialKey();
/**
* Return a query plan key taking into account persist cascading.
@@ -1,13 +1,12 @@
package io.ebeaninternal.api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.avaje.applog.AppLog;
/**
* Common loggers used in ebean-core.
*/
public final class CoreLog {
public static final Logger log = LoggerFactory.getLogger("io.ebean.core");
public static final Logger internal = LoggerFactory.getLogger("io.ebean.internal");
public static final System.Logger log = AppLog.getLogger("io.ebean.core");
public static final System.Logger internal = AppLog.getLogger("io.ebean.internal");
}
@@ -7,17 +7,18 @@ import io.ebeaninternal.server.core.BindPadding;
import io.ebeaninternal.server.core.OrmQueryRequest;
import io.ebeaninternal.server.deploy.BeanDescriptor;
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.List;
import static java.lang.System.Logger.Level.DEBUG;
/**
* Request for loading Associated Many Beans.
*/
public final class LoadManyRequest extends LoadRequest {
private static final Logger log = CoreLog.log;
private static final System.Logger log = CoreLog.log;
private final List<BeanCollection<?>> batch;
private final LoadManyBuffer loadContext;
@@ -113,10 +114,10 @@ public final class LoadManyRequest extends LoadRequest {
// in the +query or +lazy load due to no rows (predicates)
for (BeanCollection<?> bc : batch) {
if (bc.checkEmptyLazyLoad()) {
if (log.isDebugEnabled()) {
if (log.isLoggable(DEBUG)) {
EntityBean ownerBean = bc.getOwnerBean();
Object parentId = desc.getId(ownerBean);
log.debug("BeanCollection after lazy load was empty. type:" + ownerBean.getClass().getName() + " id:" + parentId + " owner:" + ownerBean);
log.log(DEBUG, "BeanCollection after lazy load was empty. type:{0} id:{1} owner:{2}", ownerBean.getClass().getName(), parentId, ownerBean);
}
} else if (loadCache && many.isUseCache()) {
desc.cacheManyPropPut(many, bc, desc.getId(bc.getOwnerBean()));
@@ -50,7 +50,6 @@ public final class ManyWhereJoins implements Serializable {
* Add a many where join.
*/
public void add(ElPropertyDeploy elProp) {
String join = elProp.elPrefix();
BeanProperty p = elProp.beanProperty();
if (p instanceof BeanPropertyAssocMany<?>) {
@@ -111,7 +110,6 @@ public final class ManyWhereJoins implements Serializable {
* Return the set of property names for the many where joins.
*/
public TreeSet<String> getPropertyNames() {
TreeSet<String> propertyNames = new TreeSet<>();
for (PropertyJoin join : joins.values()) {
propertyNames.add(join.getProperty());
@@ -142,7 +142,9 @@ public final class NaturalKeyQueryData<T> {
*/
private boolean matchProperties() {
if (naturalKey.isSingleProperty()) {
naturalKey.matchSingleProperty((inProperty != null) ? inProperty : eqList.get(0).property);
if (naturalKey.matchSingleProperty((inProperty != null) ? inProperty : eqList.get(0).property)) {
return true;
}
}
// multiple properties case
@@ -1,6 +1,6 @@
package io.ebeaninternal.api;
import io.ebeaninternal.server.type.bindcapture.BindCapture;
import io.ebeaninternal.server.bind.capture.BindCapture;
final class NoopQueryBindCapture implements SpiQueryBindCapture {
@@ -45,15 +45,14 @@ public final class ScopeTrans {
* Flag set when nested commit has occurred.
*/
private boolean nestedCommit;
private boolean nestedUseSavepoint;
public ScopeTrans(boolean rollbackOnChecked, boolean created, SpiTransaction transaction, TxScope txScope) {
this.rollbackOnChecked = rollbackOnChecked;
this.created = created;
this.transaction = transaction;
this.noRollbackFor = txScope.getNoRollbackFor();
this.rollbackFor = txScope.getRollbackFor();
if (transaction != null) {
if (!created && txScope.isBatchSet() || txScope.isBatchOnCascadeSet() || txScope.isBatchSizeSet()) {
restoreBatch = transaction.isBatchMode();
@@ -87,13 +86,21 @@ public final class ScopeTrans {
@Override
public String toString() {
return "ScopeTrans[" + transaction + "]";
return "ScopeTrans " + transaction;
}
void setNestedUseSavepoint() {
nestedUseSavepoint = true;
}
boolean isNestedUseSavepoint() {
return nestedUseSavepoint;
}
/**
* Return the current/active transaction.
*/
protected SpiTransaction getTransaction() {
SpiTransaction getTransaction() {
return transaction;
}
@@ -101,7 +108,6 @@ public final class ScopeTrans {
* Complete the transaction from enhanced transactional. Try to commit.
*/
void complete(Object returnOrThrowable, int opCode) {
if (opCode == OPCODE_ATHROW) {
// exited with a Throwable
caughtThrowable((Throwable) returnOrThrowable);
@@ -124,7 +130,7 @@ public final class ScopeTrans {
}
}
protected void commitTransaction() {
void commitTransaction() {
if (created) {
transaction.commit();
} else {
@@ -168,14 +174,13 @@ public final class ScopeTrans {
* Returns the exception and this should be thrown by the calling code.
*/
public <T extends Throwable> T caughtThrowable(T e) {
if (isRollbackThrowable(e)) {
rollback(e);
}
return e;
}
protected void rollback(Throwable e) {
void rollback(Throwable e) {
if (transaction != null && transaction.isActive()) {
// transaction is null for NOT_SUPPORTED and sometimes SUPPORTS
// and Inactive (already rolled back) if nested REQUIRED
@@ -188,21 +193,17 @@ public final class ScopeTrans {
* Return true if this throwable should cause a rollback to occur.
*/
private boolean isRollbackThrowable(Throwable e) {
if (e instanceof Error) {
return true;
}
if (noRollbackFor != null) {
for (Class<? extends Throwable> aNoRollbackFor : noRollbackFor) {
if (aNoRollbackFor.equals(e.getClass())) {
// explicit no rollback for this one
return false;
}
}
}
if (rollbackFor != null) {
for (Class<? extends Throwable> aRollbackFor : rollbackFor) {
if (aRollbackFor.equals(e.getClass())) {
@@ -211,7 +212,6 @@ public final class ScopeTrans {
}
}
}
// checked exceptions...
// EJB defaults this to false which is not intuitive IMO
// Ebean makes this configurable (default to true)
@@ -7,7 +7,7 @@ import javax.persistence.PersistenceException;
/**
* Manage scoped (typically thread local) transactions.
*
* <p>
* These can be nested and internally they are pushed and popped from a stack.
*/
public final class ScopedTransaction extends SpiTransactionProxy {
@@ -30,16 +30,29 @@ public final class ScopedTransaction extends SpiTransactionProxy {
@Override
public String toString() {
return "ScopedTransaction[" + current + "]";
return "ScopedTransaction " + current;
}
@Override
public void setNestedUseSavepoint() {
current.setNestedUseSavepoint();
}
@Override
public boolean isNestedUseSavepoint() {
return current.isNestedUseSavepoint();
}
/**
* Push the scope transaction.
*/
public void push(ScopeTrans scopeTrans) {
if (current != null) {
stack.push(current);
if (current.isNestedUseSavepoint()) {
// child scope 'inherits' nestedUseSavepoint
scopeTrans.setNestedUseSavepoint();
}
}
current = scopeTrans;
transaction = scopeTrans.getTransaction();
@@ -111,6 +124,11 @@ public final class ScopedTransaction extends SpiTransactionProxy {
}
}
@Override
public void rollbackAndContinue() {
transaction.rollbackAndContinue();
}
@Override
public void rollback() throws PersistenceException {
try {
@@ -13,8 +13,8 @@ import java.io.IOException;
*/
public interface SpiExpression extends Expression {
static final String SQL_TRUE = "1=1";
static final String SQL_FALSE = "1=0";
String SQL_TRUE = "1=1";
String SQL_FALSE = "1=0";
/**
* Simplify nested expressions if possible.
@@ -110,4 +110,11 @@ public interface SpiExpression extends Expression {
* Apply property prefix when filterMany expressions included into main query.
*/
void prefixProperty(String path);
/**
* Return a copy of the expression (as part of creating a query copy).
*/
default SpiExpression copy() {
return this;
}
}
@@ -314,7 +314,7 @@ public interface SpiQuery<T> extends Query<T>, SpiQueryFetch, TxnProfileEventCod
* Return true if select all properties was used to ensure the property
* invoking a lazy load was included in the query.
*/
boolean selectAllForLazyLoadProperty();
void selectAllForLazyLoadProperty();
/**
* Set the select properties.
@@ -1,6 +1,6 @@
package io.ebeaninternal.api;
import io.ebeaninternal.server.type.bindcapture.BindCapture;
import io.ebeaninternal.server.bind.capture.BindCapture;
/**
* Capture query bind values and with those actual database query plans.
@@ -10,27 +10,27 @@ public interface SpiQueryPlan {
/**
* The related entity bean type
*/
Class<?> getBeanType();
Class<?> beanType();
/**
* The plan name.
*/
String getName();
String name();
/**
* The hash of the sql.
*/
String getHash();
String hash();
/**
* The SQL for the query plan.
*/
String getSql();
String sql();
/**
* The related profile location.
*/
ProfileLocation getProfileLocation();
ProfileLocation profileLocation();
/**
* Initiate bind capture with the give threshold.
@@ -139,7 +139,7 @@ public final class TransactionEvent implements Serializable {
/**
* Return the CacheChangeSet that we add cache notification messages to.
*
* <p>
* We want to add to this change set as we process requests allowing the
* PersistRequestBean to be garbage collected for large transactions.
*/
@@ -2,7 +2,7 @@ package io.ebeaninternal.api;
/**
* Event codes used in transaction profiling.
*
* <p>
* These appear in verbose transaction profile logs.
*/
public interface TxnProfileEventCodes {
@@ -12,7 +12,7 @@ import java.util.Map;
public interface SpiJsonReader {
PersistenceContext getPersistenceContext();
PersistenceContext persistenceContext();
SpiJsonReader forJson(JsonParser moreJson);
@@ -20,9 +20,9 @@ public interface SpiJsonReader {
Object persistenceContextPutIfAbsent(Object id, EntityBean bean, BeanDescriptor<?> beanDesc);
ObjectMapper getObjectMapper();
ObjectMapper mapper();
JsonParser getParser();
JsonParser parser();
JsonToken nextToken() throws IOException;
@@ -34,5 +34,5 @@ public interface SpiJsonReader {
Object readValueUsingObjectMapper(Class<?> propertyType) throws IOException;
boolean isIntercept();
boolean intercept();
}
@@ -20,7 +20,7 @@ public interface SpiJsonWriter extends JsonWriter {
/**
* Return true if the value is a parent bean.
*/
boolean isParentBean(Object value);
boolean parentBean(Object value);
/**
* Start an assoc one path.
@@ -1,25 +1,18 @@
package io.ebeaninternal.server.type;
package io.ebeaninternal.server.bind;
import io.ebean.core.type.DataBinder;
import io.ebeaninternal.api.CoreLog;
import io.ebeaninternal.server.core.timezone.DataTimeZone;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.io.*;
import java.math.BigDecimal;
import java.sql.Array;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.sql.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static java.lang.System.Logger.Level.WARNING;
public class DataBind implements DataBinder {
private final DataTimeZone dataTimeZone;
@@ -109,7 +102,7 @@ public class DataBind implements DataBinder {
try {
inputStream.close();
} catch (IOException e) {
CoreLog.log.warn("Error closing InputStream that was bound to PreparedStatement", e);
CoreLog.log.log(WARNING, "Error closing InputStream that was bound to PreparedStatement", e);
}
}
inputStreams = null;
@@ -1,8 +1,8 @@
package io.ebeaninternal.server.type;
package io.ebeaninternal.server.bind;
import io.ebeaninternal.server.core.timezone.DataTimeZone;
import io.ebeaninternal.server.type.bindcapture.BindCapture;
import io.ebeaninternal.server.type.bindcapture.BindCaptureStatement;
import io.ebeaninternal.server.bind.capture.BindCapture;
import io.ebeaninternal.server.bind.capture.BindCaptureStatement;
/**
* Special DataBind used to capture bind values for obtaining explain plans.
@@ -1,4 +1,4 @@
package io.ebeaninternal.server.type.bindcapture;
package io.ebeaninternal.server.bind.capture;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -1,4 +1,4 @@
package io.ebeaninternal.server.type.bindcapture;
package io.ebeaninternal.server.bind.capture;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -1,4 +1,4 @@
package io.ebeaninternal.server.type.bindcapture;
package io.ebeaninternal.server.bind.capture;
import java.io.InputStream;
import java.io.Reader;
@@ -1,4 +1,4 @@
package io.ebeaninternal.server.type.bindcapture;
package io.ebeaninternal.server.bind.capture;
import java.io.InputStream;
import java.io.Reader;
@@ -1,4 +1,4 @@
package io.ebeaninternal.server.type.bindcapture;
package io.ebeaninternal.server.bind.capture;
import java.io.ByteArrayInputStream;
import java.io.StringReader;
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.cache;
import io.avaje.applog.AppLog;
import io.ebean.annotation.Cache;
import io.ebean.annotation.CacheBeanTuning;
import io.ebean.annotation.CacheQueryTuning;
@@ -7,20 +8,21 @@ import io.ebean.cache.*;
import io.ebean.config.CurrentTenantProvider;
import io.ebean.meta.MetricVisitor;
import io.ebean.util.AnnotationUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.locks.ReentrantLock;
import static java.lang.System.Logger.Level.DEBUG;
import static java.lang.System.Logger.Level.TRACE;
/**
* Manages the construction of caches.
*/
final class DefaultCacheHolder {
private static final Logger log = LoggerFactory.getLogger("io.ebean.cache.ALL");
private static final System.Logger log = AppLog.getLogger("io.ebean.cache.ALL");
private final ReentrantLock lock = new ReentrantLock();
private final ConcurrentHashMap<String, ServerCache> allCaches = new ConcurrentHashMap<>();
@@ -89,7 +91,7 @@ final class DefaultCacheHolder {
}
void clearAll() {
log.debug("clearAll");
log.log(DEBUG, "clearAll");
for (ServerCache serverCache : allCaches.values()) {
serverCache.clear();
}
@@ -97,7 +99,7 @@ final class DefaultCacheHolder {
public void clear(String name) {
log.debug("clear {}", name);
log.log(DEBUG, "clear {0}", name);
clearIfExists(key(name, ServerCacheType.QUERY));
clearIfExists(key(name, ServerCacheType.BEAN));
clearIfExists(key(name, ServerCacheType.NATURAL_KEY));
@@ -112,7 +114,7 @@ final class DefaultCacheHolder {
private void clearIfExists(String fullKey) {
ServerCache cache = allCaches.get(fullKey);
if (cache != null) {
log.trace("clear cache {}", fullKey);
log.log(TRACE, "clear cache {0}", fullKey);
cache.clear();
}
}
@@ -1,13 +1,12 @@
package io.ebeaninternal.server.cache;
import io.avaje.applog.AppLog;
import io.ebean.BackgroundExecutor;
import io.ebean.cache.ServerCache;
import io.ebean.cache.ServerCacheStatistics;
import io.ebean.meta.MetricVisitor;
import io.ebean.metric.CountMetric;
import io.ebean.metric.MetricFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
import java.lang.ref.SoftReference;
@@ -16,6 +15,9 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock;
import static java.lang.System.Logger.Level.TRACE;
import static java.lang.System.Logger.Level.WARNING;
/**
* The default cache implementation.
* <p>
@@ -25,7 +27,7 @@ import java.util.concurrent.locks.ReentrantLock;
*/
public class DefaultServerCache implements ServerCache {
protected static final Logger logger = LoggerFactory.getLogger(DefaultServerCache.class);
protected static final System.Logger logger = AppLog.getLogger(DefaultServerCache.class);
/**
* Compare by last access time (for LRU eviction).
@@ -287,13 +289,13 @@ public class DefaultServerCache implements ServerCache {
evictCount.add(trimmedByGC);
evictCount.add(trimmedByTTL);
evictCount.add(trimmedByLRU);
if (logger.isTraceEnabled()) {
if (logger.isLoggable(TRACE)) {
long exeMicros = TimeUnit.MICROSECONDS.convert(System.nanoTime() - startNanos, TimeUnit.NANOSECONDS);
logger.trace("Executed trim of cache {} in [{}]millis idle[{}] timeToLive[{}] accessTime[{}] gc[{}]",
logger.log(TRACE, "Executed trim of cache {0} in [{1}]millis idle[{2}] timeToLive[{3}] accessTime[{4}] gc[{5}]",
name, exeMicros, trimmedByIdle, trimmedByTTL, trimmedByLRU, trimmedByGC);
}
} catch (Throwable e) {
logger.warn("Error during trim of DefaultServerCache [" + name + "]. Cache might be bigger than desired.", e);
logger.log(WARNING, "Error during trim of DefaultServerCache [" + name + "]. Cache might be bigger than desired.", e);
}
} finally {
lock.unlock();
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.cache;
import io.avaje.applog.AppLog;
import io.ebean.cache.ServerCache;
import io.ebean.cache.ServerCacheRegion;
import io.ebean.cache.ServerCacheType;
@@ -7,17 +8,18 @@ import io.ebean.meta.MetricVisitor;
import io.ebeaninternal.api.SpiCacheRegion;
import io.ebeaninternal.server.cluster.ClusterManager;
import io.ebeaninternal.server.deploy.DCacheRegion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import static java.lang.System.Logger.Level.DEBUG;
import static java.lang.System.Logger.Level.INFO;
/**
* Manages the bean and query caches.
*/
public final class DefaultServerCacheManager implements SpiCacheManager {
private static final Logger log = LoggerFactory.getLogger("io.ebean.cache.REGION");
private static final System.Logger log = AppLog.getLogger("io.ebean.cache.REGION");
private final Map<String, SpiCacheRegion> regionMap = new HashMap<>();
private final ClusterManager clusterManager;
@@ -65,23 +67,23 @@ public final class DefaultServerCacheManager implements SpiCacheManager {
enabled.add(region.name());
if (!region.isEnabled()) {
region.setEnabled(true);
log.debug("Cache region[{}] enabled", region.name());
log.log(DEBUG, "Cache region[{0}] enabled", region.name());
}
} else {
disabled.add(region.name());
if (region.isEnabled()) {
region.setEnabled(false);
log.debug("Cache region[{}] disabled", region.name());
log.log(DEBUG, "Cache region[{0}] disabled", region.name());
}
}
}
log.info("Cache regions enabled:{} disabled:{}", enabled, disabled);
log.log(INFO, "Cache regions enabled:{0} disabled:{1}", enabled, disabled);
}
}
@Override
public void setAllRegionsEnabled(boolean enabled) {
log.debug("All cache regions enabled[{}]", enabled);
log.log(DEBUG, "All cache regions enabled[{0}]", enabled);
for (SpiCacheRegion region : regionMap.values()) {
region.setEnabled(enabled);
}
@@ -52,7 +52,7 @@ public final class RemoteCacheEvent implements BinaryWritable {
@Override
public String toString() {
return "CacheEvent[ clearAll:" + clearAll + " caches:" + clearCaches + "]";
return "CacheEvent clearAll:" + clearAll + " caches:" + clearCaches;
}
public static RemoteCacheEvent readBinaryMessage(BinaryReadContext dataInput) throws IOException {
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.changelog;
import io.avaje.applog.AppLog;
import io.ebean.event.changelog.BeanChange;
import io.ebean.event.changelog.ChangeLogListener;
import io.ebean.event.changelog.ChangeSet;
@@ -7,12 +8,13 @@ import io.ebean.event.changelog.ChangeType;
import io.ebean.plugin.Plugin;
import io.ebean.plugin.SpiServer;
import io.ebeaninternal.api.CoreLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.StringWriter;
import java.util.Properties;
import static java.lang.System.Logger.Level.ERROR;
import static java.lang.System.Logger.Level.INFO;
/**
* Simply logs the change sets in JSON form to logger named <code>io.ebean.ChangeLog</code>.
*/
@@ -21,7 +23,7 @@ public final class DefaultChangeLogListener implements ChangeLogListener, Plugin
/**
* The named logger we send the change set payload to. Can be externally configured as desired.
*/
private static final Logger changeLog = LoggerFactory.getLogger("io.ebean.ChangeLog");
private static final System.Logger changeLog = AppLog.getLogger("io.ebean.ChangeLog");
/**
* Used to build the JSON.
@@ -65,9 +67,9 @@ public final class DefaultChangeLogListener implements ChangeLogListener, Plugin
try {
StringWriter writer = new StringWriter(getBufferSize(beanChange));
jsonBuilder.writeBeanJson(writer, beanChange, changeSet);
changeLog.info(writer.toString());
changeLog.log(INFO, writer.toString());
} catch (Exception e) {
CoreLog.log.error("Exception logging beanChange " + beanChange, e);
CoreLog.log.log(ERROR, "Exception logging beanChange " + beanChange, e);
}
}
}
@@ -32,7 +32,7 @@ public class BinaryTransactionEventReader {
String serverName = dataInput.readUTF();
SpiEbeanServer server = (SpiEbeanServer) serverLookup.getServer(serverName);
if (server == null) {
throw new IllegalStateException("EbeanServer not found for name [" + serverName + "]");
throw new IllegalStateException("Database not found for name " + serverName);
}
RemoteTransactionEvent event = new RemoteTransactionEvent(server);
event.readBinary(dataInput);
@@ -1,22 +1,23 @@
package io.ebeaninternal.server.cluster;
import io.avaje.applog.AppLog;
import io.ebean.Database;
import io.ebean.config.ContainerConfig;
import io.ebeaninternal.server.transaction.RemoteTransactionEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Iterator;
import java.util.ServiceLoader;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
import static java.lang.System.Logger.Level.DEBUG;
/**
* Manages the cluster service.
*/
public class ClusterManager implements ServerLookup {
private static final Logger clusterLogger = LoggerFactory.getLogger("io.ebean.Cluster");
private static final System.Logger clusterLogger = AppLog.getLogger("io.ebean.Cluster");
private final ReentrantLock lock = new ReentrantLock();
@@ -112,8 +113,8 @@ public class ClusterManager implements ServerLookup {
*/
public void broadcast(RemoteTransactionEvent event) {
if (broadcast != null) {
if (clusterLogger.isDebugEnabled()) {
clusterLogger.debug("sending: {}", event);
if (clusterLogger.isLoggable(DEBUG)) {
clusterLogger.log(DEBUG, "sending: {0}", event);
}
broadcast.broadcast(event);
}
@@ -119,7 +119,7 @@ public abstract class AbstractSqlQueryRequest implements CancelableQuery {
int firstRow = query.getFirstRow();
int maxRows = query.getMaxRows();
if (firstRow > 0 || maxRows > 0) {
return server.databasePlatform().getBasicSqlLimiter().limit(sql, firstRow, maxRows);
return server.databasePlatform().basicSqlLimiter().limit(sql, firstRow, maxRows);
}
return sql;
}
@@ -6,6 +6,8 @@ import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.SpiTransaction;
import io.ebeaninternal.server.core.timezone.DataTimeZone;
import static java.lang.System.Logger.Level.ERROR;
/**
* Base class for find and persist requests.
*/
@@ -61,7 +63,7 @@ public abstract class BeanRequest {
// Just log this and carry on. A previous exception has been
// thrown and if this rollback throws exception it likely means
// that the connection is broken (and the dataSource and db will cleanup)
CoreLog.log.error("Error trying to rollback a transaction (after a prior exception thrown)", e);
CoreLog.log.log(ERROR, "Error trying to rollback a transaction (after a prior exception thrown)", e);
}
}
}
@@ -15,6 +15,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
import static java.lang.System.Logger.Level.DEBUG;
import static java.lang.System.Logger.Level.INFO;
/**
* Create a DatabasePlatform from the configuration.
* <p>
@@ -38,7 +41,7 @@ public class DatabasePlatformFactory {
try {
String offlinePlatform = DbOffline.getPlatform();
if (offlinePlatform != null) {
CoreLog.log.info("offline platform [{}]", offlinePlatform);
CoreLog.log.log(INFO, "offline platform [{0}]", offlinePlatform);
return byDatabaseName(offlinePlatform);
}
if (config.getDatabasePlatformName() != null) {
@@ -87,7 +90,7 @@ public class DatabasePlatformFactory {
String dbProductName = metaData.getDatabaseProductName().toLowerCase();
final int majorVersion = metaData.getDatabaseMajorVersion();
final int minorVersion = metaData.getDatabaseMinorVersion();
CoreLog.log.debug("platform for productName[{}] version[{}.{}]", dbProductName, majorVersion, minorVersion);
CoreLog.log.log(DEBUG, "platform for productName[{0}] version[{1}.{2}]", dbProductName, majorVersion, minorVersion);
for (DatabasePlatformProvider provider : providers) {
if (provider.matchByProductName(dbProductName)) {
return provider.create(majorVersion, minorVersion, metaData, connection);
@@ -12,18 +12,19 @@ import io.ebeaninternal.server.deploy.BeanDescriptor;
import io.ebeaninternal.server.deploy.BeanDescriptor.EntityType;
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
import io.ebeaninternal.server.transaction.DefaultPersistenceContext;
import org.slf4j.Logger;
import javax.persistence.EntityNotFoundException;
import java.util.List;
import java.util.Set;
import static java.lang.System.Logger.Level.DEBUG;
/**
* Helper to handle lazy loading and refreshing of beans.
*/
final class DefaultBeanLoader {
private static final Logger log = CoreLog.internal;
private static final System.Logger log = CoreLog.internal;
private final DefaultServer server;
private final boolean onIterateUseExtraTxn;
@@ -108,8 +109,8 @@ final class DefaultBeanLoader {
server.findOne(query, null);
if (beanCollection != null) {
if (beanCollection.checkEmptyLazyLoad()) {
if (log.isDebugEnabled()) {
log.debug("BeanCollection after load was empty. Owner:" + beanCollection.getOwnerBean());
if (log.isLoggable(DEBUG)) {
log.log(DEBUG, "BeanCollection after load was empty. Owner:{0}", beanCollection.getOwnerBean());
}
} else if (useManyIdCache) {
parentDesc.cacheManyPropPut(many, beanCollection, parentId);
@@ -228,7 +229,7 @@ final class DefaultBeanLoader {
Object dbBean = query.findOne();
if (dbBean == null) {
throw new EntityNotFoundException("Bean not found during lazy load or refresh." + " id[" + id + "] type[" + desc.type() + "]");
throw new EntityNotFoundException("Bean not found during lazy load or refresh. Id:" + id + " type:" + desc.type());
}
desc.resetManyProperties(dbBean);
}
@@ -1,7 +1,6 @@
package io.ebeaninternal.server.core;
import io.ebean.config.*;
import io.ebean.config.EntityClassRegister;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.event.ShutdownManager;
import io.ebean.service.SpiContainer;
@@ -13,7 +12,6 @@ import io.ebeaninternal.server.cluster.ClusterManager;
import io.ebeaninternal.server.core.bootup.BootupClassPathSearch;
import io.ebeaninternal.server.core.bootup.BootupClasses;
import io.ebeaninternal.server.executor.DefaultBackgroundExecutor;
import org.slf4j.Logger;
import javax.persistence.PersistenceException;
import java.net.URL;
@@ -23,12 +21,14 @@ import java.util.List;
import java.util.ServiceLoader;
import java.util.concurrent.locks.ReentrantLock;
import static java.lang.System.Logger.Level.*;
/**
* Default Server side implementation of ServerFactory.
*/
public final class DefaultContainer implements SpiContainer {
private static final Logger log = CoreLog.log;
private static final System.Logger log = CoreLog.log;
private final ReentrantLock lock = new ReentrantLock();
private final ClusterManager clusterManager;
@@ -108,7 +108,7 @@ public final class DefaultContainer implements SpiContainer {
startServer(online, server);
}
DbOffline.reset();
log.info("Started database[{}] platform[{}] in {}ms", config.getName(), config.getDatabasePlatform().getPlatform(), System.currentTimeMillis() - start);
log.log(INFO, "Started database[{0}] platform[{1}] in {2}ms", config.getName(), config.getDatabasePlatform().platform(), System.currentTimeMillis() - start);
return server;
} finally {
lock.unlock();
@@ -137,7 +137,7 @@ public final class DefaultContainer implements SpiContainer {
private void checkMissingModulePathProvides() {
URL servicesFile = ClassLoader.getSystemResource("META-INF/services/io.ebean.config.EntityClassRegister");
if (servicesFile != null) {
log.error("module-info.java is probably missing 'provides io.ebean.config.EntityClassRegister with EbeanEntityRegister' clause. EntityClassRegister exists but was not service loaded.");
log.log(ERROR, "module-info.java is probably missing 'provides io.ebean.config.EntityClassRegister with EbeanEntityRegister' clause. EntityClassRegister exists but was not service loaded.");
}
}
@@ -201,7 +201,7 @@ public final class DefaultContainer implements SpiContainer {
DatabasePlatform platform = config.getDatabasePlatform();
if (platform == null) {
if (config.getTenantMode().isDynamicDataSource()) {
throw new IllegalStateException("DatabasePlatform must be explicitly set on DatabaseConfig for TenantMode "+config.getTenantMode());
throw new IllegalStateException("DatabasePlatform must be explicitly set on DatabaseConfig for TenantMode " + config.getTenantMode());
}
// automatically determine the platform
platform = new DatabasePlatformFactory().create(config);
@@ -215,7 +215,7 @@ public final class DefaultContainer implements SpiContainer {
*/
private void setDataSource(DatabaseConfig config) {
if (isOfflineMode(config)) {
log.debug("... DbOffline using platform [{}]", DbOffline.getPlatform());
log.log(DEBUG, "... DbOffline using platform [{0}]", DbOffline.getPlatform());
} else {
InitDataSource.init(config);
}
@@ -251,7 +251,7 @@ public final class DefaultContainer implements SpiContainer {
}
try (Connection connection = config.getDataSource().getConnection()) {
if (connection.getAutoCommit()) {
log.warn("DataSource [{}] has autoCommit defaulting to true!", config.getName());
log.log(WARNING, "DataSource [{0}] has autoCommit defaulting to true!", config.getName());
}
return true;
} catch (SQLException ex) {
@@ -1,23 +1,24 @@
package io.ebeaninternal.server.core;
import io.avaje.applog.AppLog;
import io.ebean.config.QueryPlanCapture;
import io.ebean.config.QueryPlanListener;
import io.ebean.meta.MetaQueryPlan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.lang.System.Logger.Level.INFO;
final class DefaultQueryPlanListener implements QueryPlanListener {
static final QueryPlanListener INSTANT = new DefaultQueryPlanListener();
private static final Logger log = LoggerFactory.getLogger("io.ebean.QUERYPLAN");
private static final System.Logger log = AppLog.getLogger("io.ebean.QUERYPLAN");
@Override
public void process(QueryPlanCapture capture) {
// better to log this in JSON form?
String dbName = capture.database().name();
for (MetaQueryPlan plan : capture.plans()) {
log.info("queryPlan db:{} label:{} queryTimeMicros:{} loc:{} sql:{} bind:{} plan:{}",
log.log(INFO, "queryPlan db:{0} label:{1} queryTimeMicros:{2} loc:{3} sql:{4} bind:{5} plan:{6}",
dbName, plan.label(), plan.queryTimeMicros(), plan.profileLocation(),
plan.sql(), plan.bind(), plan.plan());
}
@@ -2,49 +2,11 @@ package io.ebeaninternal.server.core;
import io.avaje.lang.NonNullApi;
import io.avaje.lang.Nullable;
import io.ebean.AutoTune;
import io.ebean.BackgroundExecutor;
import io.ebean.BeanState;
import io.ebean.CallableSql;
import io.ebean.DocumentStore;
import io.ebean.DtoQuery;
import io.ebean.ExpressionFactory;
import io.ebean.ExpressionList;
import io.ebean.ExtendedServer;
import io.ebean.Filter;
import io.ebean.FutureIds;
import io.ebean.FutureList;
import io.ebean.FutureRowCount;
import io.ebean.MergeOptions;
import io.ebean.MergeOptionsBuilder;
import io.ebean.PagedList;
import io.ebean.PersistenceContextScope;
import io.ebean.ProfileLocation;
import io.ebean.Query;
import io.ebean.QueryIterator;
import io.ebean.RowConsumer;
import io.ebean.RowMapper;
import io.ebean.ScriptRunner;
import io.ebean.SqlQuery;
import io.ebean.SqlRow;
import io.ebean.SqlUpdate;
import io.ebean.Transaction;
import io.ebean.TransactionCallback;
import io.ebean.TxScope;
import io.ebean.Update;
import io.ebean.UpdateQuery;
import io.ebean.ValuePair;
import io.ebean.Version;
import io.ebean.*;
import io.ebean.annotation.Platform;
import io.ebean.annotation.TxIsolation;
import io.ebean.bean.BeanCollection;
import io.ebean.bean.BeanLoader;
import io.ebean.bean.CallOrigin;
import io.ebean.bean.EntityBean;
import io.ebean.bean.EntityBeanIntercept;
import io.ebean.bean.PersistenceContext;
import io.ebean.bean.*;
import io.ebean.bean.PersistenceContext.WithOption;
import io.ebean.bean.SingleBeanLoader;
import io.ebean.cache.ServerCacheManager;
import io.ebean.common.CopyOnFirstWriteList;
import io.ebean.config.*;
@@ -53,17 +15,12 @@ import io.ebean.event.BeanPersistController;
import io.ebean.event.ShutdownManager;
import io.ebean.event.readaudit.ReadAuditLogger;
import io.ebean.event.readaudit.ReadAuditPrepare;
import io.ebean.meta.MetaInfoManager;
import io.ebean.meta.MetaQueryPlan;
import io.ebean.meta.MetricVisitor;
import io.ebean.meta.QueryPlanInit;
import io.ebean.meta.QueryPlanRequest;
import io.ebean.meta.*;
import io.ebean.migration.auto.AutoMigrationRunner;
import io.ebean.plugin.BeanType;
import io.ebean.plugin.Plugin;
import io.ebean.plugin.Property;
import io.ebean.plugin.SpiServer;
import io.ebean.text.csv.CsvReader;
import io.ebean.text.json.JsonContext;
import io.ebeaninternal.api.*;
import io.ebeaninternal.api.SpiQuery.Type;
@@ -78,30 +35,15 @@ import io.ebeaninternal.server.dto.DtoBeanDescriptor;
import io.ebeaninternal.server.dto.DtoBeanManager;
import io.ebeaninternal.server.el.ElFilter;
import io.ebeaninternal.server.grammer.EqlParser;
import io.ebeaninternal.server.query.CQuery;
import io.ebeaninternal.server.query.CQueryEngine;
import io.ebeaninternal.server.query.CallableQueryCount;
import io.ebeaninternal.server.query.CallableQueryIds;
import io.ebeaninternal.server.query.CallableQueryList;
import io.ebeaninternal.server.query.DtoQueryEngine;
import io.ebeaninternal.server.query.LimitOffsetPagedList;
import io.ebeaninternal.server.query.QueryFutureIds;
import io.ebeaninternal.server.query.QueryFutureList;
import io.ebeaninternal.server.query.QueryFutureRowCount;
import io.ebeaninternal.server.querydefn.DefaultDtoQuery;
import io.ebeaninternal.server.querydefn.DefaultOrmQuery;
import io.ebeaninternal.server.querydefn.DefaultOrmUpdate;
import io.ebeaninternal.server.querydefn.DefaultRelationalQuery;
import io.ebeaninternal.server.querydefn.DefaultUpdateQuery;
import io.ebeaninternal.server.query.*;
import io.ebeaninternal.server.querydefn.*;
import io.ebeaninternal.server.rawsql.SpiRawSql;
import io.ebeaninternal.server.text.csv.TCsvReader;
import io.ebeaninternal.server.transaction.DefaultPersistenceContext;
import io.ebeaninternal.server.transaction.RemoteTransactionEvent;
import io.ebeaninternal.server.transaction.TransactionManager;
import io.ebeaninternal.util.ParamTypeHelper;
import io.ebeaninternal.util.ParamTypeHelper.TypeInfo;
import io.ebeanservice.docstore.api.DocStoreIntegration;
import org.slf4j.Logger;
import javax.persistence.NonUniqueResultException;
import javax.persistence.OptimisticLockException;
@@ -120,6 +62,7 @@ import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
import static java.lang.System.Logger.Level.*;
import static java.util.Spliterators.spliteratorUnknownSize;
import static java.util.stream.StreamSupport.stream;
@@ -129,7 +72,7 @@ import static java.util.stream.StreamSupport.stream;
@NonNullApi
public final class DefaultServer implements SpiServer, SpiEbeanServer {
private static final Logger log = CoreLog.internal;
private static final System.Logger log = CoreLog.internal;
private final ReentrantLock lock = new ReentrantLock();
private final DatabaseConfig config;
@@ -306,7 +249,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public Platform platform() {
return databasePlatform.getPlatform();
return databasePlatform.platform();
}
@Override
@@ -373,7 +316,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
migrationRunner.setDefaultDbSchema(dbSchema);
}
migrationRunner.setName(config.getName());
Platform platform = config.getDatabasePlatform().getPlatform();
Platform platform = config.getDatabasePlatform().platform();
migrationRunner.setBasePlatform(platform.base().name().toLowerCase());
migrationRunner.setPlatform(platform.name().toLowerCase());
migrationRunner.loadProperties(config.getProperties());
@@ -386,7 +329,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
if (config.isQueryPlanCapture()) {
long secs = config.getQueryPlanCapturePeriodSecs();
if (secs > 10) {
log.info("capture query plan enabled, every {}secs", secs);
log.log(INFO, "capture query plan enabled, every {0}secs", secs);
backgroundExecutor.scheduleWithFixedDelay(this::collectQueryPlans, secs, secs, TimeUnit.SECONDS);
}
}
@@ -434,7 +377,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
* Shutdown the services like threads and DataSource.
*/
private void shutdownInternal(boolean shutdownDataSource, boolean deregisterDriver) {
log.trace("shutting down instance {}", serverName);
log.log(TRACE, "shutting down instance {0}", serverName);
if (shutdown) {
// already shutdown
return;
@@ -463,7 +406,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
try {
plugin.shutdown();
} catch (Exception e) {
log.error("Error when shutting down plugin", e);
log.log(ERROR, "Error when shutting down plugin", e);
}
}
}
@@ -615,7 +558,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
try (Connection connection = dataSource().getConnection()) {
for (String table : tables) {
executeSql(connection, databasePlatform.truncateStatement(table));
if (databasePlatform.getPlatform().base() == Platform.DB2) {
if (databasePlatform.platform().base() == Platform.DB2) {
// DB2 requires commit after each truncate statement
connection.commit();
}
@@ -862,10 +805,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
return new ElFilter<>(desc(beanType));
}
@Override
public <T> CsvReader<T> createCsvReader(Class<T> beanType) {
return new TCsvReader<>(this, desc(beanType));
}
@Override
public <T> UpdateQuery<T> update(Class<T> beanType) {
@@ -1140,7 +1079,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
if (list.isEmpty()) {
return null;
} else if (list.size() > 1) {
throw new NonUniqueResultException("Unique expecting 0 or 1 results but got [" + list.size() + "]");
throw new NonUniqueResultException("Unique expecting 0 or 1 results but got " + list.size());
} else {
return list.get(0);
}
@@ -1330,7 +1269,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
copy.setFutureFetch(true);
Transaction newTxn = createTransaction();
QueryFutureRowCount<T> queryFuture = new QueryFutureRowCount<>(new CallableQueryCount<>(this, copy, newTxn));
backgroundExecutor.execute(queryFuture.getFutureTask());
backgroundExecutor.execute(queryFuture.futureTask());
return queryFuture;
}
@@ -1340,7 +1279,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
copy.setFutureFetch(true);
Transaction newTxn = createTransaction();
QueryFutureIds<T> queryFuture = new QueryFutureIds<>(new CallableQueryIds<>(this, copy, newTxn));
backgroundExecutor.execute(queryFuture.getFutureTask());
backgroundExecutor.execute(queryFuture.futureTask());
return queryFuture;
}
@@ -1357,7 +1296,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
// Create a new transaction solely to execute the findList() at some future time
Transaction newTxn = createTransaction();
QueryFutureList<T> queryFuture = new QueryFutureList<>(new CallableQueryList<>(this, spiQuery, newTxn));
backgroundExecutor.execute(queryFuture.getFutureTask());
backgroundExecutor.execute(queryFuture.futureTask());
return queryFuture;
}
@@ -2038,7 +1977,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
return desc(bean.getClass()).getId(eb);
}
private <T> BeanDescriptor<T> desc(Class<T> beanClass) {
private <T> BeanDescriptor<T> desc(Class<T> beanClass) {
BeanDescriptor<T> desc = descriptorManager.descriptor(beanClass);
if (desc == null) {
throw new PersistenceException(beanClass.getName() + " is NOT an Entity Bean registered with this server?");
@@ -2130,7 +2069,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
try {
serverCacheManager.clearLocal(Class.forName(cache));
} catch (Exception e) {
log.error("Error clearing local cache for type " + cache, e);
log.log(ERROR, "Error clearing local cache for type " + cache, e);
}
}
}

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