Compare commits

..
Author SHA1 Message Date
robin 907b182931 [maven-release-plugin] prepare release ebean-parent-12.7.2 2021-03-01 23:45:05 +13:00
robin 1a26cd717f #2182 - Tidy javadoc - this may mean JDK 15 is required to generate javadoc 2021-03-01 23:40:06 +13:00
Robin Bygrave 7bfacb095b #2181 - Oracle 9,10,11 rownum based limiting for SqlQuery and DtoQuery (rather than Oracle 12g row limiting) 2021-03-01 22:47:34 +13:00
Robin Bygrave 6315edfc21 #2177 - findNative not mapping bean when schema specified in entity mapping 2021-03-01 22:08:17 +13:00
Robin Bygrave 464f48d717 Bump test kotlin-querybean-generator version 2021-03-01 21:34:17 +13:00
Robin Bygrave eacfaf3403 No effective change - refactor tidy SqlTreeNodeBean 2021-03-01 21:19:25 +13:00
Rob BygraveandGitHub 36d8028045 Merge pull request #2180 from ebean-orm/feature/refactor-SqlTreeNodeBean
Improved fix for #2179 - Fetch on nested one-to-many collectio…
2021-03-01 20:32:08 +13:00
Robin Bygrave 297c1d7abb #2179 - Improved fix for (2179) Fetch on nested one-to-many collections results in duplicates
The improvement here is that SqlTreeNodeManyRoot uses load and isContextBean() so that it only checks if the collection already contains the detailBean if the detailBean was already in the persistence context (aka not newly loaded and added).  The vast majority case is that detailBean is loaded fresh so for the common case we can skip the extra collection contains() check.
2021-03-01 20:27:50 +13:00
Robin Bygrave 5a73c85e6e Refactor internals - SqlTreeNodeBean add derived readIdNormal + private methods
This is no effective change
2021-03-01 18:36:49 +13:00
Robin Bygrave 68138bc009 Refactor internals no effective change - reorder methods of SqlTreeNodeManyRoot 2021-03-01 17:45:52 +13:00
Robin Bygrave 8c7df3212a Refactor internals add SqlTreeRoot as follow up to #2179
Adds SqlTreeRoot interface to make it more explicit that SqlTreeNodeRoot is the only valid top level node in the sql tree (and as such has the root level load() method)
2021-03-01 17:44:13 +13:00
Robin Bygrave 5ebad53072 #2179 - Improve internals for outer join resulting in null many bean
Refactor improving the BeanList.internalAddWithCheck() for the null bean case
2021-03-01 14:00:40 +13:00
Robin Bygrave 640824ae31 Merge branch 'bkempe-nested_fetch_duplicates' 2021-03-01 13:39:16 +13:00
Robin Bygrave 6acf93c978 #2178 - Fix for duplicate instances added to collection for nested one-to-many fetch
This is an initial fix for this case.
2021-03-01 13:38:40 +13:00
Robin Bygrave 6897e06dcd Merge branch 'nested_fetch_duplicates' of https://github.com/bkempe/ebean into bkempe-nested_fetch_duplicates 2021-03-01 10:23:49 +13:00
Ben Kempe d036af8d1a Add more assertions for nested one-to-many fetch 2021-02-28 19:06:51 +01:00
robin b77c62e0db [maven-release-plugin] prepare for next development iteration 2021-02-19 22:51:03 +13:00
robin bbf46bb0ec [maven-release-plugin] prepare release ebean-parent-12.7.1 2021-02-19 22:50:53 +13:00
Rob BygraveandGitHub 6aa4337b27 #2174 - Entity beans with @Cache + @DbArray of enums (or UUID or Integer) not converted to enums (come back as String) (#2175) 2021-02-19 22:42:48 +13:00
Robin Bygrave 99d7a4e4b4 Tidy up pom jackson dependency versions (all optional dependencies) and bump to 2.12.1 2021-02-19 09:43:56 +13:00
Robin Bygrave b7da2cbd97 #2173 - ebean-test: Add assertContains - DbJson.of(entityBean).assertContains(...) 2021-02-19 09:29:06 +13:00
Rob BygraveandGitHub b4ae721998 #2169 Refactor after #2170 tidy javax/jakarta validation annotation reading (#2171)
Introduces ReadValidationAnnotations with javax and jakarta implementations and moves the validation annotation reading there
2021-02-17 22:23:07 +13:00
André CamiloandGitHub 3bb4126e26 #2169 Support for jakarta.validation.constraints.NotNull and (#2170)
jakarta.validation.constraints.Size
2021-02-17 18:04:43 +13:00
robin de439e7695 Improve Refactor internals OrmQueryProperties invert isEmpty()
Rename to hasProperties() and improve javadoc
2021-02-16 23:20:44 +13:00
robin e5ec72df5c Refactor internals OrmQueryProperties invert isEmpty() -> nonEmpty() 2021-02-16 20:37:58 +13:00
Rob BygraveandGitHub 98a89156bf Refactor query internals to reduce property parsing for partial select and fetch (#2167)
* Update test only - update TestBasicClobNoVer to use DB and AssertJ

* Refactor OrmQueryProperties internals to reduce raw property parsing

- Remove String properties
- Reduces parsing of properties via  fetchProperties() selectProperties() methods

* No effective change - tidy pom.xml for ebean-querybean

* Refactor query internals adding fetchProperties() selectProperties()

- Adds SpiQueryFetch
- Used by query beans with Set<String> properties passed (effectively skipping any parsing)
2021-02-16 17:51:47 +13:00
robin dc65475dbb #2168 - Using ebean-test with redis container - hanging testing redis connectivity 2021-02-16 17:47:56 +13:00
rob bygrave cc64ff5f10 Update javadoc with use of FetchConfig.ofQuery() etc 2021-02-14 11:37:19 +13:00
rob bygrave ab87174e5b #2163 - Fix OrmQueryProperties when FetchConfig null 2021-02-14 11:30:24 +13:00
Rob BygraveandGitHub a6fdc42934 Remove support for "query hints" like +query(50) (#2163)
* Remove support for "query hints" like +query(50)

* Remove unused readOnly from OrmQueryProperties

* OrmQueryProperties cache as final field
2021-02-14 11:21:10 +13:00
rob bygrave 4c16b85e85 #2166 - Remove deprecated forUpdate(lockType) methods - migrate to withLock(lockType, waitType) 2021-02-14 10:52:18 +13:00
rob bygrave 9e3d6c6a08 #2165 - Joda LocalDate West of UTC converts incorrectly (Fix: change from epoc millis conversion to y/m/d conversion) 2021-02-14 10:28:55 +13:00
Rob BygraveandGitHub d567872813 Deprecate the mutating methods of FetchConfig to migrate to the static factory methods (#2164)
e.g. migrate from            ->   to use
new FetchConfig().query()    ->   FetchConfig.ofQuery()
new FetchConfig().query(50)  ->   FetchConfig.ofQuery(50)
2021-02-13 14:50:02 +13:00
rob bygrave 7069d3f600 Update tests to use fetchQuery and fetchLazy rather than FetchConfig 2021-02-13 12:31:00 +13:00
rob bygrave b2f8b7c711 Bump pom version to 12.7.1-SNAPSHOT 2021-02-13 12:29:17 +13:00
rob bygrave 4092ea307e Bump pom version to 12.7.1-SNAPSHOT 2021-02-13 12:29:09 +13:00
rob bygrave 01f64ef9f9 git push origin masterMerge branch 'feature/refactor-FetchConfig' 2021-02-13 12:10:39 +13:00
rob bygrave f1a48b182e Refactor FetchConfig 2021-02-13 12:10:21 +13:00
Rob BygraveandGitHub 8ac5467856 Improve internal calculation of orm query plan hash key (Require use of inline hints like +query(50) to be comma delimited with properties) (#2159)
* WIP Tidy DefaultOrmQuery planDescription()

* WIP Tidy DefaultOrmQuery planDescription()

* Refactor OrmQueryPropertiesParser with hints requiring comma delimiting (previously didn't)

* Refactor OrmQueryPropertiesParser (reuse inputProperties) and DRawSqlColumnsParser (to return Set)

* Refactor OrmQueryPropertiesParser - remove JunkMain

* Refactor OrmQueryDetail, OrmQueryProperties - properties
2021-02-13 11:58:00 +13:00
SnōwballandGitHub 758f84f573 Ignore special kotlin collection types (#2130)
Kotlin prefers(emits compiler warnings if not) the built-in types
e.g. Set and MutableSet instead of the java.util.* variety. This
patch removes the imports for those, so the built-in varieties are
used.
2021-02-13 11:56:04 +13:00
rob bygrave 2073fefc92 #2162 - Change ebean artifact such that ebean-ddl-generator is a dependency of ebean-test and ebean-autotune optional 2021-02-12 23:12:32 +13:00
rob bygrave 5b98d8d9c2 [maven-release-plugin] prepare for next development iteration 2021-02-12 22:27:45 +13:00
rob bygrave 8e59e72983 [maven-release-plugin] prepare release ebean-parent-12.6.7 2021-02-12 22:27:34 +13:00
rob bygrave b56d68dac7 #2157 - ManyToMany mapping to itself results in broken generated SQL DDL when not defining @JoinTable. 2021-02-12 22:17:04 +13:00
rob bygrave e0c3a92b60 Refactor FetchConfig 2021-02-12 21:01:57 +13:00
Robin Bygrave 213562fcf1 No change - update ddl review for h2 2021-02-12 16:34:24 +13:00
Rob BygraveandGitHub d3a09b93c0 #2156 - Using @OneToOne(targetEntity...) with Interface field results in BeanNotRegisteredException (#2160) 2021-02-12 16:30:28 +13:00
Robin Bygrave 536ea57369 Merge branch 'master' of https://github.com/ebean-orm/ebean 2021-02-11 17:28:21 +13:00
Robin Bygrave ac1dd4cbab #2158 Refactor to use try with resources with Connection for platform selection via jdbc metaData 2021-02-11 17:28:05 +13:00
Robin Bygrave bc33e05906 #2158 - Oracle - automatic platform selection doesn't select older Oracle11Platform via jdbc metadata major version 2021-02-11 17:20:28 +13:00
rob bygrave 8ecc407cb0 #2154 - Fix tests for QueryBeans: TargetEntity is not evaluated during bean generation resulting in bad query beans 2021-02-10 19:25:42 +13:00
Robin Bygrave 2672dff512 #2155 - QueryBeans: Change to use own @Generated with retention RUNTIME 2021-02-10 15:28:55 +13:00
Robin Bygrave 74d907bbce Refactor kotlin querybean generator ProcessingContext extract asElement() method 2021-02-10 15:12:28 +13:00
Robin Bygrave 53aacabce7 #2154 - QueryBeans: TargetEntity is not evaluated during bean generation resulting in bad query beans 2021-02-10 15:10:03 +13:00
Robin Bygrave ab9cdd8f5b #2153 - QueryBeans: OneToMany Map property is handled as PScalar instead of TQAssocBean 2021-02-10 13:52:29 +13:00
Robin Bygrave b3d439ed11 Bump tile-maven-plugin to 2.19 2021-02-10 13:00:50 +13:00
Robin Bygrave d57657c209 #2127 - Fix for - Adding a new list of children to @OneToMany with orphanRemoval true does not delete existing orphans
Modifies EntityBeanIntercept preSetterMany to set the changed state on the many property and use this in SaveManyBeans to detect when the existing beans need orphan removal
2021-02-04 15:45:19 +13:00
Robin Bygrave dd080c5933 Test only change - refactor update TestBeanState 2021-02-04 15:19:34 +13:00
Rob BygraveandGitHub 0be98d7989 Fix to only cancel query once (#2152)
Change DefaultOrmQuery.cancel() to call underlying jdbc cancel once

- Refactor tidy already cancelled check (pre query execution)
- Remove unnecessary extra transaction.end() call on future query execution (as already handled by CallableQueryList etc)
2021-02-03 14:51:42 +13:00
rob bygrave fca54dbbe3 [maven-release-plugin] prepare for next development iteration 2021-01-24 17:42:50 +13:00
rob bygrave 7ec5fe6a85 [maven-release-plugin] prepare release ebean-parent-12.6.6 2021-01-24 17:42:38 +13:00
rob bygrave 9ea5505214 Bump to ebean agent 12.6.6 2021-01-24 17:40:13 +13:00
Robin Bygrave 75d3b566a7 Merge branch 'FOCONIS-prePersist-postPersist-fix-batch-flush-12' 2021-01-22 14:01:19 +13:00
Robin Bygrave e38059f52c #2149 - Fix for ADD: jdbc batch flush doesnt execute sql statements created in lifecycle methods (e.g. beans saved in PostInsert etc)
Note that the foconis fork has a onPersist extension which is removed from the test.
2021-01-22 14:00:48 +13:00
Robin Bygrave 72331aa945 Merge branch 'prePersist-postPersist-fix-batch-flush-12' of https://github.com/FOCONIS/ebean into FOCONIS-prePersist-postPersist-fix-batch-flush-12 2021-01-22 13:14:05 +13:00
Robin Bygrave e497c54f82 No effective change - modify test redis ClusterTest to have 20ms wait 2021-01-21 17:01:36 +13:00
Robin Bygrave b44091ff3a #2147 Fix for ADD: multiple to many outer joins cause wrong count in distinct count…
Copy of Rolands fix in FOCONIS branch. This also brings over some of the extra tests found there.

Note that the SQL is slightly different from the FOCONIS branch in that there is additional foreign key columns included in the sub-query select clause.
2021-01-21 16:56:42 +13:00
Robin Bygrave 2ab889f889 Merge branch 'FOCONIS-count-distinct-with-two-joins-12' 2021-01-21 14:50:32 +13:00
Robin Bygrave 23541e661e Merge branch 'count-distinct-with-two-joins-12' of https://github.com/FOCONIS/ebean into FOCONIS-count-distinct-with-two-joins-12 2021-01-21 14:45:56 +13:00
trojo 6778e37652 ADD: batch flash doesnt execute sql statements created in lifecycle methods 2021-01-20 17:43:14 +01:00
rob bygrave 5eac31283d #2148 - PersistenceException: No ScalarType registered for class java.util.LinkedHashMap 2021-01-20 23:31:45 +13:00
trojo 38016773d4 added comments 2021-01-20 10:47:53 +01:00
trojo ad80eb267f ADD: multiple to many outer joins cause wrong count in distinct count queries 2021-01-20 09:57:25 +01:00
rob bygrave 449e0832e0 Merge branch 'FOCONIS-cache-with-lazyload-wrong-12' 2021-01-20 21:37:57 +13:00
rob bygrave f28f5c9a01 #2146 - no change - Tidy test only TestWithCacheAndLazyLoad 2021-01-20 21:37:29 +13:00
rob bygrave 9dd28d8879 #2146 - Fix for Cache with lazy load doesnt work
When the list is empty() it has already been loaded and loading should skip the l2 cache
2021-01-20 21:10:49 +13:00
rob bygrave b47eec99a5 Merge branch 'cache-with-lazyload-wrong-12' of https://github.com/FOCONIS/ebean into FOCONIS-cache-with-lazyload-wrong-12 2021-01-20 20:36:18 +13:00
Robin Bygrave 99bb55efa0 No change - update ebean-test test configuration only for windows 2021-01-20 17:22:00 +13:00
Robin Bygrave 4408eb618a No change - update test only - TestHistoryOneToMany with wait for when run on windows 2021-01-20 17:11:07 +13:00
rob bygrave 9ccd1b1b27 No effective change - tidy whitespace in SqlTreeBuilder and SqlTreeNodeExtraJoin 2021-01-20 00:10:09 +13:00
rob bygrave 0c1657fef5 #2145 - SoftDelete predicate missing on join to ManyToOne supporting predicate expression 2021-01-20 00:00:27 +13:00
Noemi Szemenyei ee393c6485 ADD: testcase for wrong lazyload with cache 2021-01-19 11:41:19 +01:00
rob bygrave 7f68b9d846 No effective change - tidy whitespace in BeanDescriptorCacheHelp 2021-01-19 22:48:29 +13:00
rob bygrave 2035a3344e Merge branch 'FOCONIS-persistcontext-wrong' 2021-01-19 22:37:45 +13:00
rob bygrave ade36582a0 #2144 - Fix for NPE via Wrong beans in PersistContext avoid proper lazy load 2021-01-19 22:37:15 +13:00
Roland Praml a4b8be61e3 ADD: some suggestions/debug hints 2021-01-11 11:50:25 +01:00
Roland Praml b7feb62ecd ADD: testcase for broken lazyload 2021-01-11 11:50:05 +01:00
rob bygrave 7e48f7c8eb [maven-release-plugin] prepare for next development iteration 2021-01-05 18:02:21 +13:00
rob bygrave 501f8111fe [maven-release-plugin] prepare release ebean-parent-12.6.5 2021-01-05 18:02:09 +13:00
rob bygrave d8f4503d98 #2141 - Fix for failing test, revert of fix for #2127 2021-01-05 17:56:55 +13:00
Rob BygraveandGitHub 0d83978c58 Merge pull request #2141 from tobias-/failing_cascade_test_case_2
Failing testcase that shows wipe of all old children on save
2021-01-05 17:30:56 +13:00
Tobias 69e56be459 Failing testcase that shows wipe of all old children on save
When adding a child to a newly saved bean (A), all other children are
killed on save of A.
2020-12-28 15:35:15 +01:00
rob bygrave 35a721039d [maven-release-plugin] prepare for next development iteration 2020-12-23 20:25:47 +13:00
rob bygrave 98b4ac5029 [maven-release-plugin] prepare release ebean-parent-12.6.4 2020-12-23 20:25:22 +13:00
rob bygrave fe874c946d #2140 - Bump ebean-migration dependency of ebean-ddl-generator to 12.4.0 (update ebean-test) 2020-12-23 20:22:50 +13:00
rob bygrave 53386e9bf4 Update ebean-core-type name and description only 2020-12-22 16:12:20 +13:00
rob bygrave 5435055f5c Add ebean-redis, ebean-postgis and ebean-core-type to ebean-bom 2020-12-22 16:08:59 +13:00
rob bygrave 583e10f5c6 #2139 - Fix for - Failing testcase that shows wipe of all children on save (related to #2127) 2020-12-22 15:49:37 +13:00
Rob BygraveandGitHub 5393d709a3 Merge pull request #2139 from tobias-/failing_cascade_test_case
Failing testcase that shows wipe of all children on save
2020-12-22 14:55:12 +13:00
Tobias fc1c9392aa Failing testcase that shows wipe of all children on save
When adding a newly saved bean (A) to another bean (B), all children
in A are wiped on saving B.
2020-12-21 15:32:40 +01:00
rob bygrave 6b2c48d4f6 #2135 - ebean doest not support Spring @Transactional(propagation = Propagation.REQUIRES_NEW) 2020-12-21 16:40:19 +13:00
rob bygrave 400ae3cf4b #2138 - Mark Transaction.flushBatch() as deprecated - migrate to flush(); 2020-12-21 14:58:04 +13:00
rob bygrave f22a322104 No effective change - Refactor tidy AbstractSqlQueryRequest after #2137
- Rename trans to transaction
- Tidy whitespace
2020-12-21 14:18:13 +13:00
rob bygrave e98ff952bf #2137 - Expected Transaction flush on SqlQuery and DtoQuery not occurring 2020-12-21 14:11:28 +13:00
rob bygrave 573e1b553c [maven-release-plugin] prepare for next development iteration 2020-12-18 15:04:05 +13:00
rob bygrave a674d0d696 [maven-release-plugin] prepare release ebean-parent-12.6.3 2020-12-18 15:03:53 +13:00
Rob BygraveandGitHub 5393161c16 Merge pull request #2132 from ebean-orm/feature/redisModule
Add ebean-redis as module
2020-12-18 14:58:07 +13:00
rob bygrave 1bdc6d8f7f #2134 - Modify ChangeLog to send the last set of changes Pre Commit (rather than post commit). Expose this for spring transactions. 2020-12-18 14:54:44 +13:00
rob bygrave e9081a176f #2133 - Spring transactions not getting ChangeLog changeSet as part of postCommit() processing 2020-12-18 14:14:43 +13:00
rob bygrave 3e7db2887f Add ebean-redis as module 2020-12-17 14:38:54 +13:00
rob bygrave fcf14ac222 Add ebean-redis as module 2020-12-17 11:56:34 +13:00
Rob BygraveandGitHub 55324653a5 #2127 - Adding a new list of children to @OneToMany with orphanRemoval true does not delete existing orphans (#2131) 2020-12-16 15:36:44 +13:00
SnōwballandGitHub a132f09b03 Ignore javax.persistence.Transient in query beans (#2129)
* Add failing tests for transient types

* Ignore jpa @Transient fields in query beans

Any field marked with jpa @Transient should be ignored
2020-12-15 12:40:06 +13:00
rob bygrave 48eac84930 #2128 - Bump avaje-config dependency to 1.3 - Fix for - Repeated calls to Config.get() with no value, expect to return passed default value 2020-12-14 09:31:08 +13:00
rob bygrave 948619a125 [maven-release-plugin] prepare for next development iteration 2020-12-09 13:11:19 +13:00
rob bygrave 0cd0741f18 [maven-release-plugin] prepare release ebean-parent-12.6.2 2020-12-09 13:11:07 +13:00
rob bygrave 01a3455ecb Bump test dependency for kotlin-querybean-generator release 2020-12-08 20:51:52 +13:00
rob bygrave 610f7db1cb Bump test dependency kotlin version to 1.4.21 after issues downloading 1.4.10 from maven central? 2020-12-08 20:46:36 +13:00
rob bygrave 373ef6d1eb #2126 - Bump ebean-migration to 12.4.0 2020-12-08 20:29:34 +13:00
rob bygrave f1b1cee2fd Bump enhancement tile 2020-12-08 15:43:31 +13:00
rob bygrave a73e4f23ff Bump agent version in BOM 2020-12-08 15:41:59 +13:00
rob bygrave 9a5d3498c1 #2125 - Bump ebean-test-docker dependency to 4.1 2020-12-07 23:00:02 +13:00
rob bygrave 0b24d635ad Tests only - update ddl review 2020-12-07 22:48:32 +13:00
rob bygrave b623e19dae update git ignore 2020-12-07 22:47:43 +13:00
rob bygrave 7389a8b344 #2124 - ENH: Add name() attribute to @DbArray, @DbJson, @DbJsonB, @DbMap 2020-12-07 22:46:04 +13:00
rob bygrave d68f477e8e #2120 - DbEnumValue without database constraint 2020-12-07 21:53:03 +13:00
rob bygrave dbe273bb56 #2123 - Modify BackgroundExecutor API - add scheduleWithFixedDelay() and mark executePeriodically() as deprecated 2020-12-07 17:14:03 +13:00
rob bygrave 1a4377da29 Improve tests TestQueryForUpdate and TestSoftDeleteBasic 2020-12-07 13:29:47 +13:00
rob bygrave c3cdecaa60 Fix test TestSqlUpdateBatch with correct bind type for Postgres 2020-12-07 10:06:15 +13:00
rob bygrave 9d706056c6 No functional change, replace new ReentrantLock(false) with new ReentrantLock() 2020-12-04 21:18:55 +13:00
rob bygrave cb0100f02a Refactor tidy BeanDescriptor, no effective change 2020-12-04 21:11:02 +13:00
rob bygrave 9c6dd0989a Refactor tidy BeanDescriptorManager whitespace and raw types 2020-12-04 21:03:08 +13:00
rob bygrave a23a179bbf Fix test bump kotlin-querybean-generator 12.6.2-SNAPSHOT 2020-12-04 20:45:38 +13:00
rob bygrave 365b7c4600 #2122 - Metrics for ElementCollection query not included in reporting (via MetaInfoManager) 2020-12-04 20:41:40 +13:00
rob bygrave ed2455f460 #2121 - Refactor internals move DefaultBackgroundExecutor etc 2020-12-03 15:47:14 +13:00
rob bygrave 046033627a Update tests - generated sql for add constraint foreign key 2020-12-03 13:22:13 +13:00
Rob BygraveandGitHub 786444a6b9 Refactor BackgroundExecutor add submit() methods returning Future (#2121)
- Adds submit() methods that return Future
- Refactor internals to use DaemonScheduleThreadPool
- Delete the now unused DaemonExecutorService
- Tidy internals using wrapMDC() methods
2020-12-03 13:16:51 +13:00
rob bygrave 9ab26cfb9d #2118 - Fix test only PlatformDdl_AlterColumnTest 2020-12-03 09:48:41 +13:00
rob bygrave aa1e3ea1bc #2118 - Generated code for @DbForeignKey reading onDelete and Ignores onUpdate 2020-12-01 22:04:07 +13:00
Rob BygraveandGitHub c66875449b Add Query.withLock(LockType) and withLock(LockType, LockWait) (#2116)
Add Query.withLock(LockType) and withLock(LockType, LockWait)
2020-12-01 21:31:53 +13:00
rob bygrave f6c4024ae5 No effective change - tidy test only, TestStatelessUpdate 2020-12-01 21:17:19 +13:00
rob bygrave 2c8cc793ab No effective change - tidy test only, TestStatelessUpdate 2020-12-01 14:29:37 +13:00
rob bygrave 66454d2e61 No effective change - bump test dependency for ebean-ddl-generator 2020-11-26 08:57:19 +13:00
rob bygrave e7b13cf2d9 [maven-release-plugin] prepare for next development iteration 2020-11-25 22:48:17 +13:00
rob bygrave 04cd520719 [maven-release-plugin] prepare release ebean-parent-12.6.1 2020-11-25 22:48:05 +13:00
rob bygrave 838af0478e #2113 - Refactor rename Query.LockType enum names 2020-11-25 22:32:59 +13:00
rob bygrave 9064e96b90 #2113 - Refactor rename Query.ForUpdate to Query.LockWait
Slightly improve the name of the enum. Note that although this is on public Query it's only internally used.
2020-11-25 22:23:17 +13:00
Rob BygraveandGitHub 8e91268979 #2110 Part2 - addBatch() does not auto flush (#2115) 2020-11-25 22:18:05 +13:00
rob bygrave cc637d56e1 Tidy tests only TestInsertSqlLogging and TestSqlUpdateExceptions 2020-11-25 21:11:16 +13:00
Rob BygraveandGitHub 9846ebd65d Merge pull request #2112 from ebean-orm/FOCONIS-bug-ebean/sql_update_batch_flush
2110 - Fix and test for executeBatch() on SqlUpdate
2020-11-25 20:40:02 +13:00
rob bygrave b568e2efc7 #2114 - Fix PreparedStatement leak when findEach() with invalid SQL 2020-11-25 20:19:20 +13:00
rob bygrave 20fc74219a #2089 - Postgres - Use NO KEY with FOR UPDATE clauses with Postgres
Rename PlatformConfig.defaultLockWithKey to PlatformConfig.forUpdateNoKey
2020-11-24 23:58:58 +13:00
Rob BygraveandGitHub 92a4bfb38e Merge pull request #2113 from ebean-orm/feature/QueryLockType
Add support for Postgres lock types (no key, share, key share) with FOR UPDATE
2020-11-24 23:48:55 +13:00
rob bygrave 5c34b0daa5 Add support for Postgres lock types (no key, share, key share) with FOR UPDATE 2020-11-24 23:36:54 +13:00
rob bygrave f4ea674d60 #2108 - ebean-k8scache and ebean-cluster not invalidated when only remoteTableMod or remoteCacheEvent 2020-11-24 22:16:14 +13:00
Rob BygraveandGitHub 21f43dc395 Merge pull request #2107 from ebean-orm/feature/ModifyAwareType
Refactor io.ebeaninternal.json.ModifyAwareOwner to io.ebean.ModifyAwareType
2020-11-24 22:05:04 +13:00
rob bygrave 5082ce4280 #2089 Postgres - Support NO KEY option with FOR UPDATE clauses with Postgres 2020-11-24 22:02:06 +13:00
Rob BygraveandGitHub ed061fb3b1 Merge pull request #2090 from ebean-orm/feature/2089
#2089 - Postgres - Use NO KEY with FOR UPDATE clauses with Postgres
2020-11-24 21:49:28 +13:00
rob bygrave 247e96f5db #2110 - Fix for executeBatch() on SqlUpdate + refactor
- Changes to generally not close BatchedPstmt on executeBatch() and instead closed on commit/rollback
2020-11-24 16:40:10 +13:00
Jonas Pöhler (JPo) ce60eac583 ADD: failing testcases for executeBatch() on SqlUpdate
Signed-off-by: Jonas Pöhler (JPo) <jonas.poehler@foconis.de>
2020-11-20 15:56:08 +01:00
rob bygrave c34fcdf7b7 #2089 - Add PlatformConfig.lockWithKey configuration option for - Postgres - Use NO KEY with FOR UPDATE clauses 2020-11-19 22:47:15 +13:00
rob bygrave dcfada0b52 Refactor io.ebeaninternal.json.ModifyAwareOwner to io.ebean.ModifyAwareType
- Rename ModifyAwareOwner to ModifyAwareType
- Move to io.ebean (making it properly public)
- Remove the requirement for Serializable
- Simplify to effectively a getter/setter pair (dirty state flag)
- Simplify to reset the dirty state flag via
2020-11-19 21:50:29 +13:00
Rob BygraveandGitHub fb3fd439bb Merge pull request #2106 from ebean-orm/feature/2105-ebean-core-type
Refactor extract ebean-core-type module moving ScalarType and related interfaces to io.ebean.core.type
2020-11-19 19:56:09 +13:00
rob bygrave 6226672d27 Fix kotlin-querybean-generator version in test 2020-11-19 17:28:44 +13:00
rob bygrave bf72794a4c #2105 - Fix kotlin-querybean-generator version in test 2020-11-19 17:27:53 +13:00
rob bygrave 30a00cb092 #2105 - Refactor extract ebean-core-type module
- Move ScalarType, DataBinder, DataReader, ExtraTypeFactory to ebean-core-type module
- Update the ebean-postgis and other modules
2020-11-19 16:10:00 +13:00
rob bygrave 0bfb6895ad #2105 - Refactor extract interface DataBinder from DataBind 2020-11-19 14:52:19 +13:00
rob bygrave 29345c823e Bump test dependency on ebean-ddl-generator 2020-11-19 09:53:19 +13:00
rob bygrave e71cb4f2ff [maven-release-plugin] prepare for next development iteration 2020-11-19 09:29:27 +13:00
rob bygrave 108a1c7181 [maven-release-plugin] prepare release ebean-parent-12.6.0 2020-11-19 09:29:16 +13:00
rob bygrave 5ce07afed8 Bump ebean-agent version in BOM 2020-11-19 09:23:55 +13:00
rob bygrave d9c4798d4e Bump ebean-test-docker dependency with io.ebean groupId 2020-11-19 09:15:02 +13:00
rob bygrave 6ecd849499 #2104 - Refactor rename ebean-ddlgen module to ebean-ddl-generator 2020-11-18 22:28:33 +13:00
rob bygrave e5b0b31da6 Improve javadoc for DbMigration for pending drops 2020-11-18 22:20:18 +13:00
rob bygrave 1371cb4ff6 #2103 - Bump dependency avaje-config to 1.2 - no effective change, added JPMS Java module support 2020-11-18 22:13:10 +13:00
rob bygrave c788d339fe #2102 - Add to BOM entries for ebean-ddl-runner, ebean-datasource, ebean-migration, ebean-test-docker 2020-11-18 22:09:54 +13:00
rob bygrave 35580fa62b #2101 - Refactor to make ebean-migration optional dependency 2020-11-18 21:52:32 +13:00
rob bygrave b61ae74d3d Tidy only - organise imports in ebean-api 2020-11-17 19:20:28 +13:00
rob bygrave fead4350ce Tidy remove unused imports 2020-11-17 19:15:10 +13:00
rob bygrave 04a651c40d #2100 - Refactor move io.ebean.dbmigration.DbMigration [generation] from ebean-api to ebean-ddlgen module 2020-11-12 22:54:36 +13:00
rob bygrave f394e7f39b #2099 - Refactor internals introduce use of ebean-ddl-runner 2020-11-12 22:42:00 +13:00
rob bygrave 8f7827d3d9 No effective change - bump provided dependency slf4j-api to 1.7.30 2020-11-12 21:19:05 +13:00
rob bygrave 06b54bd824 No effective change - tidy test properties 2020-11-12 14:51:16 +13:00
rob bygrave f473e40bfc #2098 - Refactor simplify SequenceIdGenerator.loadInBackground() to use AtomicBoolean 2020-11-12 13:58:16 +13:00
rob bygrave 1eb5cf1d22 Fix test TransactionManagerTest - close leaked connection
Connection properties to help find leaks are capturestacktrace and maxStackTraceSize, e.g.

datasource.h2.capturestacktrace=true
datasource.h2.maxStackTraceSize=20
2020-11-12 13:55:10 +13:00
rob bygrave b540d70b2d #2097 - Split ebean-datasource dependency to ebean-datasource-api and ebean-datasource 2020-11-12 12:53:32 +13:00
rob bygrave 7b5a8aef73 Bump parent to java8-oss 2.3 with autoReleaseAfterClose false 2020-11-12 12:20:42 +13:00
rob bygrave 3e4daf6947 Revert/Post deploy of ebean-querybean 12.5.2 2020-11-12 12:11:23 +13:00
rob bygrave 0918cbf221 Prepare deploy of ebean-querybean 12.5.2 2020-11-12 11:28:17 +13:00
rob bygrave 3e078e41ff [maven-release-plugin] prepare for next development iteration 2020-11-11 22:47:24 +13:00
rob bygrave a80ab94479 [maven-release-plugin] prepare release ebean-parent-12.5.2 2020-11-11 22:47:12 +13:00
rob bygrave e6f0ab90dc #2094 - Refactor remove isJavaTimePresent() ... we are Java 8+ so removing effectively redundant code 2020-10-23 01:25:28 +13:00
rob bygrave 53f4739c8f #2093 - Refactor remove isJava7Present() ... we are Java 8+ so Java 7 types are always present - Removing effectively redundant code 2020-10-23 01:21:48 +13:00
rob bygrave c6e33ba3ac Modify pom names of modules for more consistency 2020-10-23 00:33:16 +13:00
rob bygrave 0e2528e542 #2092 - Add support for mocking Database interface to MockiEbean 2020-10-23 00:10:50 +13:00
rob bygrave 6ecc10a35c #2091 - Using Postgis types with query gives PersistenceException Caused by: java.sql.SQLException: Unhandled data type [6000] bind number[0] 2020-10-22 22:48:53 +13:00
rob bygrave 59bd2bb251 Add ebean-postgis module 2020-10-22 21:22:41 +13:00
rob bygrave 9fa83cdd5a Move into ebean-postgres sub directory 2020-10-22 21:18:18 +13:00
Rob BygraveandGitHub f383f3f759 Merge pull request #3 from tobias-/failing_test
Failing tests for query with postgis types
2020-10-22 20:56:22 +13:00
rob bygrave c044bc52f7 #2089 - Postgres - Use NO KEY with FOR UPDATE clauses with Postgres 2020-10-22 16:37:18 +13:00
rob bygrave 0abcc9e06e #2085 - Refactor promote getDataSource() and getReadOnlyDataSource() to Database from plugin.SpiServer interface 2020-10-20 12:08:21 +13:00
rob bygrave 4a594b32ef Refactor modify SpiServer to extend Database (rather than EbeanServer) 2020-10-20 11:36:01 +13:00
rob bygrave 8b9f760cb2 Update tests for DatabaseFactory.create() with shutdown 2020-10-19 12:12:00 +13:00
rob bygrave 1d1cf76b5e Update poms adding name, description, change to use explicit snapshot version rather than project.version 2020-10-19 11:21:18 +13:00
rob bygrave 194c14b99a Post manual release of autotune, externalmapping-xml, querybean and test modules 2020-10-19 10:16:25 +13:00
rob bygrave fa8c6839dd [maven-release-plugin] prepare for next development iteration 2020-10-19 09:44:18 +13:00
rob bygrave f8e4ce6b4c [maven-release-plugin] prepare release ebean-test-12.5.1 2020-10-19 09:44:07 +13:00
rob bygrave cce496016d [maven-release-plugin] prepare for next development iteration 2020-10-19 09:38:53 +13:00
rob bygrave 2c4d5dc304 [maven-release-plugin] prepare release ebean-querybean-12.5.1 2020-10-19 09:38:42 +13:00
rob bygrave 1c981130b6 [maven-release-plugin] prepare for next development iteration 2020-10-19 09:34:13 +13:00
rob bygrave c18d1fa288 [maven-release-plugin] prepare release ebean-externalmapping-xml-12.5.1 2020-10-19 09:34:01 +13:00
rob bygrave 5287d93a58 [maven-release-plugin] prepare for next development iteration 2020-10-19 09:30:52 +13:00
rob bygrave 6e6055fb84 [maven-release-plugin] prepare release ebean-autotune-12.5.1 2020-10-19 09:30:40 +13:00
rob bygrave c2ea8b3d56 Prepare manual release of autotune, externalmapping-xml, querybean and test modules 2020-10-19 09:29:54 +13:00
rob bygrave 5885d724c4 Prepare manual release of autotune, externalmapping-xml, querybean and test modules 2020-10-19 09:27:58 +13:00
rob bygrave 90d028640d No effective change - bump maven tiles plugin to 2.18 2020-10-16 18:11:01 +13:00
rob bygrave b8d92f1846 [maven-release-plugin] prepare for next development iteration 2020-10-16 16:08:33 +13:00
rob bygrave e41d2eed7f [maven-release-plugin] prepare release ebean-parent-12.5.1 2020-10-16 16:08:22 +13:00
rob bygrave 8c7a84be9c No effective change - tidy tests that create unregistered Database instances (shutdown) 2020-10-16 16:04:52 +13:00
rob bygrave 63116f25ec Bump ebean-datasource to 6.1 2020-10-16 15:39:29 +13:00
rob bygrave eac05571c8 Update tests for kotlin-querybean-generator to use junit5 2020-10-16 15:38:52 +13:00
rob bygrave a6ad043142 #2082 - Test scope for kotlin-querybean-generator ebean-querybean dependency 2020-10-16 12:23:59 +13:00
SnōwballandGitHub bcc8040afe Scalar type querybeans generics error (#2082)
* Add failing test case for generic querybeans

Types with generics arguments have not been processed correctly, they
will lose their generics. This is not critical in Java, as the language
has to be backwards compatible with Java 1.4, but will still become
highlighted as a warning in all common IDEs.

In Kotlin however, it's not a warning but a compile error.

* Fix problem with generics in scalar type arg

This fixes the issue introduced with ScalarType aware querybeans.
2020-10-16 09:57:32 +13:00
rob bygrave ee73fd47d5 No effective change - tidy javadoc 2020-10-16 00:53:55 +13:00
rob bygrave 064b3ceaa4 #2080 - Refactor convert from sychronized to ReentrantLock
DatabaseFactory, DbPrimary, ScalarTypeArrayList etc
2020-10-16 00:46:13 +13:00
rob bygrave 54ada6e07b #2080 - ebean-autotune - Refactor convert from sychronized to ReentrantLock 2020-10-16 00:28:23 +13:00
Rob BygraveandGitHub 14181932ec Refactor synchronized to ReentrantLock (#2081) 2020-10-16 00:20:42 +13:00
rob bygrave 0faa6a8efd Reset back pom after manual release of ebean-autotune 2020-10-16 00:16:21 +13:00
rob bygrave f94eb9b75e [maven-release-plugin] prepare for next development iteration 2020-10-16 00:03:55 +13:00
rob bygrave 817436b00d [maven-release-plugin] prepare release ebean-autotune-12.5.0 2020-10-16 00:03:42 +13:00
rob bygrave a089a36f9d Prepare manual release of ebean-autotune 2020-10-16 00:03:07 +13:00
rob bygrave 1f1868fdd3 #2079 - Refactor to make Jackson core an optional dependency 2020-10-15 22:04:36 +13:00
rob bygrave 8ac49e537d #2078 - Bump to avaje-config 1.1 - makes snakeyaml dependency optional 2020-10-15 16:51:48 +13:00
Tobias 1e44b81e87 Failing tests for the rest of the gis-types
Simple query tests for:
* Polygon
* LineString
* MultiPoint
* MultiPolygon
* MultiLineString
2020-10-13 15:29:18 +02:00
rob bygrave 133cf95c6d Reset poms for externalmapping-xml querybean and ebean-test modules after manual release take 2 2020-10-14 00:00:17 +13:00
rob bygrave 2caf4bcccd [maven-release-plugin] prepare for next development iteration 2020-10-13 23:29:19 +13:00
rob bygrave e8f0e2f4bf [maven-release-plugin] prepare release ebean-test-12.5.0 2020-10-13 23:29:05 +13:00
rob bygrave 8bde42fb16 [maven-release-plugin] prepare for next development iteration 2020-10-13 23:25:06 +13:00
rob bygrave 2bb1e40c44 [maven-release-plugin] prepare release ebean-querybean-12.5.0 2020-10-13 23:24:52 +13:00
rob bygrave 1ac1e19db0 Manually release ebean-test and ebean-querybean module 12.5.0 by itself
Take 2 with correct groupId
2020-10-13 23:23:58 +13:00
rob bygrave 85a0eb0afb [maven-release-plugin] prepare for next development iteration 2020-10-13 23:16:42 +13:00
rob bygrave a6470b48ff [maven-release-plugin] prepare release ebean-externalmapping-xml-12.5.0 2020-10-13 23:16:30 +13:00
rob bygrave ebde00a137 Manually release ebean-externalmapping-xml module 12.5.0 by itself
Take 2 with correct groupId
2020-10-13 23:16:07 +13:00
rob bygrave bb6425a0c1 Manually release ebean-externalmapping-xml module 12.5.0 by itself
Take 2 with correct groupId
2020-10-13 23:15:00 +13:00
rob bygrave abff32c418 Manually release ebean-externalmapping-xml module 12.5.0 by itself
Take 2 with correct groupId
2020-10-13 23:13:58 +13:00
75f26b1f62 Bump junit from 4.12 to 4.13.1 in /ebean-test (#2077)
Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.1.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.12.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-13 11:51:36 +13:00
rob bygrave fc4ee15a2a Reset poms for externalmapping-xml querybean and ebean-test modules after manual release 2020-10-13 11:45:46 +13:00
rob bygrave 6cb21f3e73 [maven-release-plugin] prepare for next development iteration 2020-10-13 11:17:39 +13:00
rob bygrave 18663c8983 [maven-release-plugin] prepare release ebean-externalmapping-xml-12.5.0 2020-10-13 11:17:27 +13:00
rob bygrave 0d9094984a Manually release ebean-externalmapping-xml module 12.5.0 by itself 2020-10-13 11:16:52 +13:00
rob bygrave bd05f2c2ba [maven-release-plugin] prepare for next development iteration 2020-10-13 11:09:06 +13:00
rob bygrave 1cc167341b [maven-release-plugin] prepare release ebean-test-12.5.0 2020-10-13 11:08:54 +13:00
rob bygrave 4a313245b5 Manually release ebean-test module 12.5.0 by itself 2020-10-13 11:08:21 +13:00
rob bygrave 8744435eb6 [maven-release-plugin] prepare for next development iteration 2020-10-13 11:04:13 +13:00
rob bygrave dfdcdcf321 [maven-release-plugin] prepare release ebean-querybean-12.5.0 2020-10-13 11:04:02 +13:00
rob bygrave e203d4d191 Try to release ebean-querybean module 12.5.0 by itself 2020-10-13 11:03:18 +13:00
rob bygrave d4c345b989 Try to release ebean-querybean module 12.5.0 by itself
For some unknown reason this module is missing from central after the release.
2020-10-13 11:01:16 +13:00
Tobias 85b21a02e8 Failing testcase for ebean query serializer 2020-10-12 13:23:49 +02:00
rob bygrave 541271efb7 Bump tiles etc to newly released 12.5.0 2020-10-12 23:42:08 +13:00
Tobias 4313fb6f58 Add .editorconfig 2020-10-12 11:51:44 +02:00
rob bygrave 489781f89d [maven-release-plugin] prepare for next development iteration 2020-10-12 22:35:21 +13:00
rob bygrave 9180289551 [maven-release-plugin] prepare release ebean-parent-12.5.0 2020-10-12 22:35:09 +13:00
rob bygrave b15958e766 Bump to 12.5.0-SNAPSHOT 2020-10-12 17:33:30 +13:00
rob bygrave 49c64c1eb5 Add Automatic-Module-Name entries MANIFEST.MF 2020-10-12 16:45:57 +13:00
rob bygrave a53168bd00 Add Automatic-Module-Name entries MANIFEST.MF 2020-10-12 16:21:29 +13:00
rob bygrave c783f26340 #2076 - Remove JAXB as dependency of ebean-api
- Move JAXB detection to ebean-ddlgen
- JAXB as test dependency of ebean-core
2020-10-12 16:10:07 +13:00
rob bygrave 050a3e2368 #2076 - Refactor DbDefaultValue internals - remove dependency on javax.xml.bind.DatatypeConverter for verify of value 2020-10-12 15:37:39 +13:00
rob bygrave 49b1bd54c3 #2075 - Refactor external mapping (i.e. named queries from ebean.xml etc) - extract api and separate module 2020-10-12 14:54:25 +13:00
rob bygrave f57db28f1c #2075 - Refactor external mapping api and use ServiceLoader 2020-10-10 17:12:13 +13:00
rob bygrave b22bffe770 #2074 - Refactor extract ebean-ddlgen module. In future this module would expected to be a test only dependency 2020-10-10 12:28:02 +13:00
rob bygrave b9047bf280 #2073 - Refactor internals for DdlGenerator use use ServiceLoader 2020-10-09 22:58:47 +13:00
rob bygrave a6f5ab8074 Refactor internals - move DbOffline, split VisitAllUsing into VisitProperties 2020-10-09 18:02:40 +13:00
rob bygrave 60becb6346 #2072 - Extract ebean-api module - NB: this includes moving ShutdownManager and small adjustment to DocStore/Elastic SPI 2020-10-09 17:12:27 +13:00
rob bygrave 11839aca5e Refactor to ServiceLoad MetricFactory implementation 2020-10-09 14:17:21 +13:00
rob bygrave 86aed458dd Move ShutdownManager into io.ebean.event 2020-10-09 14:13:52 +13:00
rob bygrave fa4130ba8e Fix travis testing for ebean-querybean module 2020-10-09 10:29:35 +13:00
rob bygrave 77995fda0a #2065 - Fix missed tests for - Refactor SQL generation - remove excess whitespace 2020-10-09 10:17:23 +13:00
rob bygrave 5112253d19 Fix for travis build of ebean-test module 2020-10-09 10:04:15 +13:00
rob bygrave 89c3e23410 Fix for travis build of ebean-autotune module tests 2020-10-09 09:50:43 +13:00
rob bygrave b8858d91f0 Modify Autotune module tests with surefire output
Also add to ebean-bom
2020-10-09 09:37:26 +13:00
rob bygrave 46a42f4ef7 Modify Autotune tests use an explicit datasource 2020-10-09 09:13:33 +13:00
rob bygrave 42f9c8fd59 Modify Autotune tests use an explicit datasource 2020-10-09 08:47:08 +13:00
rob bygrave 6560a46b2d Drop version of maven plugin due to travis cache 2020-10-09 01:01:45 +13:00
rob bygrave 4da86481e8 #2071 - Add ebean-bom module 2020-10-09 00:40:24 +13:00
rob bygrave bde133ef79 #2070 - Add top level ebean module 2020-10-09 00:31:19 +13:00
rob bygrave 8780ac0902 #2070 - Rename ebean module to ebean-core, add top level ebean module 2020-10-09 00:26:37 +13:00
rob bygrave 038db79737 #2069 - Add ebean-querybean, querybean-generator and kotlin-querybean-generator as modules 2020-10-09 00:02:09 +13:00
rob bygrave bc055fea25 #2068 - Add ebean-test as module 2020-10-08 23:48:19 +13:00
rob bygrave ab283efed7 Use ebean-parent and inherit version 2020-10-08 23:46:36 +13:00
rob bygrave d113ddc525 #2067 - Extract ebean-autotune into separate module 2020-10-08 23:34:56 +13:00
Rob BygraveandGitHub 7c36439daf Refactor move into ebean-core directory (#2066) 2020-10-08 21:31:18 +13:00
rob bygrave 7193b035b2 #2062 - Update enhancement agent to use ASM 9 2020-10-08 17:23:16 +13:00
Rob BygraveandGitHub de22b7bf27 Refactor SQL generation - remove excess whitespace (double spaces before where, join and order by) (#2065) 2020-10-07 21:28:33 +13:00
rob bygrave 694518db0a [maven-release-plugin] prepare for next development iteration 2020-10-07 20:43:11 +13:00
rob bygrave b721017dd5 [maven-release-plugin] prepare release ebean-12.4.2 2020-10-07 20:42:59 +13:00
rob bygrave de5346437f Bump maven plugin 2020-10-07 20:39:53 +13:00
rob bygrave 1669649706 #2064 - Generated sql is missing a space near to the "dtype and softdelete" join-conditions when "fetch join" is used 2020-10-07 17:12:51 +13:00
rob bygrave 3f816c49c9 #2063 - Updating bean - L2 Bean cache update + l2 cache update on "Many Ids" when they have not change - can lead to race 2020-10-07 15:26:31 +13:00
rob bygrave e31ae49bc5 #2063 - Failing test for - Updating bean - L2 Bean cache update + l2 cache update on "Many Ids" when they have not change - can lead to race 2020-10-07 15:12:13 +13:00
rob bygrave bdf8381518 Update test only - TestAttributeConverter 2020-10-07 14:16:55 +13:00
rob bygrave 7eb185ce9b Refactor remove message.properties resource in favour of simple error messages and logs 2020-09-24 23:40:05 +12:00
rob bygrave f175b198e6 Merge branch 'FOCONIS-test_beancache_wrong_result' 2020-09-24 22:15:09 +12:00
rob bygrave de734665cd #2061 - Fix for L2 bean cache loaded using lazy loading on mutated partially loaded bean
The fix is when the property is dirty (mutated) put the original value into the cache entry.
2020-09-24 22:14:48 +12:00
Jonas Pöhler (JPo) c5eb6fa034 ADD: failing testcase for wrong bean caching
Signed-off-by: Jonas Pöhler (JPo) <jonas.poehler@foconis.de>
2020-09-23 15:19:59 +02:00
rob bygrave ee19fd17fa [maven-release-plugin] prepare for next development iteration 2020-09-18 01:22:40 +12:00
rob bygrave a7c6f9835a [maven-release-plugin] prepare release ebean-postgis-12.4.1 2020-09-18 01:22:29 +12:00
rob bygrave 06b1babed9 Bump to 12.4.1 2020-09-18 01:21:50 +12:00
rob bygrave 5706c73272 [maven-release-plugin] prepare for next development iteration 2020-09-17 23:59:24 +12:00
rob bygrave c5a899c0e8 [maven-release-plugin] prepare release ebean-12.4.1 2020-09-17 23:59:12 +12:00
rob bygrave 50eb7d78fb Bump to 12.4.1-SNAPSHOT 2020-09-17 23:46:46 +12:00
rob bygrave 13e805b31c No effective change - organise imports on generated EQLLexer and EQLParser 2020-09-17 23:03:56 +12:00
rob bygrave 3531db0e53 #2060 - Bump ANTLR to 4.8-1 (from 4.7.2) and add support for "leOrNull" and "geOrNull" expressions from #2059 2020-09-17 23:01:09 +12:00
rob bygrave 87243a871d No effective change - tidy OrmQueryRequest 2020-09-17 22:46:22 +12:00
rob bygrave f2159fed71 #2058 - .findVersionsBetween() for PG and MySql... should use inclusive/exclusive and it is instead is exclusive/exclusive 2020-09-17 22:38:42 +12:00
rob bygrave 740fd63f35 #2059 - ENH: Add convenience expressions leOrNull() and geOrNull() ... [ property >= value or property is null ] 2020-09-17 22:23:54 +12:00
rob bygrave 2ad99794ea No effective change - tidy whitespace 2020-09-14 21:05:38 +12:00
rob bygrave 775f184450 No effective change - tidy whitespace from SaveManyBeans and BeanPropertyAssocMany 2020-09-14 20:57:21 +12:00
rob bygrave 4492a87a3f No effective change - tidy DefaultTypeFactory 2020-09-14 20:39:22 +12:00
rob bygrave 18d5d01d48 #2049 - Tidy after ServerConfig -> DatabaseConfig 2020-09-14 20:35:20 +12:00
Rob BygraveandGitHub 90b1b88be6 Update CsvCallback API to use Database instead of EbeanServer (#2010)
* Update CsvCallback API to use Database instead of EbeanServer
2020-09-14 18:33:12 +12:00
Rob BygraveandGitHub 6839f869f5 #2049 - Migrate to DatabaseConfig from ServerConfig (#2057) 2020-09-14 18:30:51 +12:00
rob bygrave 488762957a [maven-release-plugin] prepare for next development iteration 2020-09-08 13:28:26 +12:00
rob bygrave ec016cab17 [maven-release-plugin] prepare release ebean-12.3.9 2020-09-08 13:28:15 +12:00
rob bygrave 7c28f01923 Bump parent pom 2020-09-08 13:26:37 +12:00
Rob BygraveandGitHub 54da22eee6 Merge pull request #2056 from ebean-orm/feature/DbContext
#2055 - Refactor internals - Extract DbContext from Ebean and hold Database rather than EbeanServer
2020-09-08 09:33:10 +12:00
rob bygrave 6772b6e87e #2055 - Refactor internals - Extract DbContext from Ebean and hold Database rather than EbeanServer 2020-09-08 09:29:06 +12:00
rob bygrave 9856ebd540 #2055 - Refactor internals - Extract DbContext from Ebean and hold Database rather than EbeanServer 2020-09-08 09:25:32 +12:00
rob bygrave f96ac6e6fe No effective change - tidy Ebean, EbeanVersion 2020-09-07 21:55:21 +12:00
rob bygrave 4c5618b04b #2054 - Invalid SQL with History findVersions() on bean with @EmbeddedId - ... ORDER BY T0.NULL[*] ... 2020-09-07 18:25:25 +12:00
rob bygrave a77de9e5e6 No effective change - trim whitespace for IdBinderEmbedded 2020-09-07 18:00:12 +12:00
rob bygrave da29330a2a #2053 - Refactor tidy StringHelper.replace replacing with just String.replace where possible 2020-09-04 18:04:10 +12:00
rob bygrave d0f9d4a9a6 #2053 - Refactor tidy StringHelper.replaceString 2020-09-04 17:42:09 +12:00
rob bygrave 61ee67ee41 #2053 - Refactor tidy StringHelper.replaceString 2020-09-04 17:36:10 +12:00
rob bygrave 3117acd2d7 #2053 - Refactor tidy StringHelper.delimitedToMap 2020-09-04 13:37:25 +12:00
rob bygrave 4cee41d8d6 #2053 - Refactor tidy StringHelper - replace replaceStringMulti() with removeNewLines() 2020-09-04 13:21:13 +12:00
rob bygrave f4a58938bd #2053 - Refactor tidy StringHelper - just tidy 2020-09-04 13:09:55 +12:00
rob bygrave 4ce84f694f #2053 - Refactor tidy internals - Clean up StringHelper 2020-09-04 13:04:14 +12:00
rob bygrave 8eb248b966 #2052 - Refactor tidy internals - Use String.replace() rather than literal pattern replaceAll() 2020-09-04 12:53:43 +12:00
rob bygrave c294d8e568 #2051 - Bump config dependency from io.avaje:config to io.avaje:avaje-config 2020-09-03 17:18:14 +12:00
rob bygrave e923316ce9 Change to use maven <optional>true</optional> rather than scope provided 2020-09-03 17:13:23 +12:00
rob bygrave f611068a03 #2050 - Refactor internals - remove dependency on java.beans 2020-09-03 14:45:27 +12:00
rob bygrave dd880ac09b #2044 - Using @AttributeOverrides when override nullable 2020-08-31 14:38:23 +12:00
rob bygrave dbe24a4041 [maven-release-plugin] prepare for next development iteration 2020-08-26 11:37:29 +12:00
rob bygrave 73ea91d4c9 [maven-release-plugin] prepare for next development iteration 2020-03-13 11:23:01 +13:00
rob bygrave 14839f0c0f [maven-release-plugin] prepare release ebean-postgis-12.2.1 2020-03-13 11:22:51 +13:00
rob bygrave db8f4e141d Bump to 12.2.1 2020-03-13 11:22:22 +13:00
rob bygrave 09fa406f84 [maven-release-plugin] prepare for next development iteration 2019-10-14 15:18:46 +13:00
rob bygrave 50d22ba357 [maven-release-plugin] prepare release ebean-postgis-12.1.1 2019-10-14 15:18:37 +13:00
rob bygrave c6f9d193be Bump to sync to Ebean 12.1.1 2019-10-14 15:18:01 +13:00
rob bygrave 5e1aa47c05 No effective change - update application-test.yml with dbSchema and ddlMode 2018-08-02 12:10:48 +12:00
rob bygrave 21dd8cee37 [maven-release-plugin] prepare for next development iteration 2018-08-02 11:51:10 +12:00
rob bygrave ece82996c2 [maven-release-plugin] prepare release ebean-postgis-11.1.1 2018-08-02 11:50:57 +12:00
rob bygrave fa520c95ea Bump to 11.1.1-SNAPSHOT 2018-08-02 11:50:25 +12:00
rob bygrave a6685141a4 #2 - No effective change - for running tests update to use docker postgis and application-test.yml 2018-08-02 11:48:49 +12:00
rob bygrave 78ab0ad923 No effective change - test logging config update 2018-08-02 11:44:25 +12:00
rob bygrave 4fb67a4c8c #1 - Support Ebean 11.x API - due to Ebean #1153 - Refactor move ExtraTypeFactory out of io.ebean.plugin into io.ebeaninternal 2018-08-02 11:43:52 +12:00
Rob Bygrave dd94e60d16 [maven-release-plugin] prepare for next development iteration 2016-12-13 21:59:31 +13:00
Rob Bygrave aa70e17657 [maven-release-plugin] prepare release ebean-postgis-0.1.3 2016-12-13 21:59:22 +13:00
Rob Bygrave 016cd3fb71 Update for Ebean 10.1.1 2016-12-13 21:58:56 +13:00
Rob Bygrave 17f28ba0aa [maven-release-plugin] prepare for next development iteration 2016-12-01 01:11:15 +13:00
Rob Bygrave ab88a879e9 [maven-release-plugin] prepare release ebean-postgis-0.1.2 2016-12-01 01:11:05 +13:00
Rob Bygrave 5b85f3c8dd Bump to java8 parent, update scm to ssh 2016-12-01 01:10:28 +13:00
Rob Bygrave 16a5100f35 Modify ScalarTypePgisBase to support the older protocol / objects when reading 2016-12-01 01:07:55 +13:00
Rob Bygrave 86b2c5d5b5 [maven-release-plugin] prepare for next development iteration 2016-10-25 22:53:16 +13:00
Rob Bygrave e0c3198ee6 [maven-release-plugin] prepare release ebean-postgis-0.1.1 2016-10-25 22:53:08 +13:00
Rob Bygrave 12bdd847b5 Update pom for initial release 2016-10-25 22:42:17 +13:00
Rob Bygrave 9860816ab7 Update 2016-10-25 22:36:38 +13:00
Rob Bygrave e17283726a Initial add 2016-10-21 02:37:13 +13:00
Rob Bygrave eff61ae5fc Initial commit 2016-10-21 01:32:47 +13:00
3760 changed files with 39842 additions and 10059 deletions
+1 -4
View File
@@ -1,6 +1,4 @@
*.autofetch
*create-all.sql
*drop-all.sql
*.orig
.classpath
.project
@@ -12,7 +10,6 @@ ebean-autotune.xml
ebean-profiling*.xml
/db
/mydb.db
!src/test/ddl-review/*.sql
profiling/
# Intellij project files
@@ -20,4 +17,4 @@ profiling/
*.ipr
*.iws
.idea/
*uuid.state
*uuid.state
+8 -1
View File
@@ -7,4 +7,11 @@ do
echo ${file}
cat ${file}
echo
done
done
for file in ebean-autotune/target/surefire-reports/*.txt
do
echo ${file}
cat ${file}
echo
done
+1 -1
View File
@@ -293,6 +293,6 @@ ebean.tenant.schemaProvider
ebean.updateAllPropertiesInBatch
ebean.updateChangesOnly
ebean.updatesDeleteMissingChildren
ebean.useJavaxValidationNotNull
ebean.useValidationNotNull
ebean.useJtaTransactionManager
+124
View File
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.7.2</version>
</parent>
<name>ebean api</name>
<description>ebean api</description>
<artifactId>ebean-api</artifactId>
<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.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-config</artifactId>
<version>1.3</version>
</dependency>
<!--
Class retention Nonnull and Nullable annotations
to assist with IDE auto-completion with Ebean API
-->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsr305</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>persistence-api</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-annotation</artifactId>
<version>6.15</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-types</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource-api</artifactId>
<version>${ebean-datasource.version}</version>
</dependency>
<!-- Jackson core used internally by Ebean -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
<!-- provided scope for JsonNode support -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
<!-- Provided scope so that the H2HistoryTrigger can live in Ebean core
and not require a separate module for it -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.199</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,109 @@
package io.ebean;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
/**
* Background executor service for executing of tasks asynchronously.
* <p>
* This service can be used to execute tasks in the background.
* <p>
* This service is managed by Ebean and will perform a clean shutdown
* waiting for background tasks to complete with a default 30 second
* timeout. Shutdown occurs prior to DataSource shutdown.
* <p>
* This also propagates MDC context from the current thread to the
* background task if defined.
*/
public interface BackgroundExecutor {
/**
* Execute a callable task in the background returning the Future.
*/
<T> Future<T> submit(Callable<T> task);
/**
* Execute a runnable task in the background returning the Future.
*/
Future<?> submit(Runnable task);
/**
* Execute a task in the background. Effectively the same as
* {@link BackgroundExecutor#submit(Runnable)} but returns void.
*/
void execute(Runnable task);
/**
* Deprecated - migrate to scheduleWithFixedDelay().
* Execute a task periodically with a fixed delay between each execution.
* <p>
* For example, execute a runnable every minute.
* <p>
* The delay is the time between executions no matter how long the task took.
* That is, this method has the same behaviour characteristics as
* {@link ScheduledExecutorService#scheduleWithFixedDelay(Runnable, long, long, TimeUnit)}
*/
@Deprecated
void executePeriodically(Runnable task, long delay, TimeUnit unit);
/**
* Deprecated - migrate to scheduleWithFixedDelay().
* Execute a task periodically additionally with an initial delay different from delay.
*/
@Deprecated
void executePeriodically(Runnable task, long initialDelay, long delay, TimeUnit unit);
/**
* Execute a task periodically with a given delay.
*
* @param task the task to execute
* @param initialDelay the time to delay first execution
* @param delay the delay between the termination of one
* execution and the commencement of the next
* @param unit the time unit of the initialDelay and delay parameters
* @return a ScheduledFuture representing pending completion of
* the series of repeated tasks. The future's {@link
* Future#get() get()} method will never return normally,
* and will throw an exception upon task cancellation or
* abnormal termination of a task execution.
*/
ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit);
/**
* Execute a task periodically with a given period.
*
* <p>If any execution of this task takes longer than its period, then
* subsequent executions may start late, but will not concurrently
* execute.
*
* @param task the task to execute
* @param initialDelay the time to delay first execution
* @param period the period between successive executions
* @param unit the time unit of the initialDelay and period parameters
* @return a ScheduledFuture representing pending completion of
* the series of repeated tasks. The future's {@link
* Future#get() get()} method will never return normally,
* and will throw an exception upon task cancellation or
* abnormal termination of a task execution.
*/
ScheduledFuture<?> scheduleAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit);
/**
* Schedules a Runnable for one-shot action that becomes enabled after the given delay.
*
* @return a ScheduledFuture representing pending completion of the task and
* whose get() method will return null upon completion
*/
ScheduledFuture<?> schedule(Runnable task, long delay, TimeUnit unit);
/**
* Schedules a Callable for one-shot action that becomes enabled after the given delay.
*
* @return a ScheduledFuture that can be used to extract result or cancel
*/
<V> ScheduledFuture<V> schedule(Callable<V> task, long delay, TimeUnit unit);
}
@@ -14,7 +14,7 @@ import java.util.Optional;
*
* public class CustomerFinder extends BeanFinder<Long,Customer> {
*
* Inject
* @Inject
* public CustomerFinder(Database database) {
* super(Customer.class, database);
* }
@@ -9,10 +9,10 @@ import java.util.Collection;
* <p>
* <pre>{@code
*
* Repository
* @Repository
* public class CustomerRepository extends BeanRepository<Long,Customer> {
*
* Inject
* @Inject
* public CustomerRepository(Database server) {
* super(Customer.class, server);
* }
@@ -60,7 +60,9 @@ import java.util.concurrent.Callable;
*
* }</pre>
*/
public class DB {
public final class DB {
private static final DbContext context = DbContext.getInstance();
/**
* Hide constructor.
@@ -68,11 +70,18 @@ public class DB {
private DB() {
}
/**
* Backdoor for registering a mock implementation of Database as the default database.
*/
protected static Database mock(String name, Database server, boolean defaultServer) {
return context.mock(name, server, defaultServer);
}
/**
* Return the default database.
*/
public static Database getDefault() {
return Ebean.getDefaultServer();
return context.getDefault();
}
/**
@@ -81,26 +90,9 @@ public class DB {
* @param name The name of the database
*/
public static Database byName(String name) {
return Ebean.getServer(name);
return context.get(name);
}
// /**
// * Register the server with this Ebean singleton. Specify if the registered
// * server is the primary/default database.
// */
// public static void register(EbeanServer server, boolean defaultServer) {
// serverMgr.register(server, defaultServer);
// }
//
// /**
// * Backdoor for registering a mock implementation of EbeanServer as the default database.
// */
// protected static EbeanServer mock(String name, EbeanServer server, boolean defaultServer) {
// EbeanServer originalPrimaryServer = serverMgr.defaultServer;
// serverMgr.registerWithName(name, server, defaultServer);
// return originalPrimaryServer;
// }
/**
* Return the ScriptRunner for the default database.
* <p>
@@ -14,6 +14,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.persistence.OptimisticLockException;
import javax.persistence.PersistenceException;
import javax.sql.DataSource;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -93,6 +94,11 @@ import java.util.concurrent.Callable;
*/
public interface Database {
/**
* Shutdown the Database instance.
*/
void shutdown();
/**
* Shutdown the Database instance programmatically.
* <p>
@@ -116,6 +122,16 @@ public interface Database {
*/
AutoTune getAutoTune();
/**
* Return the associated DataSource for this Database instance.
*/
DataSource getDataSource();
/**
* Return the associated read only DataSource for this Database instance (can be null).
*/
DataSource getReadOnlyDataSource();
/**
* Return the name. This is used with {@link DB#byName(String)} to get a
* Database that was registered with the DB singleton.
@@ -881,7 +897,7 @@ public interface Database {
* <pre>{@code
* public class Order { ...
*
* OneToMany(cascade=CascadeType.ALL, mappedBy="order")
* @OneToMany(cascade=CascadeType.ALL, mappedBy="order")
* List<OrderDetail> details;
* ...
* }
@@ -0,0 +1,157 @@
package io.ebean;
import io.ebean.config.ContainerConfig;
import io.ebean.config.DatabaseConfig;
import io.ebean.service.SpiContainer;
import io.ebean.service.SpiContainerFactory;
import javax.persistence.PersistenceException;
import java.util.Iterator;
import java.util.Properties;
import java.util.ServiceLoader;
import java.util.concurrent.locks.ReentrantLock;
/**
* Creates Database instances.
* <p>
* This uses either DatabaseConfig or properties in the application.properties file to
* configure and create a Database instance.
* </p>
* <p>
* The Database instance can either be registered with the DB singleton or
* not. The DB singleton effectively holds a map of Database by a name.
* If the Database is registered with the DB singleton you can retrieve it
* later via {@link DB#byName(String)}.
* </p>
* <p>
* One Database can be nominated as the 'default/primary' Database. Many
* methods on the DB singleton such as {@link DB#find(Class)} are just a
* convenient way of using the 'default/primary' Database.
* </p>
*/
public class DatabaseFactory {
private static final ReentrantLock lock = new ReentrantLock();
private static SpiContainer container;
static {
EbeanVersion.getVersion();
}
/**
* Initialise the container with clustering configuration.
* <p>
* Call this prior to creating any Database instances or alternatively set the
* ContainerConfig on the DatabaseConfig when creating the first Database instance.
*/
public static void initialiseContainer(ContainerConfig containerConfig) {
lock.lock();
try {
getContainer(containerConfig);
} finally {
lock.unlock();
}
}
/**
* Create using properties to configure the database.
*/
public static Database create(String name) {
lock.lock();
try {
return getContainer(null).createServer(name);
} finally {
lock.unlock();
}
}
/**
* Create using the DatabaseConfig object to configure the database.
*/
public static Database create(DatabaseConfig config) {
lock.lock();
try {
if (config.getName() == null) {
throw new PersistenceException("The name is null (it is required)");
}
Database server = createInternal(config);
if (config.isRegister()) {
DbPrimary.setSkip(true);
DbContext.getInstance().register(server, config.isDefaultServer());
}
return server;
} finally {
lock.unlock();
}
}
/**
* Create using the DatabaseConfig additionally specifying a classLoader to use as the context class loader.
*/
public static Database createWithContextClassLoader(DatabaseConfig config, ClassLoader classLoader) {
lock.lock();
try {
ClassLoader currentContextLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try {
return DatabaseFactory.create(config);
} finally {
// set the currentContextLoader back
Thread.currentThread().setContextClassLoader(currentContextLoader);
}
} finally {
lock.unlock();
}
}
/**
* Shutdown gracefully all Database instances cleaning up any resources as required.
* <p>
* This is typically invoked via JVM shutdown hook and not explicitly called.
* </p>
*/
public static void shutdown() {
lock.lock();
try {
container.shutdown();
} finally {
lock.unlock();
}
}
private static Database createInternal(DatabaseConfig config) {
return getContainer(config.getContainerConfig()).createServer(config);
}
/**
* Get the EbeanContainer initialising it if necessary.
*
* @param containerConfig the configuration controlling clustering communication
*/
private static SpiContainer getContainer(ContainerConfig containerConfig) {
// thread safe in that all calling methods hold lock
if (container != null) {
return container;
}
if (containerConfig == null) {
// effectively load configuration from ebean.properties
Properties properties = DbPrimary.getProperties();
containerConfig = new ContainerConfig();
containerConfig.loadFromProperties(properties);
}
container = createContainer(containerConfig);
return container;
}
/**
* Create the container instance using the configuration.
*/
protected static SpiContainer createContainer(ContainerConfig containerConfig) {
Iterator<SpiContainerFactory> factories = ServiceLoader.load(SpiContainerFactory.class).iterator();
if (factories.hasNext()) {
return factories.next().create(containerConfig);
}
throw new IllegalStateException("Service loader didn't find a SpiContainerFactory?");
}
}
@@ -0,0 +1,139 @@
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;
/**
* Holds Database instances.
*/
final class DbContext {
private static final Logger logger = LoggerFactory.getLogger(DbContext.class);
static {
EbeanVersion.getVersion();
}
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() {
try {
if (!DbPrimary.isSkip()) {
// look to see if there is a default server defined
String defaultName = DbPrimary.getDefaultServerName();
logger.debug("defaultName:{}", defaultName);
if (defaultName != null && !defaultName.trim().isEmpty()) {
defaultDatabase = getWithCreate(defaultName.trim());
}
}
} catch (BeanNotEnhancedException e) {
throw e;
} catch (DataSourceConfigurationException e) {
String msg = "Configuration error creating DataSource for the default Database." +
" This typically means a missing application-test.yaml or missing ebean-test dependency." +
" See https://ebean.io/docs/trouble-shooting#datasource";
throw new DataSourceConfigurationException(msg, e);
} catch (Throwable e) {
logger.error("Error trying to create the default Database", e);
throw new RuntimeException(e);
}
}
/**
* Return the shared singleton instance.
*/
static DbContext getInstance() {
return INSTANCE;
}
/**
* Return the default database.
*/
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()";
throw new PersistenceException(msg);
}
return defaultDatabase;
}
/**
* Return the database by name.
*/
Database get(String name) {
if (name == null || name.isEmpty()) {
return defaultDatabase;
}
Database server = concMap.get(name);
if (server != null) {
return server;
}
return getWithCreate(name);
}
/**
* Read, create and put of Databases.
*/
private Database getWithCreate(String name) {
lock.lock();
try {
Database server = syncMap.get(name);
if (server == null) {
// register when creating server this way
server = DatabaseFactory.create(name);
register(server, false);
}
return server;
} finally {
lock.unlock();
}
}
/**
* Register a server so we can get it by its name.
*/
void register(Database server, boolean isDefault) {
registerWithName(server.getName(), server, isDefault);
}
private void registerWithName(String name, Database server, boolean isDefault) {
lock.lock();
try {
concMap.put(name, server);
syncMap.put(name, server);
if (isDefault) {
defaultDatabase = server;
}
} finally {
lock.unlock();
}
}
Database mock(String name, Database server, boolean defaultServer) {
Database originalPrimaryServer = this.defaultDatabase;
registerWithName(name, server, defaultServer);
return originalPrimaryServer;
}
}
@@ -3,55 +3,75 @@ package io.ebean;
import io.avaje.config.Config;
import java.util.Properties;
import java.util.concurrent.locks.ReentrantLock;
/**
* Provides singleton state for the default database.
* <p/>
* Intended for internal use as part of bootup, construction, registration of the default database.
*/
class PrimaryServer {
class DbPrimary {
private static final ReentrantLock lock = new ReentrantLock();
private static String defaultServerName;
private static boolean skip;
/**
* Set whether to skip automatically creating the primary database.
*/
static synchronized void setSkip(boolean skip) {
PrimaryServer.skip = skip;
static void setSkip(boolean skip) {
lock.lock();
try {
DbPrimary.skip = skip;
} finally {
lock.unlock();
}
}
/**
* Return true to skip automatically creating the primary database.
*/
static synchronized boolean isSkip() {
return skip;
static boolean isSkip() {
lock.lock();
try {
return skip;
} finally {
lock.unlock();
}
}
/**
* Return the default database name.
*/
static synchronized String getDefaultServerName() {
getProperties();
return defaultServerName;
static String getDefaultServerName() {
lock.lock();
try {
getProperties();
return defaultServerName;
} finally {
lock.unlock();
}
}
/**
* Return the default configuration Properties.
*/
static synchronized Properties getProperties() {
if (defaultServerName == null) {
defaultServerName = determineDefaultServerName();
static Properties getProperties() {
lock.lock();
try {
if (defaultServerName == null) {
defaultServerName = determineDefaultServerName();
}
return Config.asProperties();
} finally {
lock.unlock();
}
return Config.asProperties();
}
/**
* Determine and return the default server name checking system environment variables and then global properties.
*/
private static String determineDefaultServerName() {
String defaultServerName = System.getenv("EBEAN_DB");
defaultServerName = System.getProperty("db", defaultServerName);
defaultServerName = System.getProperty("ebean_db", defaultServerName);
@@ -1,9 +1,9 @@
package io.ebean;
import io.ebeanservice.docstore.api.DocQueryRequest;
import io.ebeanservice.docstore.api.RawDoc;
import javax.annotation.Nullable;
import io.ebean.docstore.DocQueryContext;
import io.ebean.docstore.RawDoc;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -69,7 +69,7 @@ public interface DocumentStore {
* }</pre>
*/
@Nullable
<T> T find(DocQueryRequest<T> request);
<T> T find(DocQueryContext<T> request);
/**
* Execute the find list query. This request is prepared to execute secondary queries.
@@ -86,7 +86,7 @@ public interface DocumentStore {
*
* }</pre>
*/
<T> List<T> findList(DocQueryRequest<T> request);
<T> List<T> findList(DocQueryContext<T> request);
/**
* Execute the query against the document store returning the paged list.
@@ -107,7 +107,7 @@ public interface DocumentStore {
*
* }</pre>
*/
<T> PagedList<T> findPagedList(DocQueryRequest<T> request);
<T> PagedList<T> findPagedList(DocQueryContext<T> request);
/**
* Execute the query against the document store with the expectation of a large set of results
@@ -129,7 +129,7 @@ public interface DocumentStore {
*
* }</pre>
*/
<T> void findEach(DocQueryRequest<T> query, Consumer<T> consumer);
<T> void findEach(DocQueryContext<T> query, Consumer<T> consumer);
/**
* Execute the query against the document store with the expectation of a large set of results
@@ -149,7 +149,7 @@ public interface DocumentStore {
* .setUseDocStore(true)
* .where()... // perhaps add predicates
* .findEachWhile(new Predicate<Order>() {
* Override
* @Override
* public void accept(Order bean) {
* // process the bean
*
@@ -161,7 +161,7 @@ public interface DocumentStore {
*
* }</pre>
*/
<T> void findEachWhile(DocQueryRequest<T> query, Predicate<T> consumer);
<T> void findEachWhile(DocQueryContext<T> query, Predicate<T> consumer);
/**
* Find each processing raw documents.
@@ -2,26 +2,19 @@ package io.ebean;
import io.ebean.annotation.TxIsolation;
import io.ebean.cache.ServerCacheManager;
import io.ebean.config.BeanNotEnhancedException;
import io.ebean.config.ServerConfig;
import io.ebean.datasource.DataSourceConfigurationException;
import io.ebean.plugin.Property;
import io.ebean.text.csv.CsvReader;
import io.ebean.text.json.JsonContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.persistence.OptimisticLockException;
import javax.persistence.PersistenceException;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
/**
* Deprecated - please migrate to use <code>io.ebean.DB</code>.
@@ -34,123 +27,8 @@ import java.util.concurrent.ConcurrentHashMap;
*/
@Deprecated
public final class Ebean {
private static final Logger logger = LoggerFactory.getLogger(Ebean.class);
static {
EbeanVersion.getVersion(); // initialises the version class and logs the version.
}
/**
* Manages creation and cache of Databases.
*/
private static final Ebean.ServerManager serverMgr = new Ebean.ServerManager();
/**
* Helper class for managing fast and safe access and creation of Databases.
*/
private static final class ServerManager {
/**
* Cache for fast concurrent read access.
*/
private final ConcurrentHashMap<String, EbeanServer> concMap = new ConcurrentHashMap<>();
/**
* Cache for synchronized read, creation and put. Protected by the monitor object.
*/
private final HashMap<String, EbeanServer> syncMap = new HashMap<>();
private final Object monitor = new Object();
/**
* The 'default' Database.
*/
private EbeanServer defaultServer;
private ServerManager() {
try {
if (!PrimaryServer.isSkip()) {
// look to see if there is a default server defined
String defaultName = PrimaryServer.getDefaultServerName();
logger.debug("defaultName:{}", defaultName);
if (defaultName != null && !defaultName.trim().isEmpty()) {
defaultServer = getWithCreate(defaultName.trim());
}
}
} catch (BeanNotEnhancedException e) {
throw e;
} catch (DataSourceConfigurationException e) {
String msg = "Configuration error creating DataSource for the default Database." +
" This typically means a missing application-test.yaml or missing ebean-test dependency." +
" See https://ebean.io/docs/trouble-shooting#datasource";
throw new DataSourceConfigurationException(msg, e);
} catch (Throwable e) {
logger.error("Error trying to create the default Database", e);
throw new RuntimeException(e);
}
}
private EbeanServer getDefaultServer() {
if (defaultServer == 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()";
throw new PersistenceException(msg);
}
return defaultServer;
}
private EbeanServer get(String name) {
if (name == null || name.isEmpty()) {
return defaultServer;
}
// non-synchronized read
EbeanServer server = concMap.get(name);
if (server != null) {
return server;
}
// synchronized read, create and put
return getWithCreate(name);
}
/**
* Synchronized read, create and put of Databases.
*/
private EbeanServer getWithCreate(String name) {
synchronized (monitor) {
EbeanServer server = syncMap.get(name);
if (server == null) {
// register when creating server this way
server = EbeanServerFactory.create(name);
register(server, false);
}
return server;
}
}
/**
* Register a server so we can get it by its name.
*/
private void register(EbeanServer server, boolean isDefaultServer) {
registerWithName(server.getName(), server, isDefaultServer);
}
private void registerWithName(String name, EbeanServer server, boolean isDefaultServer) {
synchronized (monitor) {
concMap.put(name, server);
syncMap.put(name, server);
if (isDefaultServer) {
defaultServer = server;
}
}
}
}
private static final DbContext context = DbContext.getInstance();
private Ebean() {
}
@@ -174,7 +52,7 @@ public final class Ebean {
* @param name the name of the server, can use null for the 'default server'
*/
public static EbeanServer getServer(String name) {
return serverMgr.get(name);
return (EbeanServer)context.get(name);
}
/**
@@ -184,7 +62,27 @@ public final class Ebean {
* </p>
*/
public static EbeanServer getDefaultServer() {
return serverMgr.getDefaultServer();
return (EbeanServer)context.getDefault();
}
/**
* Register the server with this Ebean singleton. Specify if the registered
* server is the primary/default database.
*/
@Deprecated
public static void register(EbeanServer server, boolean defaultServer) {
context.register(server, defaultServer);
}
/**
* Backdoor for registering a mock implementation of EbeanServer as the default database.
*/
protected static EbeanServer mock(String name, EbeanServer server, boolean defaultServer) {
return (EbeanServer)context.mock(name, server, defaultServer);
}
private static Database getDefault() {
return context.getDefault();
}
/**
@@ -205,24 +103,7 @@ public final class Ebean {
* </p>
*/
public static ExpressionFactory getExpressionFactory() {
return serverMgr.getDefaultServer().getExpressionFactory();
}
/**
* Register the server with this Ebean singleton. Specify if the registered
* server is the primary/default database.
*/
public static void register(EbeanServer server, boolean defaultServer) {
serverMgr.register(server, defaultServer);
}
/**
* Backdoor for registering a mock implementation of EbeanServer as the default database.
*/
protected static EbeanServer mock(String name, EbeanServer server, boolean defaultServer) {
EbeanServer originalPrimaryServer = serverMgr.defaultServer;
serverMgr.registerWithName(name, server, defaultServer);
return originalPrimaryServer;
return getDefault().getExpressionFactory();
}
/**
@@ -238,7 +119,7 @@ public final class Ebean {
* </p>
*/
public static Object nextId(Class<?> beanType) {
return serverMgr.getDefaultServer().nextId(beanType);
return getDefault().nextId(beanType);
}
/**
@@ -284,7 +165,7 @@ public final class Ebean {
* </p>
*/
public static Transaction beginTransaction() {
return serverMgr.getDefaultServer().beginTransaction();
return getDefault().beginTransaction();
}
/**
@@ -293,7 +174,7 @@ public final class Ebean {
* @param isolation the Transaction isolation level
*/
public static Transaction beginTransaction(TxIsolation isolation) {
return serverMgr.getDefaultServer().beginTransaction(isolation);
return getDefault().beginTransaction(isolation);
}
/**
@@ -346,7 +227,7 @@ public final class Ebean {
* }</pre>
*/
public static Transaction beginTransaction(TxScope scope) {
return serverMgr.getDefaultServer().beginTransaction(scope);
return getDefault().beginTransaction(scope);
}
/**
@@ -354,7 +235,7 @@ public final class Ebean {
* in scope.
*/
public static Transaction currentTransaction() {
return serverMgr.getDefaultServer().currentTransaction();
return getDefault().currentTransaction();
}
/**
@@ -384,21 +265,21 @@ public final class Ebean {
* @throws PersistenceException if there is no currently active transaction
*/
public static void register(TransactionCallback transactionCallback) throws PersistenceException {
serverMgr.getDefaultServer().register(transactionCallback);
getDefault().register(transactionCallback);
}
/**
* Commit the current transaction.
*/
public static void commitTransaction() {
serverMgr.getDefaultServer().commitTransaction();
getDefault().commitTransaction();
}
/**
* Rollback the current transaction.
*/
public static void rollbackTransaction() {
serverMgr.getDefaultServer().rollbackTransaction();
getDefault().rollbackTransaction();
}
/**
@@ -426,14 +307,14 @@ public final class Ebean {
* }</pre>
*/
public static void endTransaction() {
serverMgr.getDefaultServer().endTransaction();
getDefault().endTransaction();
}
/**
* Mark the current transaction as rollback only.
*/
public static void setRollbackOnly() {
serverMgr.getDefaultServer().currentTransaction().setRollbackOnly();
getDefault().currentTransaction().setRollbackOnly();
}
/**
@@ -444,7 +325,7 @@ public final class Ebean {
* </p>
*/
public static Map<String, ValuePair> diff(Object a, Object b) {
return serverMgr.getDefaultServer().diff(a, b);
return getDefault().diff(a, b);
}
/**
@@ -465,7 +346,7 @@ public final class Ebean {
* <pre>{@code
* public class Order { ...
*
* OneToMany(cascade=CascadeType.ALL, mappedBy="order")
* @OneToMany(cascade=CascadeType.ALL, mappedBy="order")
* List<OrderDetail> details;
* ...
* }
@@ -478,7 +359,7 @@ public final class Ebean {
* </p>
*/
public static void save(Object bean) throws OptimisticLockException {
serverMgr.getDefaultServer().save(bean);
getDefault().save(bean);
}
/**
@@ -486,14 +367,14 @@ public final class Ebean {
* want to explicitly insert it.
*/
public static void insert(Object bean) {
serverMgr.getDefaultServer().insert(bean);
getDefault().insert(bean);
}
/**
* Insert a collection of beans.
*/
public static void insertAll(Collection<?> beans) {
serverMgr.getDefaultServer().insertAll(beans);
getDefault().insertAll(beans);
}
/**
@@ -516,7 +397,7 @@ public final class Ebean {
* }</pre>
*/
public static void markAsDirty(Object bean) throws OptimisticLockException {
serverMgr.getDefaultServer().markAsDirty(bean);
getDefault().markAsDirty(bean);
}
/**
@@ -543,14 +424,14 @@ public final class Ebean {
* }</pre>
*/
public static void update(Object bean) throws OptimisticLockException {
serverMgr.getDefaultServer().update(bean);
getDefault().update(bean);
}
/**
* Update the beans in the collection.
*/
public static void updateAll(Collection<?> beans) throws OptimisticLockException {
serverMgr.getDefaultServer().updateAll(beans);
getDefault().updateAll(beans);
}
/**
@@ -559,7 +440,7 @@ public final class Ebean {
* @param bean The bean to merge
*/
public static void merge(Object bean) {
serverMgr.getDefaultServer().merge(bean);
getDefault().merge(bean);
}
/**
@@ -569,14 +450,14 @@ public final class Ebean {
* @param options The options to control the merge
*/
public static void merge(Object bean, MergeOptions options) {
serverMgr.getDefaultServer().merge(bean, options);
getDefault().merge(bean, options);
}
/**
* Save all the beans from a Collection.
*/
public static int saveAll(Collection<?> beans) throws OptimisticLockException {
return serverMgr.getDefaultServer().saveAll(beans);
return getDefault().saveAll(beans);
}
/**
@@ -627,7 +508,7 @@ public final class Ebean {
*/
@Nonnull
public static Set<Property> checkUniqueness(Object bean) {
return serverMgr.getDefaultServer().checkUniqueness(bean);
return getDefault().checkUniqueness(bean);
}
/**
@@ -635,7 +516,7 @@ public final class Ebean {
*/
@Nonnull
public static Set<Property> checkUniqueness(Object bean, Transaction transaction) {
return serverMgr.getDefaultServer().checkUniqueness(bean, transaction);
return getDefault().checkUniqueness(bean, transaction);
}
/**
@@ -658,56 +539,56 @@ public final class Ebean {
* </p>
*/
public static boolean delete(Object bean) throws OptimisticLockException {
return serverMgr.getDefaultServer().delete(bean);
return getDefault().delete(bean);
}
/**
* Delete the bean in permanent fashion (will not use soft delete).
*/
public static boolean deletePermanent(Object bean) throws OptimisticLockException {
return serverMgr.getDefaultServer().deletePermanent(bean);
return getDefault().deletePermanent(bean);
}
/**
* Delete the bean given its type and id.
*/
public static int delete(Class<?> beanType, Object id) {
return serverMgr.getDefaultServer().delete(beanType, id);
return getDefault().delete(beanType, id);
}
/**
* Delete permanent the bean given its type and id.
*/
public static int deletePermanent(Class<?> beanType, Object id) {
return serverMgr.getDefaultServer().deletePermanent(beanType, id);
return getDefault().deletePermanent(beanType, id);
}
/**
* Delete several beans given their type and id values.
*/
public static int deleteAll(Class<?> beanType, Collection<?> ids) {
return serverMgr.getDefaultServer().deleteAll(beanType, ids);
return getDefault().deleteAll(beanType, ids);
}
/**
* Delete permanent several beans given their type and id values.
*/
public static int deleteAllPermanent(Class<?> beanType, Collection<?> ids) {
return serverMgr.getDefaultServer().deleteAllPermanent(beanType, ids);
return getDefault().deleteAllPermanent(beanType, ids);
}
/**
* Delete all the beans in the Collection.
*/
public static int deleteAll(Collection<?> beans) throws OptimisticLockException {
return serverMgr.getDefaultServer().deleteAll(beans);
return getDefault().deleteAll(beans);
}
/**
* Delete permanent all the beans in the Collection (will not use soft delete).
*/
public static int deleteAllPermanent(Collection<?> beans) throws OptimisticLockException {
return serverMgr.getDefaultServer().deleteAllPermanent(beans);
return getDefault().deleteAllPermanent(beans);
}
/**
@@ -718,7 +599,7 @@ public final class Ebean {
* </p>
*/
public static void refresh(Object bean) {
serverMgr.getDefaultServer().refresh(bean);
getDefault().refresh(bean);
}
/**
@@ -736,7 +617,7 @@ public final class Ebean {
* @param manyPropertyName the property name of the List Set or Map to refresh.
*/
public static void refreshMany(Object bean, String manyPropertyName) {
serverMgr.getDefaultServer().refreshMany(bean, manyPropertyName);
getDefault().refreshMany(bean, manyPropertyName);
}
/**
@@ -761,7 +642,7 @@ public final class Ebean {
* @param id the id value
*/
public static <T> T getReference(Class<T> beanType, Object id) {
return serverMgr.getDefaultServer().getReference(beanType, id);
return getDefault().getReference(beanType, id);
}
/**
@@ -804,7 +685,7 @@ public final class Ebean {
* @param sortByClause the properties to sort the list by
*/
public static <T> void sort(List<T> list, String sortByClause) {
serverMgr.getDefaultServer().sort(list, sortByClause);
getDefault().sort(list, sortByClause);
}
/**
@@ -854,7 +735,7 @@ public final class Ebean {
*/
@Nullable
public static <T> T find(Class<T> beanType, Object id) {
return serverMgr.getDefaultServer().find(beanType, id);
return getDefault().find(beanType, id);
}
/**
@@ -869,7 +750,7 @@ public final class Ebean {
*/
@Deprecated
public static SqlQuery createSqlQuery(String sql) {
return serverMgr.getDefaultServer().sqlQuery(sql);
return getDefault().sqlQuery(sql);
}
/**
@@ -884,7 +765,7 @@ public final class Ebean {
*/
@Deprecated
public static SqlUpdate createSqlUpdate(String sql) {
return serverMgr.getDefaultServer().sqlUpdate(sql);
return getDefault().sqlUpdate(sql);
}
/**
@@ -893,7 +774,7 @@ public final class Ebean {
* @see CallableSql
*/
public static CallableSql createCallableSql(String sql) {
return serverMgr.getDefaultServer().createCallableSql(sql);
return getDefault().createCallableSql(sql);
}
/**
@@ -925,16 +806,14 @@ public final class Ebean {
* }</pre>
*/
public static <T> Update<T> createUpdate(Class<T> beanType, String ormUpdate) {
return serverMgr.getDefaultServer().createUpdate(beanType, ormUpdate);
return getDefault().createUpdate(beanType, ormUpdate);
}
/**
* Create a CsvReader for a given beanType.
*/
public static <T> CsvReader<T> createCsvReader(Class<T> beanType) {
return serverMgr.getDefaultServer().createCsvReader(beanType);
return getDefault().createCsvReader(beanType);
}
/**
@@ -949,7 +828,7 @@ public final class Ebean {
* @return The query
*/
public static <T> Query<T> createNamedQuery(Class<T> beanType, String namedQuery) {
return serverMgr.getDefaultServer().createNamedQuery(beanType, namedQuery);
return getDefault().createNamedQuery(beanType, namedQuery);
}
/**
@@ -972,8 +851,7 @@ public final class Ebean {
* @return A ORM Query object for this beanType
*/
public static <T> Query<T> createQuery(Class<T> beanType) {
return serverMgr.getDefaultServer().createQuery(beanType);
return getDefault().createQuery(beanType);
}
/**
@@ -1010,8 +888,7 @@ public final class Ebean {
* @return The query with expressions defined as per the parsed query statement
*/
public static <T> Query<T> createQuery(Class<T> beanType, String eql) {
return serverMgr.getDefaultServer().createQuery(beanType, eql);
return getDefault().createQuery(beanType, eql);
}
/**
@@ -1026,8 +903,7 @@ public final class Ebean {
* @return A ORM Query object for this beanType
*/
public static <T> Query<T> find(Class<T> beanType) {
return serverMgr.getDefaultServer().find(beanType);
return getDefault().find(beanType);
}
/**
@@ -1050,7 +926,7 @@ public final class Ebean {
* @return The query to set parameters and execute
*/
public static <T> Query<T> findNative(Class<T> beanType, String nativeSql) {
return serverMgr.getDefaultServer().findNative(beanType, nativeSql);
return getDefault().findNative(beanType, nativeSql);
}
/**
@@ -1065,7 +941,7 @@ public final class Ebean {
* @param <T> The type of the DTO bean.
*/
public static <T> DtoQuery<T> findDto(Class<T> dtoType, String sql) {
return serverMgr.getDefaultServer().findDto(dtoType, sql);
return getDefault().findDto(dtoType, sql);
}
/**
@@ -1087,7 +963,7 @@ public final class Ebean {
* @return The update query to use
*/
public static <T> UpdateQuery<T> update(Class<T> beanType) {
return serverMgr.getDefaultServer().update(beanType);
return getDefault().update(beanType);
}
/**
@@ -1101,7 +977,7 @@ public final class Ebean {
* </p>
*/
public static <T> Filter<T> filter(Class<T> beanType) {
return serverMgr.getDefaultServer().filter(beanType);
return getDefault().filter(beanType);
}
/**
@@ -1144,7 +1020,7 @@ public final class Ebean {
* @see Ebean#execute(CallableSql)
*/
public static int execute(SqlUpdate sqlUpdate) {
return serverMgr.getDefaultServer().execute(sqlUpdate);
return getDefault().execute(sqlUpdate);
}
/**
@@ -1172,7 +1048,7 @@ public final class Ebean {
* @see Ebean#execute(SqlUpdate)
*/
public static int execute(CallableSql callableSql) {
return serverMgr.getDefaultServer().execute(callableSql);
return getDefault().execute(callableSql);
}
/**
@@ -1196,7 +1072,7 @@ public final class Ebean {
* }</pre>
*/
public static void execute(TxScope scope, Runnable r) {
serverMgr.getDefaultServer().execute(scope, r);
getDefault().execute(scope, r);
}
/**
@@ -1223,7 +1099,7 @@ public final class Ebean {
* }</pre>
*/
public static void execute(Runnable r) {
serverMgr.getDefaultServer().execute(r);
getDefault().execute(r);
}
/**
@@ -1248,7 +1124,7 @@ public final class Ebean {
* }</pre>
*/
public static <T> T executeCall(TxScope scope, Callable<T> c) {
return serverMgr.getDefaultServer().executeCall(scope, c);
return getDefault().executeCall(scope, c);
}
/**
@@ -1281,7 +1157,7 @@ public final class Ebean {
* }</pre>
*/
public static <T> T executeCall(Callable<T> c) {
return serverMgr.getDefaultServer().executeCall(c);
return getDefault().executeCall(c);
}
/**
@@ -1315,8 +1191,7 @@ public final class Ebean {
* @param deletes true if rows on the table where deleted
*/
public static void externalModification(String tableName, boolean inserts, boolean updates, boolean deletes) {
serverMgr.getDefaultServer().externalModification(tableName, inserts, updates, deletes);
getDefault().externalModification(tableName, inserts, updates, deletes);
}
/**
@@ -1326,14 +1201,14 @@ public final class Ebean {
* </p>
*/
public static BeanState getBeanState(Object bean) {
return serverMgr.getDefaultServer().getBeanState(bean);
return getDefault().getBeanState(bean);
}
/**
* Return the manager of the server cache ("L2" cache).
*/
public static ServerCacheManager getServerCacheManager() {
return serverMgr.getDefaultServer().getServerCacheManager();
return getDefault().getServerCacheManager();
}
/**
@@ -1341,14 +1216,14 @@ public final class Ebean {
* queries.
*/
public static BackgroundExecutor getBackgroundExecutor() {
return serverMgr.getDefaultServer().getBackgroundExecutor();
return getDefault().getBackgroundExecutor();
}
/**
* Return the JsonContext for reading/writing JSON.
*/
public static JsonContext json() {
return serverMgr.getDefaultServer().json();
return getDefault().json();
}
}
@@ -0,0 +1,70 @@
package io.ebean;
import io.ebean.config.ContainerConfig;
import io.ebean.config.ServerConfig;
/**
* Deprecated - please migrate to DatabaseFactory.
* <p>
* Creates EbeanServer instances.
* <p>
* This uses either a ServerConfig or properties in the ebean.properties file to
* configure and create a EbeanServer instance.
* </p>
* <p>
* The EbeanServer instance can either be registered with the Ebean singleton or
* not. The Ebean singleton effectively holds a map of EbeanServers by a name.
* If the EbeanServer is registered with the Ebean singleton you can retrieve it
* later via {@link Ebean#getServer(String)}.
* </p>
* <p>
* One EbeanServer can be nominated as the 'default/primary' EbeanServer. Many
* methods on the Ebean singleton such as {@link Ebean#find(Class)} are just a
* convenient way of using the 'default/primary' EbeanServer.
* </p>
*/
@Deprecated
public class EbeanServerFactory {
/**
* Initialise the container with clustering configuration.
* <p>
* Call this prior to creating any EbeanServer instances or alternatively set the
* ContainerConfig on the ServerConfig when creating the first EbeanServer instance.
*/
public static void initialiseContainer(ContainerConfig containerConfig) {
DatabaseFactory.initialiseContainer(containerConfig);
}
/**
* Create using ebean.properties to configure the database.
*/
public static EbeanServer create(String name) {
return (EbeanServer)DatabaseFactory.create(name);
}
/**
* Create using the ServerConfig object to configure the database.
*/
public static EbeanServer create(ServerConfig config) {
return (EbeanServer)DatabaseFactory.create(config);
}
/**
* Create using the ServerConfig additionally specifying a classLoader to use as the context class loader.
*/
public static EbeanServer createWithContextClassLoader(ServerConfig config, ClassLoader classLoader) {
return (EbeanServer)DatabaseFactory.createWithContextClassLoader(config, classLoader);
}
/**
* Shutdown gracefully all EbeanServers cleaning up any resources as required.
* <p>
* This is typically invoked via JVM shutdown hook and not explicitly called.
* </p>
*/
public static void shutdown() {
DatabaseFactory.shutdown();
}
}
@@ -6,18 +6,18 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* Class to determine the ebean version. (
* @author Roland Praml, FOCONIS AG
* Class to determine the ebean version.
*
* @author Roland Praml, FOCONIS AG
*/
public class EbeanVersion {
private EbeanVersion() {
}
private static final Logger logger = LoggerFactory.getLogger(EbeanVersion.class);
private static String version = "unknown";
static {
try {
Properties prop = new Properties();
@@ -34,6 +34,10 @@ public class EbeanVersion {
}
}
private EbeanVersion() {
// hide
}
/**
* Returns the ebean version (read from /META-INF/maven/io.ebean/ebean/pom.properties)
*/
@@ -199,6 +199,14 @@ public interface ExpressionFactory {
*/
Expression gtOrNull(String propertyName, Object value);
/**
* Greater than or Equal to OR Null ({@code >= or null })
* <p>
* A convenient expression combining GE and Is Null. Most often useful for range
* expressions where the top range value is nullable.
*/
Expression geOrNull(String propertyName, Object value);
/**
* Greater Than - property greater than the given value.
*/
@@ -218,6 +226,14 @@ public interface ExpressionFactory {
*/
Expression ltOrNull(String propertyName, Object value);
/**
* Less Than or Equal to OR Null ({@code <= or null })
* <p>
* A convenient expression combining LE and Is Null. Most often useful for range
* expressions where the bottom range value is nullable.
*/
Expression leOrNull(String propertyName, Object value);
/**
* Less Than - property less than the given value.
*/
@@ -169,6 +169,28 @@ public interface ExpressionList<T> {
*/
UpdateQuery<T> asUpdate();
/**
* Execute the query with the given lock type and WAIT.
* <p>
* Note that <code>forUpdate()</code> is the same as
* <code>withLock(LockType.UPDATE)</code>.
* <p>
* Provides us with the ability to explicitly use Postgres
* SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks.
*/
Query<T> withLock(Query.LockType lockType);
/**
* Execute the query with the given lock type and lock wait.
* <p>
* Note that <code>forUpdateNoWait()</code> is the same as
* <code>withLock(LockType.UPDATE, LockWait.NOWAIT)</code>.
* <p>
* Provides us with the ability to explicitly use Postgres
* SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks.
*/
Query<T> withLock(Query.LockType lockType, Query.LockWait lockWait);
/**
* Execute using "for update" clause which results in the DB locking the record.
*/
@@ -886,6 +908,11 @@ public interface ExpressionList<T> {
*/
ExpressionList<T> gtOrNull(String propertyName, Object value);
/**
* Greater Than or Equal to OR Null - ({@code >= or null }).
*/
ExpressionList<T> geOrNull(String propertyName, Object value);
/**
* Greater Than or Equal to - property greater than or equal to the given
* value.
@@ -902,6 +929,11 @@ public interface ExpressionList<T> {
*/
ExpressionList<T> ltOrNull(String propertyName, Object value);
/**
* Less Than or Equal to OR Null - ({@code <= or null }).
*/
ExpressionList<T> leOrNull(String propertyName, Object value);
/**
* Less Than or Equal to - property less than or equal to the given value.
*/
@@ -0,0 +1,246 @@
package io.ebean;
import java.io.Serializable;
/**
* Defines how a relationship is fetched via either normal SQL join,
* a eager secondary query, via lazy loading or via eagerly hitting L2 cache.
* <p>
* <pre>{@code
* // Normal fetch join results in a single SQL query
* List<Order> list = DB.find(Order.class).fetch("details").findList();
*
* }</pre>
* <p>
* Example: Using a "query join" instead of a "fetch join" we instead use 2 SQL queries
* </p>
* <p>
* <pre>{@code
*
* // This will use 2 SQL queries to build this object graph
* List<Order> list =
* DB.find(Order.class)
* .fetch("details", FetchConfig.ofQuery())
* .findList();
*
* // query 1) find order
* // query 2) find orderDetails where order.id in (?,?...) // first 100 order id's
*
* }</pre>
*
* @author mario
* @author rbygrave
*/
public class FetchConfig implements Serializable {
private static final long serialVersionUID = 1L;
private static final int JOIN_MODE = 0;
private static final int QUERY_MODE = 1;
private static final int LAZY_MODE = 2;
private static final int CACHE_MODE = 3;
private int mode;
private int batchSize;
private int hashCode;
/**
* Deprecated - migrate to one of the static factory methods like {@link FetchConfig#ofQuery()}
*
* Construct using default JOIN mode.
*/
@Deprecated
public FetchConfig() {
//this.mode = JOIN_MODE;
this.batchSize = 100;
this.hashCode = 1000;
}
private FetchConfig(int mode, int batchSize) {
this.mode = mode;
this.batchSize = batchSize;
this.hashCode = mode + 10 * batchSize;
}
/**
* Return FetchConfig to eagerly fetch the relationship using L2 cache.
* <p>
* Any cache misses will be loaded by secondary query to the database.
*/
public static FetchConfig ofCache() {
return new FetchConfig(CACHE_MODE, 100);
}
/**
* Return FetchConfig to eagerly fetch the relationship using a secondary query.
*/
public static FetchConfig ofQuery() {
return new FetchConfig(QUERY_MODE, 100);
}
/**
* Return FetchConfig to eagerly fetch the relationship using a secondary with a given batch size.
*/
public static FetchConfig ofQuery(int batchSize) {
return new FetchConfig(QUERY_MODE, batchSize);
}
/**
* Return FetchConfig to lazily load the relationship.
*/
public static FetchConfig ofLazy() {
return new FetchConfig(LAZY_MODE, 10);
}
/**
* Return FetchConfig to lazily load the relationship specifying the batch size.
*/
public static FetchConfig ofLazy(int batchSize) {
return new FetchConfig(LAZY_MODE, batchSize);
}
/**
* Return FetchConfig to fetch the relationship using SQL join.
*/
public static FetchConfig ofDefault() {
return new FetchConfig(JOIN_MODE, 100);
}
/**
* We want to migrate away from mutating FetchConfig to a fully immutable FetchConfig.
*/
private FetchConfig mutate(int mode, int batchSize) {
if (batchSize < 1) {
throw new IllegalArgumentException("batch size "+batchSize+" must be > 0");
}
this.mode = mode;
this.batchSize = batchSize;
this.hashCode = mode + 10 * batchSize;
return this;
}
/**
* Deprecated - migrate to FetchConfig.ofLazy().
*/
@Deprecated
public FetchConfig lazy() {
return mutate(LAZY_MODE, 10);
}
/**
* Deprecated - migrate to FetchConfig.ofLazy(batchSize).
*/
@Deprecated
public FetchConfig lazy(int batchSize) {
return mutate(LAZY_MODE, batchSize);
}
/**
* Deprecated - migrate to FetchConfig.ofQuery().
*
* Eagerly fetch the beans in this path as a separate query (rather than as
* part of the main query).
* <p>
* This will use the default batch size for separate query which is 100.
*/
@Deprecated
public FetchConfig query() {
return mutate(QUERY_MODE, 100);
}
/**
* Deprecated - migrate to FetchConfig.ofQuery(batchSize).
*
* Eagerly fetch the beans in this path as a separate query (rather than as
* part of the main query).
* <p>
* The queryBatchSize is the number of parent id's that this separate query
* will load per batch.
* </p>
* <p>
* This will load all beans on this path eagerly unless a {@link #lazy(int)}
* is also used.
* </p>
*
* @param batchSize the batch size used to load beans on this path
*/
@Deprecated
public FetchConfig query(int batchSize) {
return mutate(QUERY_MODE, batchSize);
}
/**
* Deprecated - migrate to FetchConfig.ofQuery(batchSize).
*
* Eagerly fetch the first batch of beans on this path.
* This is similar to {@link #query(int)} but only fetches the first batch.
* <p>
* If there are more parent beans than the batch size then they will not be
* loaded eagerly but instead use lazy loading.
* </p>
*
* @param batchSize the number of parent beans this path is populated for
*/
@Deprecated
public FetchConfig queryFirst(int batchSize) {
return query(batchSize);
}
/**
* Deprecated - migrate to FetchConfig.ofCache().
*
* Eagerly fetch the beans fetching the beans from the L2 bean cache
* and using the DB for beans not in the cache.
*/
@Deprecated
public FetchConfig cache() {
return mutate(CACHE_MODE, 100);
}
/**
* Return the batch size for fetching.
*/
public int getBatchSize() {
return batchSize;
}
/**
* Return true if the fetch should use the L2 cache.
*/
public boolean isCache() {
return mode == CACHE_MODE;
}
/**
* Return true if the fetch should be a eager secondary query.
*/
public boolean isQuery() {
return mode == QUERY_MODE;
}
/**
* Return true if the fetch should be a lazy query.
*/
public boolean isLazy() {
return mode == LAZY_MODE;
}
/**
* Return true if the fetch should try to use SQL join.
*/
public boolean isJoin() {
return mode == JOIN_MODE;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
return (hashCode == ((FetchConfig) o).hashCode);
}
@Override
public int hashCode() {
return hashCode;
}
}
@@ -37,7 +37,7 @@ import java.util.List;
* }
* }
*
* Entity
* @Entity
* public class Customer extends BaseModel {
*
* public static final CustomerFinder find = new CustomerFinder();
@@ -80,7 +80,7 @@ public class Finder<I, T> {
* // ... add extra customer specific finder methods
* }
*
* Entity
* @Entity
* public class Customer extends BaseModel {
*
* public static final CustomerFinder find = new CustomerFinder();
@@ -32,16 +32,16 @@ import io.ebean.bean.EntityBean;
* // Typically there is a common base model that has some
* // common properties like the ones below
*
* MappedSuperclass
* @MappedSuperclass
* public class BaseModel extends Model {
*
* Id Long id;
* @Id Long id;
*
* Version Long version;
* @Version Long version;
*
* WhenCreated Timestamp whenCreated;
* @WhenCreated Timestamp whenCreated;
*
* WhenUpdated Timestamp whenUpdated;
* @WhenUpdated Timestamp whenUpdated;
*
* ...
* }
@@ -52,7 +52,7 @@ import io.ebean.bean.EntityBean;
*
* // Extend the mappedSuperclass
*
* Entity Table(name="o_account")
* @Entity @Table(name="o_account")
* public class Customer extends BaseModel {
*
* String name;
@@ -1,11 +1,9 @@
package io.ebeaninternal.json;
import java.io.Serializable;
package io.ebean;
/**
* Owner object notified when a modification is detected.
*/
public interface ModifyAwareOwner extends Serializable {
public interface ModifyAwareType {
/**
* Return true if the value is considered dirty.
@@ -16,11 +14,6 @@ public interface ModifyAwareOwner extends Serializable {
/**
* Marks the object as modified.
*/
void markAsModified();
/**
* Reset the dirty state to clean.
*/
void resetMarkedDirty();
void setMarkedDirty(boolean markedDirty);
}
@@ -1,7 +1,5 @@
package io.ebean;
import io.ebean.util.StringHelper;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -341,7 +339,7 @@ public final class OrderBy<T> implements Serializable {
if (collation != null) {
if (collation.contains("${}")) {
// this is a complex collation, e.g. DB2 - we must replace the property
sb.append(StringHelper.replaceString(collation, "${}", property));
sb.append(collation.replace("${}", property));
} else {
sb.append(property);
sb.append(" collate ").append(collation);
@@ -18,7 +18,7 @@ import java.util.List;
*
* // where a bean is annotated with a complex
* // natural key made of several properties
* Cache(naturalKey = {"store","code","sku"})
* @Cache(naturalKey = {"store","code","sku"})
*
*
* Pairs pairs = new Pairs("sku", "code");
@@ -6,7 +6,7 @@ package io.ebean;
* Ebean has traditionally used Transaction scope for the PersistenceContext. This is used to change the scope to
* use (by default) and explicitly set the scope to use for an individual query.
*
* @see io.ebean.config.ServerConfig#setPersistenceContextScope(PersistenceContextScope)
* @see io.ebean.config.DatabaseConfig#setPersistenceContextScope(PersistenceContextScope)
* @see Query#setPersistenceContextScope(PersistenceContextScope)
*/
public enum PersistenceContextScope {
@@ -180,13 +180,44 @@ import java.util.stream.Stream;
public interface Query<T> {
/**
* For update mode.
* The lock type (strength) to use with query FOR UPDATE row locking.
*/
enum ForUpdate {
enum LockType {
/**
* The default lock type being either UPDATE or NO_KEY_UPDATE based on
* PlatformConfig.forUpdateNoKey configuration (Postgres option).
*/
DEFAULT,
/**
* FOR UPDATE.
*/
UPDATE,
/**
* FOR NO KEY UPDATE (Postgres only).
*/
NO_KEY_UPDATE,
/**
* FOR SHARE (Postgres only).
*/
SHARE,
/**
* FOR KEY SHARE (Postgres only).
*/
KEY_SHARE
}
/**
* FOR UPDATE wait mode.
*/
enum LockWait {
/**
* Standard For update clause.
*/
BASE,
WAIT,
/**
* For update with No Wait option.
@@ -283,7 +314,7 @@ public interface Query<T> {
/**
* Specify the PersistenceContextScope to use for this query.
* <p/>
* When this is not set the 'default' configured on {@link io.ebean.config.ServerConfig#setPersistenceContextScope(PersistenceContextScope)}
* When this is not set the 'default' configured on {@link io.ebean.config.DatabaseConfig#setPersistenceContextScope(PersistenceContextScope)}
* is used - this value defaults to {@link PersistenceContextScope#TRANSACTION}.
* <p/>
* Note that the same persistence Context is used for subsequent lazy loading and query join queries.
@@ -483,7 +514,7 @@ public interface Query<T> {
* </p>
* <pre>{@code
*
* fetch(path, fetchProperties, new FetchConfig().query())
* fetch(path, fetchProperties, FetchConfig.ofQuery())
*
* }</pre>
* <p>
@@ -517,7 +548,7 @@ public interface Query<T> {
* </p>
* <pre>{@code
*
* fetch(path, fetchProperties, new FetchConfig().lazy())
* fetch(path, fetchProperties, FetchConfig.ofLazy())
*
* }</pre>
* <p>
@@ -542,7 +573,7 @@ public interface Query<T> {
* // fetch customers (their id, name and status)
* List<Customer> customers = DB.find(Customer.class)
* .select("name, status")
* .fetch("contacts", "firstName,lastName,email", new FetchConfig().lazy(10))
* .fetch("contacts", "firstName,lastName,email", FetchConfig.ofLazy(10))
* .findList();
*
* }</pre>
@@ -579,7 +610,7 @@ public interface Query<T> {
* </p>
* <pre>{@code
*
* fetch(path, new FetchConfig().query())
* fetch(path, FetchConfig.ofQuery())
*
* }</pre>
* <p>
@@ -608,7 +639,7 @@ public interface Query<T> {
* </p>
* <pre>{@code
*
* fetch(path, new FetchConfig().lazy())
* fetch(path, FetchConfig.ofLazy())
*
* }</pre>
* <p>
@@ -631,7 +662,7 @@ public interface Query<T> {
* // fetch customers (their id, name and status)
* List<Customer> customers = DB.find(Customer.class)
* // lazy fetch contacts with a batch size of 100
* .fetch("contacts", new FetchConfig().lazy(100))
* .fetch("contacts", FetchConfig.ofLazy(100))
* .findList();
*
* }</pre>
@@ -813,7 +844,7 @@ public interface Query<T> {
* <pre>{@code
*
* DB.find(Customer.class)
* .fetch("contacts", new FetchConfig().query(2))
* .fetch("contacts", FetchConfig.ofQuery(2))
* .where().eq("status", Status.NEW)
* .order().asc("id")
* .setMaxRows(2000)
@@ -1613,8 +1644,32 @@ public interface Query<T> {
*/
String getGeneratedSql();
/**
* Execute the query with the given lock type and WAIT.
* <p>
* Note that <code>forUpdate()</code> is the same as
* <code>withLock(LockType.UPDATE)</code>.
* <p>
* Provides us with the ability to explicitly use Postgres
* SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks.
*/
Query<T> withLock(LockType lockType);
/**
* Execute the query with the given lock type and lock wait.
* <p>
* Note that <code>forUpdateNoWait()</code> is the same as
* <code>withLock(LockType.UPDATE, LockWait.NOWAIT)</code>.
* <p>
* Provides us with the ability to explicitly use Postgres
* SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks.
*/
Query<T> withLock(LockType lockType, LockWait lockWait);
/**
* Execute using "for update" clause which results in the DB locking the record.
* <p>
* The same as <code>withLock(LockType.UPDATE, LockWait.WAIT)</code>.
*/
Query<T> forUpdate();
@@ -1622,7 +1677,8 @@ public interface Query<T> {
* Execute using "for update" clause with "no wait" option.
* <p>
* This is typically a Postgres and Oracle only option at this stage.
* </p>
* <p>
* The same as <code>withLock(LockType.UPDATE, LockWait.NOWAIT)</code>.
*/
Query<T> forUpdateNoWait();
@@ -1630,7 +1686,8 @@ public interface Query<T> {
* Execute using "for update" clause with "skip locked" option.
* <p>
* This is typically a Postgres and Oracle only option at this stage.
* </p>
* <p>
* The same as <code>withLock(LockType.UPDATE, LockWait.SKIPLOCKED)</code>.
*/
Query<T> forUpdateSkipLocked();
@@ -1640,9 +1697,14 @@ public interface Query<T> {
boolean isForUpdate();
/**
* Return the "for update" mode to use.
* Return the "for update" wait mode to use.
*/
ForUpdate getForUpdateMode();
LockWait getForUpdateLockWait();
/**
* Return the lock type (strength) to use with "for update".
*/
LockType getForUpdateLockType();
/**
* Set root table alias.
@@ -41,14 +41,14 @@ package io.ebean;
* <h3>Example OrderAggregate</h3>
* <pre>{@code
* ...
* // Sql indicates to that this bean
* // @Sql indicates to that this bean
* // is based on RawSql rather than a table
*
* Entity
* Sql
* @Entity
* @Sql
* public class OrderAggregate {
*
* OneToOne
* @OneToOne
* Order order;
*
* Double totalAmount;
@@ -107,7 +107,7 @@ package io.ebean;
*
* List<OrderAggregate> orders = DB.find(OrderAggregate.class)
* .setRawSql(rawSql)
* .fetch("order", "status,orderDate", new FetchConfig().query())
* .fetch("order", "status,orderDate", FetchConfig.ofQuery())
* .fetch("order.customer", "name")
* .where().gt("order.id", 0)
* .having().gt("totalAmount", 20)
@@ -22,7 +22,7 @@ import java.sql.SQLException;
* //
* class CustomerMapper implements RowMapper<CustomerDto> {
*
* Override
* @Override
* public CustomerDto map(ResultSet rset, int rowNum) throws SQLException {
*
* long id = rset.getLong(1);
@@ -2,8 +2,8 @@ package io.ebean;
import io.ebean.annotation.DocStoreMode;
import io.ebean.annotation.PersistBatch;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.DocStoreConfig;
import io.ebean.config.ServerConfig;
import javax.persistence.PersistenceException;
import java.sql.Connection;
@@ -226,7 +226,7 @@ public interface Transaction extends AutoCloseable {
/**
* Set if the L2 cache should be skipped for "find by id" and "find by natural key" queries.
* <p>
* By default {@link ServerConfig#isSkipCacheAfterWrite()} is true and that means that for
* By default {@link DatabaseConfig#isSkipCacheAfterWrite()} is true and that means that for
* "find by id" and "find by natural key" queries which normally hit L2 bean cache automatically
* - will not do so after a persist/write on the transaction.
* </p>
@@ -235,7 +235,7 @@ public interface Transaction extends AutoCloseable {
* will skip the L2 bean cache or not (regardless of whether the transaction is considered "read only").
* </p>
* <p>
* Refer to {@link ServerConfig#setSkipCacheAfterWrite(boolean)} for configuring the default behavior
* Refer to {@link DatabaseConfig#setSkipCacheAfterWrite(boolean)} for configuring the default behavior
* for using the L2 bean cache in transactions spanning multiple query/persist requests.
* </p>
*
@@ -276,7 +276,7 @@ public interface Transaction extends AutoCloseable {
*
* }</pre>
*
* @see ServerConfig#isSkipCacheAfterWrite()
* @see DatabaseConfig#isSkipCacheAfterWrite()
*/
void setSkipCache(boolean skipCache);
@@ -402,7 +402,7 @@ public interface Transaction extends AutoCloseable {
* </p>
*
* @param batchMode the batch mode to use per save(), insert(), update() or delete()
* @see io.ebean.config.ServerConfig#setPersistBatchOnCascade(PersistBatch)
* @see io.ebean.config.DatabaseConfig#setPersistBatchOnCascade(PersistBatch)
*/
void setBatchOnCascade(boolean batchMode);
@@ -519,11 +519,11 @@ public interface Transaction extends AutoCloseable {
void flush() throws PersistenceException;
/**
* This is a synonym for flush() and will be deprecated.
* Deprecated - migrate to flush().
* <p>
* flush() is preferred as it matches the JPA flush() method.
* </p>
*/
@Deprecated
void flushBatch() throws PersistenceException;
/**
@@ -13,23 +13,23 @@ package io.ebean;
* </p>
* <pre>{@code
* ...
* NamedUpdates(value = {
* NamedUpdate(
* @NamedUpdates(value = {
* @NamedUpdate(
* name = "setTitle",
* notifyCache = false,
* update = "update topic set title = :title, postCount = :count where id = :id"),
* NamedUpdate(
* @NamedUpdate(
* name = "setPostCount",
* notifyCache = false,
* update = "update f_topic set post_count = :postCount where id = :id"),
* NamedUpdate(
* @NamedUpdate(
* name = "incrementPostCount",
* notifyCache = false,
* update = "update Topic set postCount = postCount + 1 where id = :id")
* //update = "update f_topic set post_count = post_count + 1 where id = :id")
* })
* Entity
* Table(name = "f_topic")
* @Entity
* @Table(name = "f_topic")
* public class Topic {
* ...
* }
@@ -1,5 +1,7 @@
package io.ebean.bean;
import java.util.concurrent.locks.Lock;
/**
* Loads a entity bean.
* <p>
@@ -18,4 +20,9 @@ public interface BeanLoader {
*/
void loadBean(EntityBeanIntercept ebi);
/**
* Obtain a lock on the loader.
*/
Lock lock();
}
@@ -14,6 +14,8 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* This is the object added to every entity bean using byte code enhancement.
@@ -30,6 +32,8 @@ public final class EntityBeanIntercept implements Serializable {
private static final int STATE_REFERENCE = 1;
private static final int STATE_LOADED = 2;
private transient final ReentrantLock lock = new ReentrantLock();
private transient NodeUsageCollector nodeUsageCollector;
private transient PersistenceContext persistenceContext;
@@ -803,7 +807,8 @@ public final class EntityBeanIntercept implements Serializable {
* Load the bean when it is a reference.
*/
protected void loadBean(int loadProperty) {
synchronized (this) {
lock.lock();
try {
if (beanLoader == null) {
final Database database = DB.byName(ebeanServerName);
if (database == null) {
@@ -811,14 +816,19 @@ public final class EntityBeanIntercept implements Serializable {
}
// For stand alone reference bean or after deserialisation lazy load
// using the ebeanServer. Synchronise only on the bean.
loadBeanInternal(loadProperty, database.getPluginApi());
loadBeanInternal(loadProperty, database.getPluginApi().beanLoader());
return;
}
} finally {
lock.unlock();
}
synchronized (beanLoader) {
final Lock lock = beanLoader.lock();
try {
// Lazy loading using LoadBeanContext which supports batch loading
// Synchronise on the beanLoader (a 'node' of the LoadBeanContext 'tree')
loadBeanInternal(loadProperty, beanLoader);
} finally {
lock.unlock();
}
}
@@ -921,10 +931,14 @@ public final class EntityBeanIntercept implements Serializable {
* OneToMany and ManyToMany only set loaded state.
*/
public void preSetterMany(boolean interceptField, int propertyIndex, Object oldValue, Object newValue) {
if (readOnly) {
throw new IllegalStateException("This bean is readOnly");
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else {
if (readOnly) {
throw new IllegalStateException("This bean is readOnly");
}
setChangedProperty(propertyIndex);
}
setLoadedProperty(propertyIndex);
}
private void setChangedPropertyValue(int propertyIndex, boolean setDirtyState, Object origValue) {
@@ -2,11 +2,16 @@ package io.ebean.bean;
import io.ebean.Database;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* BeanLoader used when single beans are loaded (which is usually not ideal / N+1).
*/
public abstract class SingleBeanLoader implements BeanLoader {
private final ReentrantLock lock = new ReentrantLock();
protected final Database database;
SingleBeanLoader(Database database) {
@@ -18,6 +23,12 @@ public abstract class SingleBeanLoader implements BeanLoader {
return database.getName();
}
@Override
public Lock lock() {
lock.lock();
return lock;
}
/**
* Single bean lazy loaded when bean from L2 cache.
*/
@@ -45,4 +56,18 @@ public abstract class SingleBeanLoader implements BeanLoader {
database.getPluginApi().loadBeanRef(ebi);
}
}
/**
* Single bean lazy loaded when a reference bean.
*/
public static class Dflt extends SingleBeanLoader {
public Dflt(Database database) {
super(database);
}
@Override
public void loadBean(EntityBeanIntercept ebi) {
database.getPluginApi().loadBean(ebi);
}
}
}

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