Compare commits

...
Author SHA1 Message Date
rbygrave 3c6d17c9a5 [maven-release-plugin] prepare release ebean-parent-12.11.1 2021-08-16 09:23:11 +12:00
rbygrave 885ba0fdd2 Set autoReleaseAfterClose true 2021-08-16 09:18:31 +12:00
rbygrave f3b0e34b67 #2315 - Refactor internals - make more classes final in transaction packages 2021-08-16 09:16:31 +12:00
rbygrave 4109fab0d8 #2313 - Refactor internals - make more classes final in query packages 2021-08-15 15:22:02 +12:00
rbygrave 0688061f5c Speed up TestUuidGenerator 2021-08-15 15:17:19 +12:00
rbygrave 82c12b1565 #2312 - Refactor internals - make more classes final in persist packages 2021-08-15 14:50:43 +12:00
rbygrave ebc0fabbdb #2311 - Fix BindPadding for empty list 2021-08-15 14:15:03 +12:00
rbygrave 587b2e3075 #2310 Tidy to only cast once 2021-08-15 14:09:44 +12:00
Rob BygraveandGitHub ec82dd3da9 Merge pull request #2310 from FOCONIS/nutation-on-cache
FIX: mutation info is not restored on cache hit
2021-08-15 13:50:19 +12:00
rbygrave 3e190b34f5 Merge branch 'master' of github.com:ebean-orm/ebean 2021-08-15 13:48:43 +12:00
rbygrave e059ad9172 Merge branch 'FOCONIS-mutationdetection-source-special-json-types' 2021-08-15 13:48:27 +12:00
rbygrave 1297324fa9 Fix where using JDK 10 Reader.transferTo() method plus add final to methods and classes 2021-08-15 13:47:46 +12:00
rbygrave e2b7434d98 Merge branch 'mutationdetection-source-special-json-types' of https://github.com/FOCONIS/ebean into FOCONIS-mutationdetection-source-special-json-types 2021-08-15 12:06:12 +12:00
rbygrave ada8df5755 Improve startup logging messages 2021-08-15 12:05:30 +12:00
Roland Praml 843b90cbba FIX: mutation info is not restored on cache hit 2021-08-13 11:52:31 +02:00
Roland Praml 6b263919d5 handle also JsonNode 2021-08-13 11:19:24 +02:00
Roland Praml 965c1e803f FIX: mutationDetection = SOURCE works also for special json types 2021-08-13 10:47:14 +02:00
Rob BygraveandGitHub a13bc481b8 Merge pull request #2306 from FOCONIS/pr/enh/softreference_in_cache
Use SoftReferences in Cache
2021-08-13 09:35:38 +12:00
rbygrave fc7379aabc Tidy internals - server.persist.dml package for whitespace and typos 2021-08-13 09:18:31 +12:00
rbygrave a17683c549 #2307 - Tidy ShutdownManager DatabaseFactory only 2021-08-12 16:32:12 +12:00
rbygrave eeacad0fb9 #2307 - ENH: Add DatabaseFactory.disableShutdownHook() ... [ alias for ShutdownManager.deregisterShutdownHook() ] 2021-08-12 14:36:14 +12:00
rbygrave c51140b59a Add DefaultServer.toString() and tidy DbOffline remove unnecessary log message 2021-08-12 13:01:07 +12:00
Jonas Pöhler f1817a0dbb Merge remote-tracking branch 'ebean/master' into pr/enh/softreference_in_cache 2021-08-11 15:26:42 +02:00
Jonas Pöhler 5b05510bb9 Merge remote-tracking branch 'ebean/master' into pr/enh/softreference_in_cache 2021-08-11 14:08:55 +02:00
rbygrave b676476cd2 Add SpiQuery.Type.defaultSelect() for ATTRIBUTE and sub-query type queries 2021-08-11 20:51:46 +12:00
rbygrave 709f8ed05f Merge branch 'master' of github.com:ebean-orm/ebean 2021-08-11 20:21:26 +12:00
rbygrave 31282416d8 Merge branch 'FOCONIS-subquery-with-fetch-path' 2021-08-11 20:16:33 +12:00
Rob BygraveandGitHub 385c84ae6f Merge pull request #2302 from FOCONIS/feature/switch-db2-driver
Switch DB2 driver to the publicly available JCC driver
2021-08-11 19:43:09 +12:00
Roland Praml 2d24020202 Added / enhanced test case 2021-08-11 09:32:21 +02:00
Roland Praml 1a2aba3f56 Distinguish between exists and in subquery 2021-08-11 08:54:40 +02:00
Thomas Fellner f50f0192d1 Switch DB2 driver to the publicly available JCC driver 2021-08-11 08:47:49 +02:00
Roland Praml 12b8b4b955 Merge remote-tracking branch 'upstream/master' into subquery-with-fetch-path 2021-08-11 07:42:11 +02:00
rbygrave c267366578 Refactor tidy internals - aList -> expr in for loops etc. No functional change. 2021-08-11 15:32:54 +12:00
Rob BygraveandGitHub 18e49cc1ce Merge pull request #2300 from FOCONIS/exists-with-dynamic
Enables select + exists for dynamic formula properties
2021-08-11 14:01:46 +12:00
Rob BygraveandGitHub 1ce4b1a994 Merge pull request #2299 from FOCONIS/push-pops-in-wrong-order
PushJson/PopJson did not work correctly, if null beans were involved
2021-08-11 13:48:00 +12:00
Rob BygraveandGitHub f3c87e488a Merge pull request #2301 from FOCONIS/bugfix/update-ddl-generator-version
Updating ebean-ddl-generator version in ebean-core
2021-08-11 13:46:19 +12:00
Rob BygraveandGitHub f24c698cd5 Merge pull request #2298 from ebean-orm/FOCONIS-md5-for-querybindhash
Foconis md5 for querybindhash
2021-08-11 13:29:44 +12:00
rbygrave 144a3b54bb Refactor rename method queryBindHash() to queryBindKey() 2021-08-11 13:25:04 +12:00
rbygrave ec7c7048db Refactor rename BindHash to BindValuesKey 2021-08-11 13:19:44 +12:00
rbygrave fd2e542c0b Change BindHash from interface to implementation, Delete unused server persist BindValues 2021-08-11 12:43:58 +12:00
rbygrave 11e8e3696f BindParams does not need encryptionKey in equals/hashCode 2021-08-11 12:24:36 +12:00
Thomas Fellner d08f7af1e0 update ebean-ddl-generator version in ebean-core 2021-08-10 18:31:02 +02:00
Roland Praml 60dfaab22c Enables select + exists for dynamic formula properties 2021-08-10 15:29:10 +02:00
Roland Praml 75fa7cb7fd PushJson/PopJson did not work correctly, if null beans were involved 2021-08-10 13:24:13 +02:00
rbygrave e47b1737a8 Add HashCodeBindHashTest 2021-08-10 22:28:31 +12:00
rbygrave e1ad210bb0 Tidy JunctionExpression 2021-08-10 22:18:33 +12:00
rbygrave ac3edbedf4 Remove MdBindHash, tidy DefaultOrmQuery 2021-08-10 22:07:48 +12:00
rbygrave 2dc48cf08d ArrayContainsExpression equals() to use enhanced for loop 2021-08-10 22:00:46 +12:00
rbygrave ede1ad0a4c Fix BindParams equals() and hashCode() 2021-08-10 21:58:41 +12:00
rbygrave 3e8f76cd6d Update HashCodeBindHash to use values for equals() 2021-08-10 21:49:31 +12:00
rbygrave cd6df2be39 Merge branch 'md5-for-querybindhash' of https://github.com/FOCONIS/ebean into FOCONIS-md5-for-querybindhash 2021-08-10 21:18:43 +12:00
Rob BygraveandGitHub 7091e972fc Merge pull request #2297 from FOCONIS/fix-mutable-next-changelog
FIX: Changelog-oldValue did not work for Json mutable properties
2021-08-10 21:10:15 +12:00
Roland Praml c8ae3c5ef6 FIX: Changelog-oldValue did not work for Json mutable properties 2021-08-10 09:30:25 +02:00
Rob BygraveandGitHub 54e8c4df8a Merge pull request #2296 from FOCONIS/fix-test-for-java-8
Fix the test to run with java 8
2021-08-10 17:04:14 +12:00
Roland Praml e18c190905 Fix the test to run with java 8 2021-08-09 09:46:49 +02:00
Roland Praml 181dc73d39 Use MD5 for QueryBindHash 2021-08-09 09:19:53 +02:00
rbygrave 7ed2de9178 Update github issue template 2021-08-09 16:57:43 +12:00
rbygrave 8c101fd0a4 #2268 - Feature request/question: Query execution time for debugging 2021-08-09 16:48:59 +12:00
rbygrave 43213ead05 #2291 - ENH: Explicit option for fast-failing or not fast-failing (skipDataSourceCheck config option) 2021-08-09 15:10:59 +12:00
Rob BygraveandGitHub 0ef5c65c94 Merge pull request #2294 from ebean-orm/feature/metric-hash-2
#2293 - Metric hash back to MD5 of sql + name + loc (minus location file and line source) ~= Revert of #2288
2021-08-09 14:49:17 +12:00
rbygrave c610f95b2d #2293 - Metric hash back to MD5 of sql + name + loc (minus location file and line source) ~= Revert of #2288 2021-08-09 14:05:10 +12:00
rbygrave c4484c758e [maven-release-plugin] prepare for next development iteration 2021-08-06 14:56:15 +12:00
rbygrave ee615836ba [maven-release-plugin] prepare release ebean-parent-12.11.0 2021-08-06 14:56:09 +12:00
rbygrave fea7de42d5 #2290 - Add MetaTimedMetric locationHash() which is a crc32 checksum of package + type + method (excludes line number) 2021-08-06 14:48:42 +12:00
Rob BygraveandGitHub 4787303160 Merge pull request #2289 from ebean-orm/feature/meta-api
Refactor io.ebean.meta API, method rename with deprecation
2021-08-06 13:17:08 +12:00
rbygrave 801d419f51 Refactor io.ebean.meta API, method rename with deprecation 2021-08-06 13:14:29 +12:00
Rob BygraveandGitHub 3579557200 Merge pull request #2288 from ebean-orm/feature/sql-hash
Change query metric hash from MD5 of sql + name + loc to Checksum of sql (+ rename to sqlHash)
2021-08-06 12:52:42 +12:00
rbygrave 202d785710 Rename hash to sqlHash to better reflect what it is (CRC32 checksum of the sql) 2021-08-06 12:06:43 +12:00
rbygrave 7ca72a39b1 Change query metric hash from MD5 of sql + name + loc to Checksum of sql 2021-08-06 11:52:38 +12:00
rbygrave f34e0f5f2b #2287 - ebean-migration: For multiple platforms automatically run the correct migrations 2021-08-05 23:03:02 +12:00
rbygrave d98a31fa6b Bump to 12.11.0-SNAPSHOT 2021-08-05 16:53:51 +12:00
rbygrave 9a82dbb3e6 Bump parent to java8-oss 3.2 with GPG maven plugin active only with "release" profile
The GPG maven plugin is now only active with the "release" profile
use -P release when we want to release with GPG signing
2021-08-05 13:17:32 +12:00
rbygrave a76442641b Tidy test only - rename ServerConfigTest to DatabaseConfigTest and tidy 2021-08-05 13:14:00 +12:00
rbygrave 2043fdf7e1 #2274 Add DatabaseConfig jsonMutationDetection property setting the global default mode 2021-08-05 13:12:18 +12:00
rbygrave a06f7bea41 Tidy javadoc for MutableValueInfo 2021-08-05 12:55:42 +12:00
rbygrave db34afe867 #2284 - ENH: ddl-generator - add optional generation of idx_<platform>.migrations file 2021-08-03 00:03:02 +12:00
rbygrave 589ee7a5ea #2284 - ENH: ddl-generator - add optional generation of idx_<platform>.migrations file 2021-08-02 23:59:49 +12:00
rbygrave 4ba26ee7b7 #2283 - ddl-generator - Refactor tidy DefaultDbMigration etc 2021-08-02 20:49:30 +12:00
rbygrave 71223895ac #2283 - ddl-generator - Refactor tidy whitespace etc 2021-08-02 20:38:05 +12:00
rbygrave 928b90122f #2283 - ddl-generator - Add DbMigration.addPlatform(Platform) with default sub-directory based on Platform 2021-08-02 20:15:51 +12:00
rbygrave d601a88d82 #2278 - Move null to empty json collections check to BeanPropertyJsonBasic 2021-07-30 23:53:28 +12:00
rbygrave 443e826f61 #2278 - Embedded bean override with DbJson property 2021-07-30 23:22:06 +12:00
rbygrave 2691221168 #2278 - Do not override empty json collections, when database value is null 2021-07-30 22:53:51 +12:00
rbygrave e62bb3dc6b Merge branch 'pr/bugfix/null_to_empty_json_collection' of https://github.com/FOCONIS/ebean into FOCONIS-pr/bugfix/null_to_empty_json_collection 2021-07-30 22:51:40 +12:00
Rob BygraveandGitHub 604099429e Merge pull request #2282 from ebean-orm/feature/json-mutable-collections
Treat json Jackson collections the same wrt mutation detection
2021-07-30 21:15:04 +12:00
Rob BygraveandGitHub 11dc7f64ba Merge pull request #2274 from ebean-orm/feature/json-dirty-detection-md5
Add support for JSON bean mutation detection via HASH and SOURCE of JSON string content
2021-07-30 21:11:42 +12:00
rbygrave ceea705a76 Treat json Jackson collections the same wrt mutation detection 2021-07-30 20:20:03 +12:00
rbygrave d9f7531e81 Tidy tests only - TestDbJson_Jackson3 TestJacksonPlainBean 2021-07-30 17:26:46 +12:00
rbygrave 7bd7640c63 Update test TestDbJson_Jackson3 showing HASH mode is used even on ModifyAwareType 2021-07-30 17:18:28 +12:00
rbygrave ca1636ff9e Fix when json/jackson bean inserted as null and not changed
Expectation is that it is not included in update (still null, no change)
2021-07-30 17:16:05 +12:00
rbygrave ea741d0169 Update TestDbJson_Jackson3 with comments 2021-07-30 15:41:52 +12:00
rbygrave c43e2e6956 Update TestDbJson_Jackson3 2021-07-30 15:34:54 +12:00
rbygrave 03004452ac ebean.mf set back to synthetic: true 2021-07-30 14:53:32 +12:00
rbygrave a470877017 Update kotlin-querybean-generator pom to make kotlin in IntelliJ happy 2021-07-30 14:52:49 +12:00
rbygrave 777d322222 #2279 - Remove _ebean_getMarker() from EntityBean interface - not actually required 2021-07-30 14:51:38 +12:00
Jonas Pöhler 1f0ac1f1c1 ADD: Testcases for List and Map as well 2021-07-29 16:50:08 +02:00
Jonas Pöhler (JPo) 1fad6e910c FIX: do not override empty (json) collections with null
Original: https://github.com/ebean-orm/ebean/commit/5551c35ec2496a9d62ab0afcaecbed739f17aa7c
Signed-off-by: Jonas Pöhler (JPo) <jonas.poehler@foconis.de>
2021-07-29 15:53:44 +02:00
rbygrave 822fb7325a Due to mutableNext handling, with checkMutableProperties() even when known dirty go into beanProperty.checkMutable()
As per rPraml's PR and comment

Due to handling of mutableNext we need  checkMutableProperties() to call into what is now beanProperty.checkMutable() even when we already know it's dirty.
2021-07-29 23:37:29 +12:00
rbygrave 20e0eb1021 Re-enable TestDbJson_Jackson3 via adding mutationDetection = HASH to beanList property
@DbJsonB(mutationDetection = HASH)
  List<PlainBean> beanList;
2021-07-29 23:17:11 +12:00
rbygrave 20becf951d Use MutationDetection replacing dirtyDetection and keepSource
Also adds NoMutationDetection to support NONE
2021-07-29 23:11:42 +12:00
rbygrave 5aa8557168 Update tests only - TestJacksonPlainBean with dirtyDetection = false property 2021-07-29 16:29:10 +12:00
rbygrave c66d248e96 Add MutableValueNext to replace mutableContent such that hash compute is only done once
Adds MutableValueInfo.nextDirty() to replace the isEqualToJson() method. The next is computed once and stored. BindablePropertyJsonUpdate makes the .mutableNext(propertyIndex) call to move the next MutableValueInfo and return the json content.
2021-07-29 15:42:16 +12:00
rbygrave 0d8e7c852b Change Checksum to use CRC32 2021-07-29 15:32:06 +12:00
rbygrave 991c6d6b5c No effective change - tidy FactoryProperty 2021-07-29 13:30:15 +12:00
rbygrave 2bc5d3d325 Refactor rename MutableHash to MutableValueInfo (and subsequent rename on methods etc) 2021-07-29 13:20:30 +12:00
rbygrave 5ad8e7ead4 Use new @DbJson dirtyDetection and keepSource attributes
- Bump ebean-annotation with new @DbJson dirtyDetection and keepSource attributes
- Get those to BeanPropertyJsonMapper to chose MutableHash implementation
- Modify MD5MutableHash to include check for isDirty()
- EBasicJsonList needs keepSource=true to pass that test with oldValue
2021-07-29 12:47:10 +12:00
rbygrave 8832bbc57f No effective change - format EntityBeanIntercept only
Plus adjust timing on SqlQueryCancelTest
2021-07-29 12:43:37 +12:00
rbygrave 86483ff947 Use scalarType.format(value) removing scalarType.jsonMapper(value)
Remove scalarType.jsonMapper(value) as we can just use format(value) instead
2021-07-29 11:52:15 +12:00
rbygrave 92d7a7562f Tidy only - no functional change to MutableHash and BeanPropertyJsonMapper 2021-07-29 11:49:01 +12:00
rbygrave 52fe3cf3c8 Change from MD5 to Checksum (Adler32) for json content dirty detection 2021-07-29 11:40:05 +12:00
rbygrave 94fb6414fa Refactor move createMutableHash() method from ScalarType to BeanProperty / BeanPropertyJsonMapper 2021-07-29 11:28:25 +12:00
rbygrave d0270dbc6a Temporarily disable TestDbJson_Jackson3 updateIncludesJsonColumn_when_list_loadedAndNotDirtyAware()
BeanState state = DB.getBeanState(found);
    assertThat(state.getChangedProps()).containsExactlyInAnyOrder("beanList");
    // this test fails, because we have a OmList instead of a GenericObject
    // TODO: Can/Should we enhance the @DbJson/@DbJsonB annotations with a property "dirtyDetection"
2021-07-29 11:21:38 +12:00
rbygrave 11a047bf8e Merge branch 'FOCONIS-feature/json-dirty-detection-md5' into feature/json-dirty-detection-md5 2021-07-29 10:27:28 +12:00
Roland Praml eb70c7e196 some javadoc and refactored getOrigValue 2021-07-28 17:36:53 +02:00
Roland Praml b497b8635b some refactor and tidying 2021-07-28 17:22:29 +02:00
Roland Praml 5e595ec5f8 Proof of concept to support also bean change detection / changelog on mutable properties 2021-07-28 14:54:56 +02:00
rbygrave 49b86d07d3 Modify SqlBeanLoad to use readSet()
Note that we don't need to use readSetIntercept() now as there is no property change listener support
2021-07-28 22:48:29 +12:00
rbygrave 11eed4cfe9 Add BeanPropertyJsonMapper for JSON dirty detection 2021-07-28 21:43:57 +12:00
rbygrave 4aef0ad459 #2275 - Change Query<?> to Query<T> on ExtendedServer exists() method 2021-07-28 17:23:37 +12:00
Rob BygraveandGitHub 21cd74d0ca Merge pull request #2273 from ebean-orm/feature/2272
#2272 Fix for collection with orphanRemoval (such that equals/hashCode isn't use)
2021-07-28 17:14:09 +12:00
rbygrave 6c262f1df5 JSON bean dirty detection via MD5 of JSON string content
- MD5 of json content stored on EntityBeanIntercept for dirty detection
- Only convert to JSON once (at dirty detection time). Store this json content on EntityBeanIntercept to later push to ScalarTypeJsonObjectMapper for bind

Should consider alternative to extend BeanProperty rather than have these if blocks.
2021-07-23 16:50:24 +12:00
rbygrave f32ace4e5a Refactor EntityBeanIntercept replacing owner._ebean_getPropertyNames().length with flags.length 2021-07-23 13:54:29 +12:00
rbygrave e54b7052e0 #2272 Fix for collection with orphanRemoval (such that equals/hashCode isn't use)
- Changes ModifyHolder to use IdentityHashMap such that equals/hashcode isn't invoked
- Change SaveManyBeans such that M2M intersection deletes execute before inserts

The SaveManyBeans change is required to pass TestM2MModifyTest. With that test we get a delete/insert pair that we somewhat expect because we clear() the collection. Previously equals/hashCode meant we didn't get that delete/insert pair.

The test changes from containsExactly() to containsOnly() as we now can't guarantee the ordering with IdentityHashMap.
2021-07-23 12:18:06 +12:00
rbygrave b40d448955 #2272 No effective change, tidy test TestM2MModifyTest only
Noting that this test fails with the fix for 2272 as M2M intersection deletes are currently executed after inserts. We need a fix to SaveManyBeans to change that so that deletes to intersection table execute after inserts.
2021-07-23 12:01:36 +12:00
rbygrave 33bccd3bcb [maven-release-plugin] prepare for next development iteration 2021-07-22 19:03:54 +12:00
rbygrave 705e4f4098 [maven-release-plugin] prepare release ebean-parent-12.10.0 2021-07-22 19:03:43 +12:00
rbygrave 1642833fdb Improve javadoc on TQRootBean and generated javadoc on query bean forFetchGroup() method 2021-07-22 18:56:02 +12:00
rbygrave 492bb98e0e #2269 - findSingleAttributeList does not filter soft-deleted record 2021-07-22 17:12:06 +12:00
rbygrave a8456f90db Bump ebean-agent version to 2.10.0 2021-07-22 16:46:57 +12:00
Rob BygraveandGitHub 103b75172d Merge pull request #2267 from FOCONIS/pr/bugfix/connection_closed_on_clob
Retrieve (C|B)LOB on SqlRow construction
2021-07-22 16:44:05 +12:00
rbygrave 0baa3a0eac #2270 - ebean-agent enhancement NPE with MappedSuperclass with no properties that uses named database 2021-07-22 16:38:28 +12:00
rbygrave f26e4b5381 Bump jedis to 3.6.3 (from 3.6.1) 2021-07-22 12:37:42 +12:00
Jonas Pöhler 60ef87b269 Merge remote-tracking branch 'ebean/master' into pr/enh/softreference_in_cache 2021-07-16 15:29:33 +02:00
Jonas Pöhler 3d4de4dee5 FIX TestRawSqlService and TestRawSqlBuilder 2021-07-16 15:17:04 +02:00
Jonas Pöhler c621435a28 Merge remote-tracking branch 'ebean/master' into pr/bugfix/connection_closed_on_clob 2021-07-16 13:32:24 +02:00
rbygrave 7408483a43 #2264 - Use of default timezone for OffsetDateTime offsets problematic for unit tests and presentation layer 2021-07-15 17:14:22 +12:00
Roland Praml 7e265f7bde FIX: SubQuery with fetch-path does not work correctly 2021-07-13 09:09:30 +02:00
rbygrave 4d15535381 No functional change - tidy DefaultDbSqlContext 2021-07-13 16:48:45 +12:00
Rob BygraveandGitHub 787c2f90f2 Merge pull request #2188 from FOCONIS/fix-order-by
FIX: orderBy does not work when used on formula property
2021-07-13 16:41:33 +12:00
Rob BygraveandGitHub e590a2149d Merge pull request #2257 from FOCONIS/queries-are-cancelable
Queries are cancelable
2021-07-13 16:11:36 +12:00
rbygrave 8c77740aa7 Bump version tp 12.10.0-SNAPSHOT (with 12.9.4-RC1 ddl generator) 2021-07-13 15:48:10 +12:00
Rob BygraveandGitHub 29582b57f7 Merge pull request #2256 from FOCONIS/many-where-support
Improved @Where support, especially for Many-to-many tables
2021-07-13 15:01:49 +12:00
rbygrave 2763f333d4 #2262 - Tidy tests for Transaction postCommit Callback 2021-07-13 14:48:40 +12:00
rbygrave 8840628d34 #2262 - Transaction postCommit Callback not invoked when the active transaction has no database writes 2021-07-13 14:45:48 +12:00
rbygrave 6fb28d7ded #2255 Specific test for setParameter cannot assigning the value when parameter in selecting section of query 2021-07-13 12:54:21 +12:00
rbygrave be810aa568 [maven-release-plugin] prepare for next development iteration 2021-07-13 12:16:12 +12:00
rbygrave 8a698bd71e [maven-release-plugin] prepare release ebean-parent-12.9.3 2021-07-13 12:16:01 +12:00
rbygrave baa0594501 Change ebean-test tests to use H2 rather than mariadb 2021-07-13 12:10:23 +12:00
rbygrave e82b8c80f0 #2265 - ArrayIndexOutOfBoundsException: Index -1 out of bounds with @IdClass and batch insert accessing id property 2021-07-13 11:30:31 +12:00
Rob BygraveandGitHub f8e54be9a6 Merge pull request #2260 from casmir/master
Fix additional autotune runtimeExceptions due to toString() calls instead of asString()
2021-07-01 13:05:17 +12:00
Cas de Graaf d3137be984 in addition to #2236
- autotune still throws RunTimeException due to existing
 ORMQueryDetail.toString() calls, replaced with .asString()
2021-06-30 16:23:20 +02:00
Roland Praml 824cfa27be Queries are cancelable 2021-06-23 17:11:21 +02:00
Roland Praml 66cb6d5e7d Imporved @Where support, especially for Many-to-many tables 2021-06-21 14:50:15 +02:00
rbygrave 8f432aa0a9 #2251 - Transparent persistence of to-many associations (with orphanRemoval) 2021-06-18 16:05:25 +12:00
rbygrave 4aa4137abe Merge branch 'transparent_persistence' of https://github.com/cit-consulting/ebean into cit-consulting-transparent_persistence 2021-06-18 13:03:36 +12:00
rbygrave f4bb4e1b6a #2254 - OraclePlatform needs columnAliasPrefix 'c' - Regression in version 12.2.1 due to #1967 2021-06-18 12:37:16 +12:00
rbygrave 7af4e166a4 #2253 - Incorrect JSON format for LocalDateTime. Includes Z suffix when it should not. 2021-06-17 13:26:34 +12:00
Vladimir Konkov 1fa488d870 Test for transparent persistence of to-many associations 2021-06-14 16:20:25 +03:00
rbygrave 37a3a51b6b Bump test dependency for Postgres JDBC driver 2021-06-14 11:09:37 +12:00
rbygrave 6a6e8f906f Bump jedis dependency to 3.6.1 (from 3.6.0) 2021-06-14 11:09:13 +12:00
rbygrave 55bc498f9d No functional change - refactor QueryIterator to use Iterator.remove()
default method

Iterator.remove() has a default implementation that throws UnsupportedOperationException which is what we want. Remove the close() method from QueryIterator and implementations so that we just use the Iterator.remove() default implementation.
2021-06-11 10:20:47 +12:00
rbygrave 4ee784c68f [maven-release-plugin] prepare for next development iteration 2021-06-11 00:41:06 +12:00
rbygrave fc757c087a [maven-release-plugin] prepare release ebean-parent-12.9.2 2021-06-11 00:40:55 +12:00
rbygrave 884dd939b7 #2249 - Bug with DbJson Jackson property that is null is updated as null (unnecessarily included in update)
When the value is null and not changed then is was null before and should not be treated as dirty. Hence only check for dirty when value != null in BeanDescriptor 3182
2021-06-11 00:19:20 +12:00
Rob BygraveandGitHub 6fd2f556db Merge pull request #2248 from ebean-orm/feature/DbJson-DirtyDetection-Refactor
Refactor DbJson Jackson handling adding DatabaseConfig.setJsonDirtyByDefault()
2021-06-11 00:10:37 +12:00
rbygrave 4e088a40d9 Refactor DbJson Jackson handling adding DatabaseConfig.setJsonDirtyByDefault()
Adds the ability to change the default "jsonDirtyByDefault" configuration setting used with DbJson Jackson properties. Currently these default to being assumed dirty and this allows us to change that to be assumed not dirty (which is very likely the better default).
2021-06-11 00:08:03 +12:00
rbygrave 8ba66af878 Modify test TestQueryDefaultBatchSize to show use of ProfileLocation 2021-06-10 22:11:45 +12:00
rbygrave 441f51ed79 #2247 - Refactor internals - Change DefaultTypeManager - tidy 2021-06-10 20:30:07 +12:00
rbygrave 9ee891dc66 #2247 - Refactor internals - Change DefaultTypeManager from class.newInstance() to class.getDeclaredConstructor().newInstance() 2021-06-10 20:09:34 +12:00
rbygrave 87ffcbf23e No effective change - tidy CQuery 2021-06-10 19:45:27 +12:00
rbygrave adfc54200f No effective change - extract JacksonTypeHelper for ScalarTypeJsonObjectMapper 2021-06-10 19:27:42 +12:00
rbygrave 3c36b43449 No effective change - tidy EntityBeanIntercept 2021-06-10 19:26:56 +12:00
rbygrave 9be1dcff6c Tidy internals ScalarTypeJsonObjectMapper, no functional change 2021-06-10 19:00:35 +12:00
rbygrave 37dff62fa9 #2246 - ENH: Add DtoQuery findStream() and findIterate() 2021-06-10 14:55:31 +12:00
rbygrave 4fd462b1c8 #2244 - ENH: Add SQL Server support for transparent encryption via EncryptByPassPhrase, DecryptByPassPhrase 2021-06-10 13:34:33 +12:00
rbygrave 33ac1923ff No effective change - refactor move Str into server.util package
Allows the removal of io.ebeaninternal.server.lib package as that was the only thing in there.
2021-06-09 23:40:48 +12:00
rbygrave 0b87ae5eac No effective change - tidy BindParams 2021-06-09 23:38:10 +12:00
rbygrave 678743cc10 Use upper case E for class name of generated _Ebean$ModuleInfo 2021-06-09 21:59:19 +12:00
rbygrave c8345ce093 No functional change - refactor internal toStream() to use closure rather than explicit Runnable type for closing the stream
Conceptually javac closure might be better than an extra explicit type here
2021-06-09 16:21:15 +12:00
rbygrave f3af43a9ce Add support for findEach() on SqlQuery with RowMapper and scalar result 2021-06-09 15:49:48 +12:00
rbygrave 1df2ccb1c6 Refactor internals DefaultRelationalQueryEngine remove unnecessary method
- Remove findEach() method that took RowReader<T> and Consumer<T>
- Use findEachRow() instead
2021-06-09 15:19:35 +12:00
rbygrave 3add4472ef Refactor internals DefaultRelationalQueryEngine.findListMapper()
- Remove findListMapper() method
- Introduce RowReader interface
- Combine findList internals for both SqlRow and RowMapper use
2021-06-09 14:58:08 +12:00
rbygrave 4613f63c66 Refactor internals DataReader remove resetColumnPosition()
- Move the reset of position to the DataReader.next() method
- Tidy up use of wasNull() in RsetDataReader
2021-06-09 12:57:56 +12:00
rbygrave 612295fb9d [maven-release-plugin] prepare for next development iteration 2021-06-04 17:59:21 +12:00
rbygrave 64405ade52 [maven-release-plugin] prepare release ebean-parent-12.9.1 2021-06-04 17:59:11 +12:00
rbygrave ce5f1b25f5 Bump ebean-maven-plugin to 12.9.1 2021-06-04 17:50:46 +12:00
rbygrave ae4f50e7b3 #2236 - Auto-tune does not work / throws RuntimeException (Regression from 12.7.1)
Note we are missing a test on ProfileManager but doing this for now.
2021-06-04 17:46:31 +12:00
rbygrave c9120be347 No effective change - tidy only H2HistoryTrigger and H2HistoryDdl 2021-06-04 17:37:37 +12:00
rbygrave b189e67b4c #2241 - Offline DDL migration generation for H2 requires H2 Driver 2021-06-04 17:35:19 +12:00
Rob BygraveandGitHub 5d5c275c79 Merge pull request #2240 from FOCONIS/bugfix/ddl-generator-version
Set ddl-generator version to a public-available version + fix classpath for Java8
2021-06-04 17:24:31 +12:00
rbygrave 52f31a7a8e Merge branch 'bkempe-testSelectOneToOneDisjunction' 2021-06-04 17:17:21 +12:00
rbygrave 6697aecd48 #2238 - Select with disjunction of expressions over OneToOne relationship missing join clause
Noting that there might be a better fix. The addJoin() at line 151 is suppressed as it is a duplicate for this case of a !oneToOneExported so a better fix might be to only add the soft delete clause when the join as actually added (not suppressed as a duplicate).
2021-06-04 17:16:50 +12:00
Jonas Pöhler 348c075a14 FIX: Build for java8 2021-06-01 17:56:47 +02:00
Jonas Pöhler bf2420702c FIX: set ddl-generator version to a repo-available version 2021-06-01 17:19:38 +02:00
Ben Kempe 16832ac67a add test testSelectOneToOneDisjunction 2021-05-24 23:47:55 +02:00
rbygrave 47bd2ff03d [maven-release-plugin] prepare for next development iteration 2021-05-23 23:08:47 +12:00
rbygrave 850f1c1469 [maven-release-plugin] prepare release ebean-parent-12.9.0 2021-05-23 23:08:38 +12:00
rbygrave 622a90c7d5 No effective change - tidy whitespace in TransactionManager 2021-05-23 23:00:34 +12:00
rbygrave 4c317f11ae Add additional test for PrimaryKeyJoinColumn 2021-05-23 22:21:05 +12:00
rbygrave 01bce5cfa6 #2226 - Automatically determining join columns and ignoring PrimaryKeyJoinColumn.name Id warning when I want to use Id as a foreign key
Improve the message and dropping to INFO level.
2021-05-23 22:20:40 +12:00
rbygrave 2158925d3c #2202 - kotlin-maven-plugin issue with JDK 16
InaccessibleObjectException: Unable to make protected void java.util.ResourceBundle.setParent(java.util.ResourceBundle) accessible: module java.base does not "opens java.util" to unnamed module @62732be7
2021-05-23 21:28:11 +12:00
Rob BygraveandGitHub 2aff6403a2 Merge pull request #2235 from ebean-orm/feature/2223
#2223 #2224 Support BeanMap modification via entrySet() and keySet()
2021-05-23 17:20:55 +12:00
rbygrave 3c4d600187 #2223 #2224 Support BeanMap modification via entrySet() and keySet() 2021-05-23 17:17:34 +12:00
Rob BygraveandGitHub f60ccb9b90 Merge pull request #2222 from ebean-orm/feature/support-filterMany-inline
Change such that filterMany can be included in the main query.
2021-05-21 17:20:17 +12:00
rbygrave 2a6108087c Bump version to 12.9.0-SNAPSHOT 2021-05-21 17:18:30 +12:00
rbygrave 0da86a82ae #2233 Bump to ebean-agent 12.9.0 2021-05-21 17:14:49 +12:00
rbygrave 643b0499c4 #2233 Add ebean-version.mf so ebean-agent can sniff the internal version
This allows the ebean-agent to support the older behaviour. Devs using the latest IntelliJ ebean plugin will get the old behaviour unless they bump ebean-core to 12.9 or later.
2021-05-21 16:09:15 +12:00
rbygrave 676bac390e #2233 Followup change that unsets load buffer from BeanCollection
- Clears the buffer after it has been used to load BeanCollection's
- Sets the BeanCollection to use the server rather than the Load Buffer just in case there are subsequent calls for loading (which there should not be)
2021-05-21 09:01:45 +12:00
rbygrave 79740accfa #2233 Fix with setter on ToMany now not invoking lazy loading
- ebean-agent changed to not invoke preGetter on ToMany (just like Id)
- EntityBeanIntercept preSetterMany() changed to ensure loading flag set
2021-05-21 08:48:42 +12:00
rbygrave 77c6f1cb9f #2233 Tidy failing test Ebean -> DB and rename test 2021-05-21 08:44:04 +12:00
rbygrave 538361d5fd #2233 Failing test 2021-05-21 08:33:31 +12:00
rbygrave b17593ba3c No effective change - tidy BeanList, BeanMap, BeanSet internals 2021-05-20 21:44:07 +12:00
rbygrave eb00690b30 #2231 - Change OrderBy to not be final to support mocking via Mockito 2021-05-20 14:09:22 +12:00
Rob BygraveandGitHub a772e65d32 Merge pull request #2225 from ebean-orm/dependabot/maven/ebean-core/commons-io-commons-io-2.7
Bump commons-io from 2.5 to 2.7 in /ebean-core
2021-05-20 13:56:00 +12:00
Brian Payne 66f7f69ec7 Fixed bug with soft-delete on one-to-one exported 2021-05-12 09:24:33 -07:00
Brian Payne ad52711fe1 Add test demonstrating soft-delete bug with optional relationship 2021-05-11 10:42:04 -07:00
dependabot[bot]andGitHub d6fdb4ee34 Bump commons-io from 2.5 to 2.7 in /ebean-core
Bumps commons-io from 2.5 to 2.7.

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-26 20:37:55 +00:00
Jonas Pöhler (JPo) 4977aa2ad1 Merge remote-tracking branch 'ebean/master' into pr/bugfix/connection_closed_on_clob 2021-04-26 14:54:32 +02:00
rbygrave 74c7268d2f Change such that filterMany can be included in the main query.
That is, currently a filterMany automatically marks that path as a fetchQuery path. This change turns that off and the filterMany path and predicates can then be included in the main query.

This is better for performance (to include the filterMany path in with the main query) when the query is a findEach and looking to return a large number of results.
2021-04-21 18:57:03 +12:00
rbygrave 42fc419759 #2221 - ebean-redis: bump jedis dependency to 3.6.0 2021-04-20 22:23:33 +12:00
rbygrave 4fb3b9cddc Tidy use of StringHelper replace() in BeanProperty, BaseTableDdl 2021-04-20 22:13:45 +12:00
Robin Bygrave c60077174e Tidy use of StringHelper replace() in BeanProperty, BaseTableDdl 2021-04-20 15:14:20 +12:00
rbygrave 5e893dd2ad [maven-release-plugin] prepare for next development iteration 2021-04-19 21:40:16 +12:00
rbygrave 9eb54da2dc [maven-release-plugin] prepare release ebean-parent-12.8.3 2021-04-19 21:40:07 +12:00
rbygrave bb6ff866c7 #2220 - DDL generation of nullable columns expected with nullable Embedded containing non null properties 2021-04-19 21:37:05 +12:00
Robin Bygrave 2d719c5b37 #2218 - @Encrypted columns on Oracle. The identifier alias starts with an underscore (ORA-00911)
Change to use zx__ for the encryption column alias prefix rather than _e_
2021-04-19 20:08:38 +12:00
Robin Bygrave 9d54b264ad #2219 - Compile error with ZonedDateTime and query beans - type argument java.time.ZonedDateTime is not within bounds of type-variable D 2021-04-19 17:04:57 +12:00
rbygrave 65b282a056 [maven-release-plugin] prepare for next development iteration 2021-04-09 17:49:16 +12:00
rbygrave fc174c8988 [maven-release-plugin] prepare release ebean-parent-12.8.2 2021-04-09 17:49:07 +12:00
rbygrave 06802896ef #2213 Bump agent for @Transactional(autoPersistUpdates = TxOption.ON) 2021-04-09 16:17:58 +12:00
Robin Bygrave 7f13ac9e5e #2213 - Support autoPersistUpdates via TxScope 2021-04-08 23:15:49 +12:00
Rob BygraveandGitHub 4a1374d22d Merge pull request #2213 from ebean-orm/feature/transparentPersistence
Initial experimental support for autoPersistUpdates / "transparent persistence"
2021-04-08 23:03:05 +12:00
rbygrave 4ee8d647b7 No effective change - tidy test TestCustomerFinder 2021-04-07 23:28:53 +12:00
rbygrave 59793f3c01 Improve javadoc for Transaction#setGetGeneratedKeys
More clearly document the limitation that we can't update beans that don't have id values
2021-04-07 15:50:04 +12:00
rbygrave f7f383d8f3 No effective change - tidy tests TestRawSqlPositionedParams, TestRawSqlUnparsedQuery 2021-04-07 13:38:34 +12:00
rbygrave 562a3959b6 Merge branch 'master' of github.com:ebean-orm/ebean 2021-04-06 21:14:21 +12:00
rbygrave bb1275f4f9 #2217 - Inserting an entity bean is skipped with a String @Id property and no other properties set 2021-04-06 21:13:59 +12:00
Rob BygraveandGitHub 7fde6b9331 Merge pull request #2216 from ebean-orm/feature/2177-take2
#2177 - Fix where schema not provided by JDBC driver
2021-04-06 20:13:24 +12:00
rbygrave 3e97a4005a Change TestCustomerFinder drop query plan threshold for tests only 2021-04-06 20:09:09 +12:00
Rob BygraveandGitHub c271760230 Merge pull request #2215 from PromanSEW/patch-1
Fix copy/paste typo in javadoc for endOr()
2021-04-06 20:00:02 +12:00
rbygrave f7c1845f0c #2177 - Fix where schema not provided by JDBC driver
For @Table with schema, using findNative with a JDBC driver that does not provide the schema this fix matches by just using the table name.
2021-04-06 19:58:02 +12:00
Roman ParshikovandGitHub 9b04f20ed3 Fix copy/paste typo 2021-04-06 13:32:57 +08:00
Rob BygraveandGitHub 62b6b6293b Merge pull request #2214 from cit-consulting/fix_with_lock
Explicit locking method withLock() is unaccessible on query beans
2021-04-06 08:27:38 +12:00
Vladimir Konkov 6d8a1c9398 Explicit locking method withLock() is unaccessible on query beans 2021-04-05 21:45:48 +03:00
Robin Bygrave 303039735f Refactor rename transparentPersistence to autoPersistUpdates 2021-04-01 23:04:22 +13:00
Robin Bygrave 6bcf5c6881 Add DatabaseConfig.autoPersistUpdates for experimental "transparent persistence" 2021-04-01 22:57:34 +13:00
Robin Bygrave 0527f45f5a For experimental "transparent persistence" - Inserts added to PC
When inserting bean with transparent persistence the beans are registered with the persistence context. This is done to support the cases where the beans are inserted, a flush() occurs, the inserted bean is mutated and now dirty - we want that to be detected and get an update
2021-04-01 16:59:03 +13:00
Robin Bygrave ba397bbb0c For experimental "transparent persistence" - Delete removes from PC early
When delete bean executed with transparent persistence, this marks the bean as removed from the persistence context early.

This avoids a "dirty" deleted bean from being seen as a "dirty" bean in the persistence context at flush() time.
2021-04-01 16:04:18 +13:00
Robin Bygrave a617d58902 Initial experimental support for "transparent persistence"
In short, when this is turned on at flush() get any dirty beans held by the PersistenceContext and persist them (always update for these beans)
2021-04-01 14:47:54 +13:00
Robin Bygrave 7fc4a229ae Merge branch 'master' of https://github.com/ebean-orm/ebean 2021-04-01 12:23:00 +13:00
Robin Bygrave f53d31aa2e No functional change - final field for BatchControl 2021-04-01 12:22:45 +13:00
Rob BygraveandGitHub b889b6a6b0 Merge pull request #2212 from tobias-/bitwise_querybean_operators
Add bitwise operators to query beans
2021-04-01 09:38:00 +13:00
Tobias f9b55a06b8 Add bitwise operators to query beans 2021-03-31 12:53:06 +02:00
rob bygrave 09d772a5e5 [maven-release-plugin] prepare for next development iteration 2021-03-31 00:06:13 +13:00
rob bygrave f7035eb228 [maven-release-plugin] prepare release ebean-parent-12.8.1 2021-03-31 00:06:04 +13:00
Robin Bygrave 1bf09ddd38 #2211 - Improve javadoc for queryPlanTTLSeconds
Hopefully people understand it is unrelated. Unfortunately we now have some properties with similar names so maybe we need a better name for this sometime in the future.
2021-03-30 23:49:44 +13:00
Robin Bygrave a8bf27da55 #2211 - Improve query plan capture - Align config property names
collectQueryPlans -> queryPlanEnable
collectQueryPlanThresholdMicros -> queryPlanThresholdMicros

properties keys:
ebean.collectQueryPlans -> ebean.queryPlan.enable
ebean.collectQueryPlanThresholdMicros -> ebean.queryPlan.thresholdMicros

This then aligns all the queryPlan related properties together which is important in order to avoid confusion.
2021-03-30 23:44:30 +13:00
Robin Bygrave ee8bb5ef75 #2211 - Improve query plan capture - Add default mechanism to log captured query plans 2021-03-30 23:19:21 +13:00
Robin Bygrave bcfd9cab1d #2210 - Improve query plan capture - bump threshold multiplier to 1.5 2021-03-30 16:05:42 +13:00
Robin Bygrave 2a5fd7f3a9 #2210 - Improve query plan capture - ability to change default threshold micros 2021-03-30 16:02:27 +13:00
Robin Bygrave f8c37772d4 Tidy internals of DefaultServer with @Nonnull, <>, Collections.singleton(), remove unused queryBatchSize 2021-03-30 10:23:28 +13:00
Robin Bygrave d988dbe69d #2209 - Registering [default] as the default server but [default] is already registered as the default exception with hot-reload 2021-03-30 09:56:48 +13:00
Jonas Pöhler (JPo) bd7499a505 Use SoftReference in Cache, so it can be gc'ed if the jvm runs out of memory
Signed-off-by: Jonas Pöhler (JPo) <jonas.poehler@foconis.de>
2021-03-29 13:23:56 +02:00
rob bygrave 5cb9b9b237 #2208 - When using fetchCache() with a single id / findOne ... doesn't hit L2 cache
Plus #2207 ENH: Query beans add support for nested FetchGroup
2021-03-29 23:21:07 +13:00
rob bygrave 819d391495 Bump agent maven plugin to 12.8.1 2021-03-26 20:31:57 +13:00
rob bygrave 1f0ed629a7 Bump java8-oss to 3.1 with removal of --illegal-access=permit argLine 2021-03-26 20:31:03 +13:00
rob bygrave 91044d0a75 javadoc only - improve javadoc for DatabaseConfig.loadFromProperties() 2021-03-25 23:13:51 +13:00
rob bygrave 57736185d0 #2206 - Postgres DDL generation - for create index use "if not exists" clause 2021-03-25 23:13:15 +13:00
Robin Bygrave 8992980689 #2206 - Postgres DDL generation - for create index use "if not exists" clause 2021-03-25 16:45:44 +13:00
rob bygrave f341ff0167 #2205 - [oracle] Incorrect DDL generated for alter table add column 2021-03-23 23:58:28 +13:00
rob bygrave abfa841ed7 #2205 - [oracle] Incorrect DDL generated for alter table add column 2021-03-23 23:51:07 +13:00
Rob BygraveandGitHub e68adf53bc Merge pull request #2204 from ebean-orm/feature/Honor-setLazyLoadBatchSize
Honor setLazyLoadBatchSize() when using FetchConfig.ofLazy() of unspecified size
2021-03-23 23:25:08 +13:00
Robin Bygrave 562d175de1 With FetchConfig.ofLazy() honor query.setLazyLoadBatchSize()
Use 0 for default lazy batch such that it honors a value set via query.setLazyLoadBatchSize()
2021-03-23 23:17:07 +13:00
Robin Bygrave b5cef354ad Refactor simplify LoadContext.getSecondaryQueriesMinBatchSize()
No functional change here. Just move the constant into DLoadContext.
2021-03-23 14:53:30 +13:00
Jonas Pöhler (JPo) dd6a473008 ADD: Test and possible fix for (C)LOBs being handed out of connnection-context
Signed-off-by: Jonas Pöhler (JPo) <jonas.poehler@foconis.de>
2021-03-22 15:59:59 +01:00
Rob Bygrave 09a887aeb7 #2203 - Support use of Java Record type with @Entity, @Embeddable @IdClass
Add tests for IdClass use of record type
2021-03-23 00:19:52 +13:00
Rob Bygrave 53c903fa48 #2203 - Support use of Java Record type with @Entity, @Embeddable @IdClass
Add tests for EmbeddedId use of record type
2021-03-23 00:10:28 +13:00
Rob Bygrave 548454c90d #2203 - Support use of Java Record type with @Entity, @Embeddable @IdClass
Add tests for embedded use of record type
2021-03-22 23:57:14 +13:00
Rob Bygrave 94bab5f83b #2203 - Support use of Java Record type with @Entity, @Embeddable @IdClass
Add tests for entity use of record type
2021-03-22 23:44:10 +13:00
Rob Bygrave 78965c1ac4 #2203 - Support use of Java Record type with @Entity, @Embeddable @IdClass
Allow java.lang.Record to be a root level parent for entity beans etc
2021-03-22 23:43:35 +13:00
Rob Bygrave 00b0fcaeb3 #2202 - kotlin-maven-plugin issue with JDK 16
Temporary modify tests to not invoke the kotlin-maven-plugin while adding JDK 16 specific tests.

Hitting error InaccessibleObjectException: Unable to make protected void java.util.ResourceBundle.setParent(java.util.ResourceBundle) accessible: module java.base does not "opens java.util" to unnamed module @62732be7
2021-03-22 23:24:16 +13:00
rob bygrave f7905c8e94 [maven-release-plugin] prepare for next development iteration 2021-03-18 22:30:17 +13:00
rob bygrave 7ab7b612f6 [maven-release-plugin] prepare release ebean-parent-12.8.0 2021-03-18 22:23:34 +13:00
rob bygrave ce1d2803ce Bump test wait time for redis 2021-03-18 22:18:34 +13:00
rob bygrave 9b066e4eac Bump version to 12.8.0-SNAPSHOT 2021-03-18 21:26:50 +13:00
Robin Bygrave e1f9d106f0 Additional tests for #2191 query findEach batch consumer 2021-03-18 17:12:21 +13:00
Robin Bygrave e40a539406 #2200 - ENH: Add DtoQuery findEach with batch consumer - findEach(int batchSize, Consumer<List<T>> consumer) 2021-03-18 17:02:41 +13:00
Robin Bygrave bb73c30bb7 #2199 - ScalarTypeWrapper doesn't handle "nullValue" correctly
Fix for - standard JPA AttributeConverter which doesn't have the getNullValue method, he/she can't convert null to a custom null object

AttributeConverterAdapter probes the AttributeConverter for the nullValue rather than just assuming it is null.
2021-03-18 16:14:46 +13:00
Robin Bygrave 2e16f05a70 #2199 - ScalarTypeWrapper doesn't handle "nullValue" correctly
Handles the case for ScalarTypeConverter with custom null value and binding the custom null value (via query parameter, CallableSql parameter etc)
2021-03-18 10:03:35 +13:00
Robin Bygrave 1837c3443d #2186 - Invalid generated table and column names of @ManyToMany relation with allQuotedIdentifiers=true 2021-03-17 21:02:59 +13:00
Rob BygraveandGitHub bd1060ff28 Merge pull request #2198 from ebean-orm/sebastian-mrozek-feature/json-assert-compare-arrays
Feature/json assert compare arrays
2021-03-16 22:06:28 +13:00
Robin Bygrave c9968a9662 Change JsonAssertContains array matching to match on size 2021-03-16 22:03:12 +13:00
Robin Bygrave e3001e8bdd Fix JsonAssertContains testContainsFails with missing parts of JSON
Just add missing parts of test/resources/original.json and original-subset-modified.json
2021-03-16 09:30:54 +13:00
Robin Bygrave 82bb2b4567 Merge branch 'feature/json-assert-compare-arrays' of https://github.com/sebastian-mrozek/ebean into sebastian-mrozek-feature/json-assert-compare-arrays 2021-03-16 09:14:06 +13:00
Robin Bygrave f483002e39 #2197 - [ebean-redis] - Bump jedis dependency to 3.5.2 (from 3.4.0 2021-03-16 09:13:01 +13:00
Robin Bygrave c2a87a0c88 #2196 - SQLException:Column "T0.ID" must be in the GROUP BY list - when findCount with having clause 2021-03-15 22:43:25 +13:00
Robin Bygrave 733886c70b #2195 - @Aggregation on OneToMany property not mapping to column properly 2021-03-15 22:03:14 +13:00
sebastian-mrozek 899fdca995 Improve assertions in case json compare does not fail as expected
Remove sys out print.
2021-03-15 13:04:05 +13:00
sebastian-mrozek 4731ee034e Handle searching for matching elements in an array
Add unit tests.
Refactor internals to allow reusing assertion method for finding matches in an array.
2021-03-15 12:51:36 +13:00
Robin Bygrave e6faf9efd1 #2193 - Prevent registration of 2 default servers (2 Database that have defaultServer=true) 2021-03-11 23:21:44 +13:00
Rob BygraveandGitHub d75d1fce43 Change ModuleInfoLoader API and querybean-generator for named default database (#2190)
Currently we can not use @DbName with the entities of the default database. With this change the generated code that registers entity classes will support using @DbName with the default database.
2021-03-11 20:42:25 +13:00
sebastian-mrozek ef3980a3ee Add test resources 2021-03-11 13:47:46 +13:00
sebastian-mrozek 2a1c170aa4 Add test for shuffled array comparison 2021-03-11 13:44:59 +13:00
Rob BygraveandGitHub d65e769dd7 Merge pull request #2191 from ebean-orm/feature/findEachBatch
ENH: Add Query findEach() with batch consumer
2021-03-11 13:34:58 +13:00
Rob Bygrave 2bb5a85bd6 ENH: Add Query findEach() with batch consumer
This is a variation of findEach() that makes it easy to have a batch consumer processing a large result in batches.  For example, process in batches of 50 beans.

Note that the last batch consumed/processed will often have less than the batch size.
2021-03-10 00:18:35 +13:00
rob bygrave 98aee9ca62 Merge branch 'master' of github.com:ebean-orm/ebean 2021-03-09 20:13:47 +13:00
Robin Bygrave c86f965d36 #2187 - Improve error message thrown when @JoinTable @JoinColumn not satisfied.
Added " or a @JoinColumn needs an explicit referencedColumnName specified?";
2021-03-04 08:55:11 +13:00
Roland Praml ef1143bb70 FIX: orderBy does not work when used on formula property or in conjunction with "exists" query 2021-03-02 15:26:29 +01:00
Robin Bygrave 81e445e386 #2184 - Fix for findNative() with fetch() - convert fetch to fetchQuery with nativeSql
When using nativeSql (think of it as the "root query") we can't use "fetch joins" (FetchConfig.ofDefault()) as that means to prefer to use a SQL JOIN. In this nativeSql case we need to effectively automatically convert fetch() to fetchQuery()
2021-03-02 15:47:07 +13:00
Robin Bygrave 2cbbbc4419 Merge branch 'master' of https://github.com/ebean-orm/ebean 2021-03-02 15:32:40 +13:00
Rob BygraveandGitHub 632f43016e Merge pull request #2183 from bkempe/findNative_fetch_inconsistent
added tests for findNative query with fetch() and fetchQuery()
2021-03-02 15:31:38 +13:00
Robin Bygrave fe62ad2ea2 #2184 - Initial refactor of DefaultOrmQuery to support 2184
- Add fetchInternal() and point fetchQuery() fetchLazy() and fetchCache() to it
- Move the fetch() methods so they are located together
2021-03-02 15:28:17 +13:00
Robin Bygrave f416309863 No effective change - change DefaultOrmQuery methods to return Query<T> rather than DefaultOrmQuery<T>
This is no effective functional change but we do need to update the test OrmQueryPlanKeyTest to cast now.
2021-03-02 14:44:54 +13:00
Rob BygraveandGitHub dcf5e7a15c Merge pull request #2185 from bkempe/querybeans_is_in_subquery
ENH: add in(subQuery) support for query beans
2021-03-02 14:10:53 +13:00
Ben Kempe af4f70e3a7 add in(subQuery) support for query beans 2021-03-01 13:21:05 +01:00
Ben Kempe 79dde23ec6 added tests for findNative fetches 2021-03-01 12:16:22 +01:00
robin e4d0341e67 [maven-release-plugin] prepare for next development iteration 2021-03-01 23:45:15 +13:00
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 bab637667d Update test only - update TestBasicClobNoVer to use DB and AssertJ 2021-02-14 11:50:54 +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 1f32dc2dc5 [maven-release-plugin] prepare release ebean-12.3.8 2020-08-26 11:37:17 +12:00
rob bygrave b2ce9db8a8 #2048 - IllegalStateException: No query cache enabled on __. Need explicit @Cache(enableQueryCache=true) ... when ebean.disableL2Cache=true l2 2020-08-26 11:33:23 +12:00
rob bygrave a626690918 #2044 - Using @AttributeOverrides also override length, scale and columnDefinition 2020-08-25 09:48:01 +12:00
rob bygrave 0d511d51a6 #2044 - Using @AttributeOverrides breaking generated SQL (when override nullable and no column name) 2020-08-25 09:22:15 +12:00
rob bygrave 854f467504 No effective change - update ddl review h2 2020-08-25 09:08:11 +12:00
rob bygrave d3cc393edc No effective change - update ddl review postgres 2020-08-25 09:04:21 +12:00
Rob BygraveandGitHub 002014f930 For #2038 - updated from 12.3.6 to 12.3.7 - NPE BeanDescriptor.findPropertyFromPath(BeanDescriptor.java:1965) (#2047)
* #2038 - lazy loading ToMany with path

* #2038 - Failing test for NPE BeanDescriptor.findPropertyFromPath(BeanDescriptor.java:1965)

* #2038 Refactor internals DbReadContext use BeanPropertyAssocMany
2020-08-24 18:40:36 +12:00
rob bygrave c8d352b0a8 Add a better error message for #2038 NPE at BeanDescriptor.java:1965 2020-08-05 16:44:45 +12:00
rob bygrave 3796f2b267 No effective change - organise imports on tests 2020-08-05 16:39:10 +12:00
peterko2017andGitHub 4ef5abceca Add STI Discrimination on Reference Associations (#2041)
* Update SqlTreeNodeBean#appendFromBaseTable to add
discriminator values to the join
* Update tests to reflect new generated SQL
2020-08-05 16:33:34 +12:00
rob bygrave 4eda4201de Javadoc only change for RawSql 2020-07-30 16:22:09 +12:00
rob bygrave 933aa30149 Javadoc only change - replace at sign and fix javadoc 2020-07-27 16:41:30 +12:00
rob bygrave 0c80b3078a #2037 - Refactor simplify TransactionCallback to lambda
- Move to use generic try catch exception
- Convert to lambda method calls
2020-07-24 13:19:56 +12:00
rob bygrave 7317847aa7 #2037 - Allow PostCommit transaction callback to recursively add another PostCommit callback 2020-07-24 13:16:18 +12:00
rob bygrave 444644f759 #2037 - Allow PostCommit transaction callback to recursively add another PostCommit callback 2020-07-24 13:16:00 +12:00
rob bygrave f704da641d No effective change - Modify test only adding extra asserts for #2036 2020-07-24 11:54:15 +12:00
rob bygrave a1d2f4c1af [maven-release-plugin] prepare for next development iteration 2020-07-14 12:52:50 +12:00
rob bygrave b7469da5b1 [maven-release-plugin] prepare release ebean-12.3.7 2020-07-14 12:52:39 +12:00
rob bygrave 2897968a54 Bump maven plugin - no effective change 2020-07-14 12:50:47 +12:00
rob bygrave 6360fad701 Refactor tidy NoopCallOriginFactory 2020-07-14 11:11:14 +12:00
rob bygrave dbc97aa28c Remove the duplicate TestSoftDeleteBasic.testFindSoftDeletedList()
Hmmm, my bad. I merged the branch manually and that didn't remove the PR so I've merged this twice now and hence ended up with a duplicate method. All good, just removing this duplicate method.
2020-07-14 09:47:07 +12:00
SnōwballandGitHub a231c136a9 Add failing test case for softdeletes (#2034)
Example:
One X can have many Ys. Ys can be soft deleted.

Y1 -> X1 -> Y1

Y1 is soft deleted

When Y1 is loaded, lazy-loading X1 and then lazy-loading the list of Ys associated with X1,
the list should contain Y1. This test asserts that is true.
2020-07-14 09:43:54 +12:00
rob bygrave c6487e56cf Merge branch 'tobias--soft_deletes_not_included' 2020-07-14 09:33:26 +12:00
rob bygrave dac0a97a3f #2035 - lazy-loading soft-deleted list from lazy-loaded bean doesn't remember includeSoftDeletes 2020-07-14 09:32:52 +12:00
rob bygrave ff0274f72c Merge branch 'soft_deletes_not_included' of https://github.com/tobias-/ebean into tobias--soft_deletes_not_included 2020-07-13 18:02:04 +12:00
rob bygrave ddee202bcc No effective change - tidy SqlTreeNodeBean 2020-07-10 10:52:22 +12:00
rob bygrave e1522a4a68 No effective change - tidy test TestSoftDeleteBasic 2020-07-10 10:48:28 +12:00
rob bygrave 7bc6170587 #2032 - Objects that occur in query is not filtered by @SoftDelete (when query has predicates on a ToMany path the associated soft delete predicates are not included) 2020-07-10 10:00:52 +12:00
rob bygrave 0322c19261 Merge branch 'tobias--softdeleted_where' 2020-07-10 09:57:45 +12:00
Tobias 18ae0a7833 Add failing test case for softdeletes
Example:
One X can have many Ys. Ys can be soft deleted.

Y1 -> X1 -> Y1

Y1 is soft deleted

When Y1 is loaded, lazy-loading X1 and then lazy-loading the list of Ys associated with X1,
the list should contain Y1. This test asserts that is true.
2020-07-09 20:56:33 +02:00
Tobias e99db44ddf Add test for soft deleted children
When a child is referenced in the query, Ebean should make sure
that the child (or any of the objects connecting it in the query)
is deleted.

Ie. if a query requires a child to have a certain value, it should
filter out those children that are soft deleted. It should also perform
the deleted check on all objects leading up to that child.

E.g. assuming that all objects are soft deletable, the following where():

DB.find(Alpha.class).where()
.eq("alpha.beta.gamma.name", "bar")

should generate a query with
"t0.deleted = false AND t1.deleted = false AND t2.deleted = false AND t2.name = 'bar'"
2020-07-07 12:33:43 +02:00
rob bygrave 361de9ea99 Update error thrown to use DatabaseConfig rather than ServerConfig 2020-07-06 14:37:56 +12:00
rob bygrave 99732b30b1 No effective change - tidy test TestHstore 2020-07-01 15:38:58 +12:00
rob bygrave dd5e5819b8 No effective change - Javadoc for ServerConfig 2020-06-30 23:07:27 +12:00
rob bygrave b4330679b8 #2029 Opps, fix tests 2020-06-30 10:59:03 +12:00
rob bygrave 59447ad261 #2029 - ENH: Add database.getPlatform(); ... to obtain the underlying database platform being used 2020-06-29 21:56:18 +12:00
rob bygrave 3bd20a424a [maven-release-plugin] prepare for next development iteration 2020-06-29 18:07:38 +12:00
rob bygrave 4ac3a8d1ad [maven-release-plugin] prepare release ebean-12.3.6 2020-06-29 18:07:27 +12:00
rob bygrave 5a8f8b3a83 #2027 - querybean generator support for @EbeanComponent 2020-06-29 18:01:28 +12:00
rob bygrave 7c01cec466 [maven-release-plugin] prepare for next development iteration 2020-06-29 17:21:19 +12:00
rob bygrave 30ad4260f0 [maven-release-plugin] prepare release ebean-12.3.5 2020-06-29 17:21:08 +12:00
rob bygrave ab421d6f2b No effective change - trim whitespace in BaseTableDdl 2020-06-29 17:15:35 +12:00
rob bygrave 0b807addc7 No effective change - test tidy 2020-06-29 17:09:02 +12:00
rob bygrave bb03ef5693 No effective change - test tidy 2020-06-29 15:51:34 +12:00
rob bygrave 248a7b1062 #2004 - MariaDB DDL review 2020-06-29 15:50:08 +12:00
rob bygrave 9da28262b4 #2004 - MariaDB History useLegacyDatetimeCode=false required to properly handle server timezone 2020-06-29 14:51:24 +12:00
rob bygrave fc8dd18fd1 #2004 - MariaDB History DDL using add/drop system versioning 2020-06-29 14:03:21 +12:00
rob bygrave 70ba658442 #2026 - Postgres DDL - modify type generates wrong alter sql. Needs explicit cast / using clause. 2020-06-29 12:12:10 +12:00
rob bygrave 70b730657f #2028 - Refactor internals of smart persistence context to reference "parent" rather than copy beans (adjustment of #2021) 2020-06-29 08:48:24 +12:00
rob bygrave bf3cb7e2e2 No effective change - tidy test BeanDescriptor_registerTest 2020-06-26 15:49:35 +12:00
rob bygrave c2708ecc76 No effective change - Refactor tidy BeanDescriptor internals - trimQueryPlans() etc 2020-06-23 22:14:11 +12:00
rob bygrave 896aba3053 No effective change - trim whitespace 2020-06-23 22:03:21 +12:00
rob bygrave f78b602a90 No effective change - trim whitespace 2020-06-23 21:08:30 +12:00
rob bygrave 306c1b5cf6 No effective change - EntityBeanIntercept tidy javadoc 2020-06-23 20:57:31 +12:00
rob bygrave cdf2718ca9 No effective change - refactor EntityBeanIntercept reverse internal notEqual() method 2020-06-23 20:43:08 +12:00
rob bygrave 967ca0c9f3 No effective change - add some more tests for EntityBeanIntercept 2020-06-23 17:09:15 +12:00
rob bygrave 607acb1b4e No effective change - tidy DefaultPersistenceContext 2020-06-23 16:35:53 +12:00
rob bygrave 5f923945e9 No effective change - trim whitespace 2020-06-23 16:35:36 +12:00
rob bygrave 11fbe8bf5b [maven-release-plugin] prepare for next development iteration 2020-06-19 23:23:32 +12:00
rob bygrave 0544fa7ab4 [maven-release-plugin] prepare release ebean-12.3.4 2020-06-19 23:23:21 +12:00
rob bygrave 51eed9bfe4 Testing - default to h2 2020-06-19 23:20:46 +12:00
Rob BygraveandGitHub 32ce1f1d59 #2004 - MariaDb specific platform with @History support (initial) (#2023)
#2004 - MariaDb specific platform with @History support (initial)
2020-06-19 23:20:07 +12:00
rob bygrave f445c118a0 #2025 - Make findStream & findLargeStream the same - deprecate findLargeStream 2020-06-19 23:17:47 +12:00
rob bygrave a8ff918bb3 #2024 - Change default "fetchBuffer" for findEach/iterate/stream queries to 100 2020-06-19 22:36:24 +12:00
rob bygrave 729aeae0d7 No effective change - trim whitespace 2020-06-19 22:13:50 +12:00
rob bygrave 17a9341287 #2006 - Auto register AttributeConverter with Ebean (using @Converter) 2020-06-19 20:33:58 +12:00
rob bygrave c863014fec Javadoc improvements for #2022 - use of index params like ?1, ?2, ?3 etc 2020-06-18 16:04:13 +12:00
rob bygrave 8170db4101 Bump ebean-annotation which has MariaDB platform enum
As a step for #2004
Means we can add a specific platform for MariaDB separate from MySql
2020-06-18 11:30:43 +12:00
rob bygrave 434a5117a2 Bump to ebean-datasource 5.1
This will expose pool size which can be exposed as a gauge metric (the current size of main connection pool and readonly connection pool)
2020-06-18 11:10:01 +12:00
rob bygrave 85ed8cd784 Test update only - TestSqlUpdateBindMultipleLists 2020-06-18 11:07:45 +12:00
rob bygrave 9b70900267 #2021 - Use smarter persistence context for findEach/iterate/stream queries - improve performance of un-tuned findEach/iterate/stream queries that invoke lazy loading 2020-06-17 21:50:11 +12:00
rob bygrave 0e33d58bb2 Bump ebean-maven-plugin to 12.3.4 2020-06-17 21:47:14 +12:00
rob bygrave 9d9d13060c #2020 - Fix potential connection leak in query-iterator WITH lazyLoadBufferSize (Refer #1164) 2020-06-17 17:10:16 +12:00
rob bygrave e071eecd59 Tidy test only - TestQueryFindEachWhile 2020-06-17 15:37:58 +12:00
rob bygrave bc8e254a65 Tidy tests - delete duplicate test TestQueryFindVisit.java 2020-06-17 13:31:18 +12:00
rob bygrave e0e369904c Tidy test only - TestQueryFindIterate 2020-06-17 13:30:34 +12:00
rob bygrave bd85ba17a1 No effective change - tidy TestQueryFindEach 2020-06-16 17:00:23 +12:00
rob bygrave 8801b8d8ca No effective change - tidy TestQueryFindEach 2020-06-16 16:55:49 +12:00
rob bygrave ebd6c535ab No effective change - tidy TestRawSqlParsing 2020-06-12 15:04:36 +12:00
rob bygrave 5c771a7219 Add tests for RawSql with ${where} and ${andWhere} placeholders 2020-06-12 15:03:05 +12:00
rob bygrave eb6f722385 Put back javadoc maven plugin 2020-06-09 20:03:47 +12:00
rob bygrave cef4f59b2c [maven-release-plugin] prepare for next development iteration 2020-06-08 21:58:31 +12:00
rob bygrave 67352ab3b2 [maven-release-plugin] prepare release ebean-12.3.3 2020-06-08 21:58:19 +12:00
rob bygrave 4a21395cda Comment out javadoc maven plugin temporarily 2020-06-08 21:56:07 +12:00
rob bygrave fcd7f8b6cf Bump ebean-maven-plugin 2020-06-08 20:00:22 +12:00
rob bygrave 4565719728 #2017 - ENH: Add option for different initialDelay to BackgroundExecutor.executePeriodically() 2020-06-05 18:31:07 +12:00
rob bygrave cbdf5609b2 #2015 - Dto instance id fields are not populated when queried using DtoQuery (and no select clause is specified) 2020-05-27 22:05:39 +12:00
rob bygrave f97359502b Refactor internals - DtoMeta DtoMappingRequest
Refactor move most of the code mapping DB columns to bean setters from DtoMeta to DtoMappingRequest
2020-05-27 22:04:03 +12:00
rob bygrave ffaf00c064 Improve error message throw on DTO unmapped DB column 2020-05-27 21:39:16 +12:00
rob bygrave f6f9511d2a #2014 - IllegalArgumentException: No rule for io.ebeaninternal.dbmigration.migration.RenameColumn 2020-05-27 21:00:42 +12:00
rob bygrave 5e94c26094 No effective change - update TestQueryInIdTypeConversion 2020-05-27 15:53:01 +12:00
rob bygrave 5aaed4e12b #2016 - L2 Cache - missing puts with explicit bean cache + findByIds/keys + after transaction writes 2020-05-26 23:42:44 +12:00
rob bygrave c29a57b5ec No effective change - update TestBeanCache Ebean -> DB 2020-05-26 23:19:23 +12:00
rob bygrave 998b8cc192 #2011 - Change query.orderBy() to not be deprecated 2020-05-15 14:06:28 +12:00
rob bygrave 9c1d930fb8 #2012 - Change ExpressionList.orderBy(String) to return ExpressionList<T>
Plus #2011 remove @Deprecated for orderBy
2020-05-15 14:06:06 +12:00
rob bygrave d6d7537a9c #2012 - Change ExpressionList.orderBy(String) to return ExpressionList<T> 2020-05-15 14:05:15 +12:00
rob bygrave 92e83c49d9 [maven-release-plugin] prepare for next development iteration 2020-05-12 22:39:42 +12:00
rob bygrave d758590da4 [maven-release-plugin] prepare release ebean-12.3.2 2020-05-12 22:39:31 +12:00
rob bygrave 21a5efa9b9 Tidy tests - tidy up TestCsvReader and TestCsvReaderWithCallback 2020-05-12 21:28:31 +12:00
rob bygrave 55a2cb12bb #2007 - Encrypted fields unable to be mapped when using DtoQuery 2020-05-12 21:11:28 +12:00
rob bygrave 293700acc0 #2007 - Encrypted fields unable to be mapped when using DtoQuery 2020-05-12 20:25:56 +12:00
rob bygrave 8980a3b6fd No functional change - tidy DbEncrypt, AbstractDbEncrypt 2020-05-12 16:34:08 +12:00
rob bygrave 72efc5d7d6 #2005 - Mark Ebean as deprecated - migrate to io.ebean.Database (EbeanServer -> Database) 2020-05-11 23:15:02 +12:00
rob bygrave 84589fcce6 Bump the versions of ebean-maven-plugin and maven-surefire-plugin 2020-05-11 23:09:24 +12:00
rob bygrave a0e44aedf3 Fix IllegalStateException to use correct dependency io.ebean:ebean-elastic in error message 2020-05-11 20:29:58 +12:00
rob bygrave 41102aca35 Add clearBatch() on BatchedPstmt construction 2020-05-08 23:32:24 +12:00
rob bygrave 548cea432e Fix test UpdateQueryTest for PG 2020-05-08 23:22:23 +12:00
rob bygrave 592cb37693 Reset test default to H2 2020-05-08 23:01:59 +12:00
rob bygrave f2178bf0a6 #2003 - Bump ebean-datasource to 4.9.2 with optional driver 2020-05-04 12:41:14 +12:00
rob bygrave 5cae425b09 #2002 - Support maxRows with delete query 2020-05-04 12:28:52 +12:00
rob bygrave 94b78f1c2d [maven-release-plugin] prepare for next development iteration 2020-04-30 23:41:07 +12:00
rob bygrave 561affef0f [maven-release-plugin] prepare release ebean-12.3.1 2020-04-30 23:40:56 +12:00
Rob BygraveandGitHub 3310d2186d Remove autoCommitMode and explicitTransactionBeginMode (#1993)
These are legacy options that we don't want anyone using going forward.
2020-04-30 23:36:24 +12:00
Rob BygraveandGitHub 02bdace144 Change OraclePlatform to default to use Identity (rather than sequence) (#1976)
* Change OraclePlatform to default to use Identity

- Keep Oracle11Platform to default to Sequence
- Refactor rename Oracle10Ddl to OracleDdl

* Change OraclePlatform to default to use Identity

- DDL review changes in src/test

* Bump ebean-test-docker for StartOracle
2020-04-30 23:35:20 +12:00
rob bygrave 7c17098f17 Bump pom version to 12.3.1-SNAPSHOT 2020-04-30 23:34:13 +12:00
rob bygrave 6f194ce95d #2001 - Add convenient alternative to set read-only url (on the main DataSourceConfig) 2020-04-30 23:19:08 +12:00
rob bygrave dbe473d5a1 #1996 - Fix for MySQLSyntaxErrorException when update in bulk using idIn(). 2020-04-30 21:33:02 +12:00
rob bygrave ed0e9e7006 #1999 - Additionally support empty string for read only url with config.isAutoReadOnlyDataSource() 2020-04-29 22:15:15 +12:00
rob bygrave 2a03198393 #1999 - Additionally support "none" for read only url
"none" can then be used as a special literal value in configuration for "no read-only jdbc url"
2020-04-29 22:07:27 +12:00
rob bygrave 6f1472abe0 #2000 - Tests only - bump sql server to 2019-GA-ubuntu-16.04 2020-04-28 22:13:57 +12:00
rob bygrave 6dea4f0890 #1996 - MySQLSyntaxErrorException when update in bulk. 2020-04-28 21:24:25 +12:00
rob bygrave 4a4ec42cdc #1999 - Refactor read-only DataSource initialisation 2020-04-28 21:10:43 +12:00
rob bygrave 92ea8e3738 #1998 - Refactor internals rename createQueryTransaction() to createReadOnlyTransaction() 2020-04-25 17:38:54 +12:00
rob bygrave c349832d35 #1997 - Modify @Transactional(readOnly=true) to use the read only DataSource 2020-04-25 17:33:33 +12:00
rob bygrave 90493ad57d #1995 - Fix for DatabaseConfig.isLocalOnlyL2Cache() ... to set localL2Caching = true
This has the effect that the l2 cache notification occurs in the foreground when isLocalOnlyL2Cache is true (not background)
2020-04-23 13:11:20 +12:00
rob bygrave 5012f59371 [maven-release-plugin] prepare for next development iteration 2020-04-21 23:01:48 +12:00
rob bygrave 149e63a272 [maven-release-plugin] prepare release ebean-12.2.6 2020-04-21 23:01:37 +12:00
rob bygrave d52a00a8fb #1995 - ENH: Add DatabaseConfig.isLocalOnlyL2Cache() ... to support disabling l2 cache plugins 2020-04-21 23:00:13 +12:00
rob bygrave f0dcec95dd [maven-release-plugin] prepare for next development iteration 2020-04-21 22:00:29 +12:00
rob bygrave 2653931881 [maven-release-plugin] prepare release ebean-12.2.5 2020-04-21 22:00:18 +12:00
rob bygrave 85207086e6 #1995 - ENH: Add DatabaseConfig.isLocalOnlyL2Cache() ... to support disabling l2 cache plugins 2020-04-21 21:55:51 +12:00
rob bygrave d0b0b02d6a [maven-release-plugin] prepare for next development iteration 2020-04-15 08:47:38 +12:00
rob bygrave 34fa1def77 [maven-release-plugin] prepare release ebean-12.2.4 2020-04-15 08:47:26 +12:00
rob bygrave 9f1aa958fc Bump ebean-maven-plugin 2020-04-15 08:35:24 +12:00
rob bygrave cdc5eefc69 EntityBeanIntercept.isOrphanDelete() - Additional refactor for #1988 2020-04-14 23:17:56 +12:00
Jonas PöhlerandGitHub c9588586c9 Removing elements with @OrderColumn with a tree depth > 1 doesn't work (#1988)
* ADD: failing testcase for orderColumn when tree depth > 1

* FIX: no update with @OrderColumn on treeDepth > 1 and avoid needless updates

* ADD: failing testcase for removing models in oneToMany relation with @OrderColumn

Signed-off-by: Jonas Pöhler (JPo) <jonas.poehler@foconis.de>

* ADD: failing test for faulty element reordering in a entityBean tree with version

Signed-off-by: Jonas Pöhler (JPo) <jonas.poehler@foconis.de>

* FIX: incorrect behaviour when reordering or removing elements from collection with @OrderColumn.

Signed-off-by: Jonas Pöhler (JPo) <jonas.poehler@foconis.de>
2020-04-14 23:07:00 +12:00
rob bygrave 52735179d9 Bump maven plugin 2020-04-14 22:44:46 +12:00
rob bygrave cef1fb9e80 #1992 - IllegalArgumentException: Expecting only yaml or properties file but got [ort] 2020-04-14 22:42:26 +12:00
rob bygrave c7e1964aae #1991 - NPE in MCompoundUniqueConstraint.<init>(MCompoundUniqueConstraint.java:66) 2020-04-14 21:28:03 +12:00
rob bygrave 6d43883f77 #1990 - NPE with @Cache and setting naturalKey to null 2020-04-14 20:57:42 +12:00
rob bygrave f06f99dfc3 Refactor remove unnecessary BeanDescriptorManager.setProfileIds() method
As it is no longer necessary (profileIds no longer used)
2020-04-12 17:13:54 +12:00
rob bygrave 41e600be45 Merge branch 'bugfix/order_column_l1_cache' of https://github.com/FOCONIS/ebean into FOCONIS-bugfix/order_column_l1_cache 2020-04-12 16:37:00 +12:00
Rob BygraveandGitHub 62a81c531a Merge pull request #1986 from FOCONIS/bugfix/order_column_reference_abstract
@OrderColumn is ignored on relations referencing a abstract inheritance-model
2020-04-12 16:32:15 +12:00
Rob BygraveandGitHub 2cb1a626c4 Merge pull request #1985 from FOCONIS/bugfix/order_column_tree_depth
Update is missing for relations with @OrderColumn from a tree depth > 1
2020-04-12 16:19:01 +12:00
Jonas Pöhler (JPo) 18cde36b9d FIX: cache not being cleared in persistence context on reorder with @OrderColumn
Signed-off-by: Jonas Pöhler (JPo) <jonas.poehler@foconis.de>
2020-04-08 16:05:09 +02:00
Jonas Pöhler (JPo) e05b6b78ad ADD: failing testcase for not cleared beancache in persistence context on reorder with @OrderColumn
Signed-off-by: Jonas Pöhler (JPo) <jonas.poehler@foconis.de>
2020-04-08 16:04:49 +02:00
rob bygrave 58c49deb06 [maven-release-plugin] prepare for next development iteration 2020-04-08 14:59:42 +12:00
rob bygrave 4a41e88162 [maven-release-plugin] prepare release ebean-12.2.3 2020-04-08 14:59:30 +12:00
rob bygrave 2e5becf48c Refactor rename to MySqlDataTimeZone and OracleDataTimeZone 2020-04-08 14:57:58 +12:00
rob bygrave 4094339407 #1984 - ENH: Add DB.script() ... to access ScriptRunner from DB 2020-04-08 14:13:57 +12:00
rob bygrave bf24949efb #1982 - conflict with eureka config generate StringIndexOutOfBoundsException with 12.2.1 version 2020-04-08 13:49:13 +12:00
Jonas Pöhler (JPo) 3b4549a7ee FIX: @OrderColumn not working when referencing the parent of a inheritance structure 2020-04-06 16:22:33 +02:00
Jonas Pöhler (JPo) f194fdb132 ADD: failing testcase for @OrderColumn working when referencing the parent of a inheritance structure 2020-04-06 16:08:21 +02:00
Jonas Pöhler (JPo) 2d274c46fa FIX: no update with @OrderColumn on treeDepth > 1 and avoid needless updates 2020-04-06 15:34:43 +02:00
Jonas Pöhler (JPo) b61e9af750 ADD: failing testcase for orderColumn when tree depth > 1 2020-04-06 15:14:23 +02:00
rob bygrave a01362abad #1980 Remove the volatile that was added for NPE in EntityBeanIntercept 2020-03-25 22:03:52 +13:00
Rob BygraveandGitHub 4387c662b6 Merge pull request #1981 from tobias-/issue_1980_NPE
Use temp variable to avoid NPE race
2020-03-25 21:06:00 +13:00
Tobias ecdd027b3e Use temp variable to avoid NPE race
resolve #1980
2020-03-25 07:01:32 +01:00
rob bygrave 2b0f572f4d [maven-release-plugin] prepare for next development iteration 2020-03-25 16:15:44 +13:00
rob bygrave 0a1704e6a9 [maven-release-plugin] prepare release ebean-12.2.2 2020-03-25 16:15:32 +13:00
rob bygrave 854c208f92 Bump ebean-maven-plugin 2020-03-25 15:55:57 +13:00
rob bygrave e6f604764c #1980 - NullPointerException in EntityBeanIntercept 2020-03-25 15:54:16 +13:00
Rob BygraveandGitHub 9b501b3dc8 Merge pull request #1979 from FOCONIS/bugfix/order_column_on_inheritance_model
@OrderColumn does not work on inheritance models
2020-03-23 22:28:57 +13:00
Jonas PöhlerandGitHub c2fb23a25c "insert into table default values" is invalid MySQL syntax (#1978)
* ADD: failing testcase for "insert into table default values;" is invalid MySql syntax

* FIX: "insert into table default values;" is invalid MySql syntax
2020-03-23 22:09:28 +13:00
Jonas Pöhler (JPo) 1ad7ace9bd FIX: error with @OrderColumn on model with inheritance 2020-03-20 10:22:16 +01:00
Jonas Pöhler (JPo) 6a3a7eafea ADD: failing testcase for @OrderColumn on model with inheritance 2020-03-20 10:20:52 +01:00
rob bygrave 896aed0b38 No effective change - change to avaje-jsr305 2020-03-17 22:38:05 +13:00
rob bygrave f7359aacd7 No effective change - update tests for oracle ddl 2020-03-17 22:25:52 +13:00
rob bygrave d77fb9265b No effective change - update oracle ddl review 2020-03-17 22:25:04 +13: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 db27844eca [maven-release-plugin] prepare for next development iteration 2020-03-13 09:28:33 +13:00
rob bygrave 61be1683b2 [maven-release-plugin] prepare release ebean-12.2.1 2020-03-13 09:28:23 +13:00
rob bygrave 27a1f35356 Bump ebean-maven-plugin to 12.2.1 2020-03-12 23:46:40 +13:00
rob bygrave f0c0b7ebcc #1974 - Turn on by default loadModuleInfo - aka auto register entity beans using query bean generated code 2020-03-12 23:45:35 +13:00
rob bygrave f4c646cdc1 Bump pom to 12.2.1-SNAPSHOT 2020-03-10 23:00:10 +13:00
rob bygrave 48abc73e50 #1973 - L2Cache, Inheritance and Lazy-Loading loads the parent Class not the Child 2020-03-10 22:52:13 +13:00
rob bygrave 91a327a5e7 #1972 - Change BigDecimal to map by default DB type DECIMAL(16,3) rather than DECIMAL(38) 2020-03-09 17:05:08 +13:00
Rob BygraveandGitHub a861e8bdcc Remove reading mapping annotations from "Getters" with associated refactoring for performance (#1971)
* #1970 - Change test code only moving mapping annotations to fields

First step in remove support for mapping annotations on "Getters" (so field only target for mapping annotations)

* #1970 - Remove reading mapping annotations from "Getters"

* #1970 - Refactor to use simple annotation lookup where possible

* #1970 - Remove GenerationType.TABLE and SequenceGenerator from type/class

* #1970 - Refactor meta annotation reading

* #1970 - Read @Aggregation as a meta annotation
2020-03-09 16:09:41 +13:00
Rob BygraveandGitHub 7692d9782a Merge pull request #1968 from ebean-orm/feature/refactorRenameTxnBatchMethods
Refactor rename Transaction methods - setBatchGetGeneratedKeys(), setBatchFlushOnMixed() setBatchFlushOnQuery() ... (remove the "batch" part)
2020-03-05 09:31:13 +13:00
rob bygrave 524e3e31f0 Refactor rename Transaction setGetGeneratedKeys(), setFlushOnMixed() setFlushOnQuery() ... (remove the "batch" part) 2020-03-05 01:10:41 +13:00
rob bygrave d69d96a400 #1967 - Refactor internals reverse default columnAliasPrefix to null from "c" 2020-03-05 00:56: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
3913 changed files with 68084 additions and 20336 deletions
-6
View File
@@ -1,9 +1,3 @@
GITHUB ISSUES ARE STRICTLY CONTROLLED FOR THIS PROJECT.
Refer to http://ebean-orm.github.io/support for the policies controlling the use of github issues.
Please post issues to the Ebean group https://groups.google.com/forum/#!forum/ebean first.
## Expected behavior
## Actual behavior
+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.11.1</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>7.2</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);
}
@@ -0,0 +1,19 @@
package io.ebean;
/**
* Defines a cancelable query.
* <p>
* Typically holds a representation of the PreparedStatement to perform the
* actual cancel.
* </p>
*/
public interface CancelableQuery {
/**
* Cancel the query.
* <p>
* For JDBC this translates to calling cancel on the PreparedStatement.
* </p>
*/
void cancel();
}
@@ -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,25 +90,24 @@ 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>
* Useful to run SQL scripts that are resources. For example a test script
* for inserting seed data for a particular test.
*
* <pre>{@code
*
* DB.script().run("/scripts/test-script.sql")
*
* }</pre>
*/
public static ScriptRunner script() {
return getDefault().script();
}
/**
* Return the ExpressionFactory from the default database.
@@ -1,5 +1,6 @@
package io.ebean;
import io.ebean.annotation.Platform;
import io.ebean.annotation.TxIsolation;
import io.ebean.cache.ServerCacheManager;
import io.ebean.config.DatabaseConfig;
@@ -13,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;
@@ -92,6 +94,11 @@ import java.util.concurrent.Callable;
*/
public interface Database {
/**
* Shutdown the Database instance.
*/
void shutdown();
/**
* Shutdown the Database instance programmatically.
* <p>
@@ -115,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.
@@ -132,6 +149,25 @@ public interface Database {
*/
MetaInfoManager getMetaInfoManager();
/**
* Return the platform used for this database instance.
* <p>
* Note many platforms have multiple specific platform types so often we want to
* get the base platform via {@link Platform#base()}.
* </p>
* <pre>{@code
*
* Platform platform = database.getPlatform().base();
* if (platform == Platform.MYSQL) {
* // do MySql specific function
* }
*
* }</pre>
*
* @return platform for this database instance
*/
Platform getPlatform();
/**
* Return the extended API intended for use by plugins.
*/
@@ -0,0 +1,170 @@
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>
* 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>
* 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.
*/
public class DatabaseFactory {
private static final ReentrantLock lock = new ReentrantLock();
private static SpiContainer container;
private static String defaultServerName;
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 {
container(containerConfig);
} finally {
lock.unlock();
}
}
/**
* Create using properties to configure the database.
*/
public static Database create(String name) {
lock.lock();
try {
return container(null).createServer(name);
} finally {
lock.unlock();
}
}
/**
* Create using the DatabaseConfig object to configure the database.
*
* <pre>{@code
*
* DatabaseConfig config = new DatabaseConfig();
* config.setName("db");
* config.loadProperties();
*
* Database database = DatabaseFactory.create(config);
*
* }</pre>
*/
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()) {
if (config.isDefaultServer()) {
if (defaultServerName != null && !defaultServerName.equals(config.getName())) {
throw new IllegalStateException("Registering [" + config.getName() + "] as the default server but [" + defaultServerName + "] is already registered as the default");
}
defaultServerName = config.getName();
}
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.
*/
public static void shutdown() {
lock.lock();
try {
container.shutdown();
} finally {
lock.unlock();
}
}
private static Database createInternal(DatabaseConfig config) {
return container(config.getContainerConfig()).createServer(config);
}
/**
* Return the SpiContainer initialising it if necessary.
*
* @param containerConfig the configuration controlling clustering communication
*/
private static SpiContainer container(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
@@ -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.
@@ -6,6 +6,7 @@ import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Stream;
/**
* Query for performing native SQL queries that return DTO Bean's.
@@ -37,7 +38,7 @@ import java.util.function.Predicate;
*
* }</pre>
*/
public interface DtoQuery<T> {
public interface DtoQuery<T> extends CancelableQuery {
/**
* Execute the query returning a list.
@@ -45,6 +46,26 @@ public interface DtoQuery<T> {
@Nonnull
List<T> findList();
/**
* Execute the query iterating a row at a time.
* <p>
* Note that the QueryIterator holds resources related to the underlying
* resultSet and potentially connection and MUST be closed. We should use
* QueryIterator in a <em>try with resource block</em>.
*/
@Nonnull
QueryIterator<T> findIterate();
/**
* Execute the query returning a Stream.
* <p>
* Note that the Stream holds resources related to the underlying
* resultSet and potentially connection and MUST be closed. We should use
* the Stream in a <em>try with resource block</em>.
*/
@Nonnull
Stream<T> findStream();
/**
* Execute the query iterating a row at a time.
* <p>
@@ -53,6 +74,17 @@ public interface DtoQuery<T> {
*/
void findEach(Consumer<T> consumer);
/**
* Execute the query iterating the results and batching them for the consumer.
* <p>
* This runs like findEach streaming results from the database but just collects the results
* into batches to pass to the consumer.
*
* @param batch The number of dto beans to collect before given them to the consumer
* @param consumer The consumer to process the batch of DTO beans
*/
void findEach(int batch, Consumer<List<T>> consumer);
/**
* Execute the query iterating a row at a time with the ability to stop consuming part way through.
* <p>
@@ -2,29 +2,22 @@ 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;
/**
* Ebean will be Deprecated - please migrate to use DB.
* Deprecated - please migrate to use <code>io.ebean.DB</code>.
* <p>
* Ebean is a registry of {@link Database} by name. Ebean has now been renamed to {@link DB}.
* <p>
@@ -32,124 +25,10 @@ import java.util.concurrent.ConcurrentHashMap;
* <p>
* The preference is to use DB and Database rather than Ebean and EbeanServer.
*/
@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() {
}
@@ -173,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);
}
/**
@@ -183,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();
}
/**
@@ -204,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();
}
/**
@@ -237,7 +119,7 @@ public final class Ebean {
* </p>
*/
public static Object nextId(Class<?> beanType) {
return serverMgr.getDefaultServer().nextId(beanType);
return getDefault().nextId(beanType);
}
/**
@@ -283,7 +165,7 @@ public final class Ebean {
* </p>
*/
public static Transaction beginTransaction() {
return serverMgr.getDefaultServer().beginTransaction();
return getDefault().beginTransaction();
}
/**
@@ -292,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);
}
/**
@@ -345,7 +227,7 @@ public final class Ebean {
* }</pre>
*/
public static Transaction beginTransaction(TxScope scope) {
return serverMgr.getDefaultServer().beginTransaction(scope);
return getDefault().beginTransaction(scope);
}
/**
@@ -353,7 +235,7 @@ public final class Ebean {
* in scope.
*/
public static Transaction currentTransaction() {
return serverMgr.getDefaultServer().currentTransaction();
return getDefault().currentTransaction();
}
/**
@@ -383,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();
}
/**
@@ -425,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();
}
/**
@@ -443,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);
}
/**
@@ -477,7 +359,7 @@ public final class Ebean {
* </p>
*/
public static void save(Object bean) throws OptimisticLockException {
serverMgr.getDefaultServer().save(bean);
getDefault().save(bean);
}
/**
@@ -485,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);
}
/**
@@ -515,7 +397,7 @@ public final class Ebean {
* }</pre>
*/
public static void markAsDirty(Object bean) throws OptimisticLockException {
serverMgr.getDefaultServer().markAsDirty(bean);
getDefault().markAsDirty(bean);
}
/**
@@ -530,16 +412,6 @@ public final class Ebean {
* <b>Optimistic Locking: </b> Note that if the version property is not set when update() is
* called then no optimistic locking is performed (internally ConcurrencyMode.NONE is used).
* </p>
* <p>
* <b>{@link ServerConfig#setUpdatesDeleteMissingChildren(boolean)}: </b> When cascade saving to a
* OneToMany or ManyToMany the updatesDeleteMissingChildren setting controls if any other children
* that are in the database but are not in the collection are deleted.
* </p>
* <p>
* <b>{@link ServerConfig#setUpdateChangesOnly(boolean)}: </b> The updateChangesOnly setting
* controls if only the changed properties are included in the update or if all the loaded
* properties are included instead.
* </p>
* <pre>{@code
*
* // A 'stateless update' example
@@ -552,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);
}
/**
@@ -568,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);
}
/**
@@ -578,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);
}
/**
@@ -636,7 +508,7 @@ public final class Ebean {
*/
@Nonnull
public static Set<Property> checkUniqueness(Object bean) {
return serverMgr.getDefaultServer().checkUniqueness(bean);
return getDefault().checkUniqueness(bean);
}
/**
@@ -644,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);
}
/**
@@ -667,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);
}
/**
@@ -727,7 +599,7 @@ public final class Ebean {
* </p>
*/
public static void refresh(Object bean) {
serverMgr.getDefaultServer().refresh(bean);
getDefault().refresh(bean);
}
/**
@@ -745,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);
}
/**
@@ -770,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);
}
/**
@@ -813,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);
}
/**
@@ -863,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);
}
/**
@@ -878,7 +750,7 @@ public final class Ebean {
*/
@Deprecated
public static SqlQuery createSqlQuery(String sql) {
return serverMgr.getDefaultServer().sqlQuery(sql);
return getDefault().sqlQuery(sql);
}
/**
@@ -893,7 +765,7 @@ public final class Ebean {
*/
@Deprecated
public static SqlUpdate createSqlUpdate(String sql) {
return serverMgr.getDefaultServer().sqlUpdate(sql);
return getDefault().sqlUpdate(sql);
}
/**
@@ -902,7 +774,7 @@ public final class Ebean {
* @see CallableSql
*/
public static CallableSql createCallableSql(String sql) {
return serverMgr.getDefaultServer().createCallableSql(sql);
return getDefault().createCallableSql(sql);
}
/**
@@ -934,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);
}
/**
@@ -958,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);
}
/**
@@ -981,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);
}
/**
@@ -1019,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);
}
/**
@@ -1035,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);
}
/**
@@ -1059,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);
}
/**
@@ -1074,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);
}
/**
@@ -1096,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);
}
/**
@@ -1110,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);
}
/**
@@ -1153,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);
}
/**
@@ -1181,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);
}
/**
@@ -1205,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);
}
/**
@@ -1232,7 +1099,7 @@ public final class Ebean {
* }</pre>
*/
public static void execute(Runnable r) {
serverMgr.getDefaultServer().execute(r);
getDefault().execute(r);
}
/**
@@ -1257,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);
}
/**
@@ -1290,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);
}
/**
@@ -1324,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);
}
/**
@@ -1335,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();
}
/**
@@ -1350,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();
}
}
@@ -1,6 +1,7 @@
package io.ebean;
/**
* Deprecated - please migrate to <code>io.ebean.Database</code>.
* Provides the API for fetching and saving beans to a particular Database.
* <p>
* Effectively this is an alias for {@link Database} which is now the new
@@ -8,6 +9,7 @@ package io.ebean;
* <p>
* The preference is to use DB and Database rather than Ebean and EbeanServer.
*/
@Deprecated
public interface EbeanServer extends Database {
}
@@ -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)
*/
@@ -53,7 +53,7 @@ public class Expr {
}
/**
* In Range - property >= value1 and property < value2.
* In Range - {@code property >= value1 and property < value2}.
* <p>
* Unlike Between inRange is "half open" and usually more useful for use with dates or timestamps.
* </p>
@@ -155,7 +155,7 @@ public interface ExpressionFactory {
Expression ineObject(String propertyName, Object value);
/**
* In Range - property >= value1 and property < value2.
* In Range - {@code property >= value1 and property < value2}.
* <p>
* Unlike Between inRange is "half open" and usually more useful for use with dates or timestamps.
* </p>
@@ -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.
*/
@@ -70,30 +70,40 @@ public interface ExpressionList<T> {
*/
ExpressionList<T> order(String orderByClause);
/**
* Set the order by clause replacing the existing order by clause if there is
* one.
* <p>
* This follows SQL syntax using commas between each property with the
* optional asc and desc keywords representing ascending and descending order
* respectively.
*/
ExpressionList<T> orderBy(String orderBy);
/**
* Return the OrderBy so that you can append an ascending or descending
* property to the order by clause.
* <p>
* This will never return a null. If no order by clause exists then an 'empty'
* OrderBy object is returned.
* </p>
* <p>
* This is the same as <code>orderBy()</code>
*/
OrderBy<T> order();
/**
* Deprecated migrate to order().
* Return the OrderBy so that you can append an ascending or descending
* property to the order by clause.
* <p>
* This will never return a null. If no order by clause exists then an 'empty'
* OrderBy object is returned.
* <p>
* This is the same as <code>order()</code>
*/
@Deprecated
OrderBy<T> orderBy();
/**
* Deprecated migrate to {@link #order(String)}
*/
@Deprecated
Query<T> orderBy(String orderBy);
/**
* Deprecated migrate to {@link #order(String)}
* Deprecated migrate to {@link #orderBy(String)}
*/
@Deprecated
Query<T> setOrderBy(String orderBy);
@@ -159,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.
*/
@@ -275,6 +307,13 @@ public interface ExpressionList<T> {
*/
void findEach(Consumer<T> consumer);
/**
* Execute findEach with a batch consumer.
*
* @see Query#findEach(int, Consumer)
*/
void findEach(int batch, Consumer<List<T>> consumer);
/**
* Execute the query processing the beans one at a time with the ability to
* stop processing before reading all the beans.
@@ -849,7 +888,7 @@ public interface ExpressionList<T> {
ExpressionList<T> inRangeWith(String lowProperty, String highProperty, Object value);
/**
* In Range - property >= value1 and property < value2.
* In Range - {@code property >= value1 and property < value2}.
* <p>
* Unlike Between inRange is "half open" and usually more useful for use with dates or timestamps.
* </p>
@@ -876,6 +915,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.
@@ -892,6 +936,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.
*/
@@ -1241,26 +1290,35 @@ public interface ExpressionList<T> {
/**
* Add raw expression with a single parameter.
* <p>
* The raw expression should contain a single ? at the location of the
* parameter.
* </p>
* The raw expression should contain a single ? or ?1
* at the location of the parameter. We use ?1 when binding a
* collection for an IN expression.
* <p>
* When properties in the clause are fully qualified as table-column names
* then they are not translated. logical property name names (not fully
* qualified) will still be translated to their physical name.
* </p>
* <p>
* <h4>Example:</h4>
* <h4>Examples:</h4>
* <pre>{@code
*
* // use a database function
* raw("add_days(orderDate, 10) < ?", someDate)
*
* raw("name like ?", "Rob%")
*
* raw("name in (?1)", asList("Rob", "Fiona", "Jack"))
*
* raw("name = any(?)", asList("Rob", "Fiona", "Jack"))
*
* }</pre>
*
* <h4>Subquery example:</h4>
* <h4>Subquery examples:</h4>
* <pre>{@code
*
* // Bind collection using ?1
* .raw("id in (select c.id from o_customer c where c.name in (?1))", asList("Rob", "Fiona", "Jack"))
*
* // Using Postgres ANY expression
* .raw("t0.customer_id in (select customer_id from customer_group where group_id = any(?::uuid[]))", groupIds)
*
* }</pre>
@@ -1270,14 +1328,25 @@ public interface ExpressionList<T> {
/**
* Add raw expression with an array of parameters.
* <p>
* The raw expression should contain the same number of ? as there are
* parameters.
* </p>
* The raw expression should contain the same number of ? or ?1, ?2 ... bind parameters
* as there are values. We use ?1, ?2 etc when binding a collection for an IN expression.
* <p>
* When properties in the clause are fully qualified as table-column names
* then they are not translated. logical property name names (not fully
* qualified) will still be translated to their physical name.
* </p>
*
* <h4>Examples:</h4>
* <pre>{@code
*
* raw("unitPrice > ? and product.id > ?", 2, 3)
*
* raw("(status = ? or (orderDate < ? and shipDate is null) or customer.name like ?)",
* Order.Status.APPROVED,
* new Timestamp(System.currentTimeMillis()),
* "Rob")
*
* }</pre></pre>
*/
ExpressionList<T> raw(String raw, Object... values);
@@ -1602,7 +1671,7 @@ public interface ExpressionList<T> {
ExpressionList<T> endAnd();
/**
* End a AND junction - synonym for endJunction().
* End a OR junction - synonym for endJunction().
*/
ExpressionList<T> endOr();
@@ -67,7 +67,7 @@ public interface ExtendedServer {
*
* @return True if the query finds a matching row in the database
*/
<T> boolean exists(Query<?> ormQuery, Transaction transaction);
<T> boolean exists(Query<T> ormQuery, Transaction transaction);
/**
* Return the number of 'top level' or 'root' entities this query should return.
@@ -92,11 +92,9 @@ public interface ExtendedServer {
* {@link #findEachWhile(Query, Predicate, Transaction)} is preferred
* to findIterate(). The reason is that those methods automatically take care of
* closing the queryIterator (and the underlying jdbc statement and resultSet).
* </p>
* <p>
* This is similar to findEach in that not all the result beans need to be held
* in memory at the same time and as such is good for processing large queries.
* </p>
*
* @see Query#findIterate()
* @see Query#findEach(Consumer)
@@ -106,7 +104,10 @@ public interface ExtendedServer {
<T> QueryIterator<T> findIterate(Query<T> query, Transaction transaction);
/**
* Return the query result as a Stream using a single persistence context.
* Execute the query returning the result as a Stream.
* <p>
* Note that this can support very large queries iterating any number of results.
* To do so internally it can use multiple persistence contexts.
* <p>
* Note that the stream needs to be closed so use with try with resources.
* </p>
@@ -115,12 +116,17 @@ public interface ExtendedServer {
<T> Stream<T> findStream(Query<T> query, Transaction transaction);
/**
* Return the query result as a Stream (with multiple persistence contexts).
* Deprecated - migrate to findStream().
* <p>
* Execute the query returning the result as a Stream.
* <p>
* Note that this can support very large queries iterating any number of results.
* To do so internally it can use multiple persistence contexts.
* <p>
* Note that the stream needs to be closed so use with try with resources.
* </p>
*/
@Nonnull
@Deprecated
<T> Stream<T> findLargeStream(Query<T> query, Transaction transaction);
/**
@@ -153,6 +159,13 @@ public interface ExtendedServer {
*/
<T> void findEach(Query<T> query, Consumer<T> consumer, Transaction transaction);
/**
* Execute findEach with batch consumer.
*
* @see Query#findEach(int, Consumer)
*/
<T> void findEach(Query<T> query, int batch, Consumer<List<T>> consumer, Transaction t);
/**
* Execute the query visiting the each bean one at a time.
* <p>
@@ -0,0 +1,243 @@
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()}
* <p>
* 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, 0);
}
/**
* 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 < 0) {
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, 0);
}
/**
* Deprecated - migrate to FetchConfig.ofLazy(batchSize).
*/
@Deprecated
public FetchConfig lazy(int batchSize) {
return mutate(LAZY_MODE, batchSize);
}
/**
* Deprecated - migrate to FetchConfig.ofQuery().
* <p>
* 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).
* <p>
* 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>
* This will load all beans on this path eagerly unless a {@link #lazy(int)}
* is also used.
*
* @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).
* <p>
* 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.
*
* @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().
* <p>
* 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;
}
}
@@ -43,6 +43,7 @@ import java.util.List;
* public static final CustomerFinder find = new CustomerFinder();
* ...
*
* }
* }</pre>
* <p>
* When the Finder is registered as a field on Customer it can then be used like:
@@ -85,6 +86,7 @@ public class Finder<I, T> {
* public static final CustomerFinder find = new CustomerFinder();
* ...
*
* }
* }</pre>
*/
public Finder(Class<T> type) {
@@ -32,19 +32,19 @@ import io.ebean.bean.EntityBean;
* // Typically there is a common base model that has some
* // common properties like the ones below
*
* @MappedSuperclass
* public class BaseModel extends Model {
* @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;
*
* ...
* }
* }</pre>
* <p>
* <h3>Extend the Model</h3>
@@ -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;
@@ -18,7 +16,7 @@ import java.util.Objects;
* on the Query object.
* </p>
*/
public final class OrderBy<T> implements Serializable {
public class OrderBy<T> implements Serializable {
private static final long serialVersionUID = 9157089257745730539L;
@@ -71,7 +69,6 @@ public final class OrderBy<T> implements Serializable {
* Add a property with ascending order to this OrderBy.
*/
public Query<T> asc(String propertyName) {
list.add(new Property(propertyName, true));
return query;
}
@@ -100,7 +97,6 @@ public final class OrderBy<T> implements Serializable {
return query;
}
/**
* Return true if the property is known to be contained in the order by clause.
*/
@@ -209,7 +205,6 @@ public final class OrderBy<T> implements Serializable {
if (!(obj instanceof OrderBy<?>)) {
return false;
}
OrderBy<?> e = (OrderBy<?>) obj;
return e.list.equals(list);
}
@@ -251,7 +246,7 @@ public final class OrderBy<T> implements Serializable {
/**
* A property and its ascending descending order.
*/
public static final class Property implements Serializable {
public static class Property implements Serializable {
private static final long serialVersionUID = 1546009780322478077L;
@@ -341,7 +336,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);
@@ -417,13 +412,10 @@ public final class OrderBy<T> implements Serializable {
}
private void parse(String orderByClause) {
if (orderByClause == null) {
return;
}
String[] chunks = orderByClause.split(",");
for (String chunk : chunks) {
for (String chunk : orderByClause.split(",")) {
Property p = parseProperty(chunk);
if (p != null) {
list.add(p);
@@ -469,8 +461,7 @@ public final class OrderBy<T> implements Serializable {
if (s.startsWith("desc")) {
return false;
}
String m = "Expecting [" + s + "] to be asc or desc?";
throw new RuntimeException(m);
throw new RuntimeException("Expecting [" + s + "] to be asc or desc?");
}
private boolean isEmptyString(String s) {
@@ -94,8 +94,8 @@ public interface PagedList<T> {
* Return the Future row count. You might get this if you wish to cancel the total row count query
* or specify a timeout for the row count query.
* <p>
* The loadRowCount() & getTotalRowCount() methods internally make use of this getFutureRowCount() method.
* Generally I expect people to prefer loadRowCount() & getTotalRowCount() over getFutureRowCount().
* The loadRowCount() and getTotalRowCount() methods internally make use of this getFutureRowCount() method.
* Generally I expect people to prefer loadRowCount() and getTotalRowCount() over getFutureRowCount().
* </p>
* <pre>{@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 {
@@ -177,16 +177,47 @@ import java.util.stream.Stream;
*
* @param <T> the type of Entity bean this query will fetch.
*/
public interface Query<T> {
public interface Query<T> extends CancelableQuery {
/**
* 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.
@@ -260,15 +291,6 @@ public interface Query<T> {
*/
UpdateQuery<T> asUpdate();
/**
* Cancel the query execution if supported by the underlying database and
* driver.
* <p>
* This must be called from a different thread to the query executor.
* </p>
*/
void cancel();
/**
* Return a copy of the query.
* <p>
@@ -283,7 +305,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 +505,7 @@ public interface Query<T> {
* </p>
* <pre>{@code
*
* fetch(path, fetchProperties, new FetchConfig().query())
* fetch(path, fetchProperties, FetchConfig.ofQuery())
*
* }</pre>
* <p>
@@ -517,7 +539,7 @@ public interface Query<T> {
* </p>
* <pre>{@code
*
* fetch(path, fetchProperties, new FetchConfig().lazy())
* fetch(path, fetchProperties, FetchConfig.ofLazy())
*
* }</pre>
* <p>
@@ -542,7 +564,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 +601,7 @@ public interface Query<T> {
* </p>
* <pre>{@code
*
* fetch(path, new FetchConfig().query())
* fetch(path, FetchConfig.ofQuery())
*
* }</pre>
* <p>
@@ -608,7 +630,7 @@ public interface Query<T> {
* </p>
* <pre>{@code
*
* fetch(path, new FetchConfig().lazy())
* fetch(path, FetchConfig.ofLazy())
*
* }</pre>
* <p>
@@ -631,7 +653,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>
@@ -711,9 +733,9 @@ public interface Query<T> {
/**
* Execute the query returning the result as a Stream.
* <p>
* Note that this will hold all resulting beans in memory using a single
* persistence context. Use findLargeStream() for queries that expect to
* return a large number of results.
* Note that this can support very large queries iterating
* any number of results. To do so internally it can use
* multiple persistence contexts.
* </p>
* <pre>{@code
*
@@ -731,6 +753,8 @@ public interface Query<T> {
Stream<T> findStream();
/**
* Deprecated - migrate to findStream.
* <p>
* Execute the query returning the result as a Stream.
* <p>
* Note that this uses multiple persistence contexts such that we can use
@@ -749,6 +773,7 @@ public interface Query<T> {
* }</pre>
*/
@Nonnull
@Deprecated
Stream<T> findLargeStream();
/**
@@ -776,7 +801,7 @@ public interface Query<T> {
* </p>
* <p>
* This method is functionally equivalent to findIterate() but instead of using an
* iterator uses the Consumer interface which is better suited to use with Java8 closures.
* iterator uses the Consumer interface which is better suited to use with closures.
* </p>
* <pre>{@code
*
@@ -795,6 +820,21 @@ public interface Query<T> {
*/
void findEach(Consumer<T> consumer);
/**
* Execute findEach streaming query batching the results for consuming.
* <p>
* This query execution will stream the results and is suited to consuming
* large numbers of results from the database.
* <p>
* Typically we use this batch consumer when we want to do further processing on
* the beans and want to do that processing in batch form, for example - 100 at
* a time.
*
* @param batch The number of beans processed in the batch
* @param consumer Process the batch of beans
*/
void findEach(int batch, Consumer<List<T>> consumer);
/**
* Execute the query using callbacks to a visitor to process the resulting
* beans one at a time.
@@ -805,12 +845,12 @@ public interface Query<T> {
* </p>
* <p>
* This method is functionally equivalent to findIterate() but instead of using an
* iterator uses the Predicate (SAM) interface which is better suited to use with Java8 closures.
* iterator uses the Predicate interface which is better suited to use with closures.
* </p>
* <pre>{@code
*
* DB.find(Customer.class)
* .fetch("contacts", new FetchConfig().query(2))
* .fetchQuery("contacts")
* .where().eq("status", Status.NEW)
* .order().asc("id")
* .setMaxRows(2000)
@@ -1352,9 +1392,13 @@ public interface Query<T> {
Query<T> having(Expression addExpressionToHaving);
/**
* Deprecated migrate to {@link #order(String)}
* Set the order by clause replacing the existing order by clause if there is
* one.
* <p>
* This follows SQL syntax using commas between each property with the
* optional asc and desc keywords representing ascending and descending order
* respectively.
*/
@Deprecated
Query<T> orderBy(String orderByClause);
/**
@@ -1373,13 +1417,20 @@ public interface Query<T> {
* <p>
* This will never return a null. If no order by clause exists then an 'empty'
* OrderBy object is returned.
* <p>
* This is the same as <code>orderBy()</code>
*/
OrderBy<T> order();
/**
* Deprecated migrate to order().
* Return the OrderBy so that you can append an ascending or descending
* property to the order by clause.
* <p>
* This will never return a null. If no order by clause exists then an 'empty'
* OrderBy object is returned.
* <p>
* This is the same as <code>order()</code>
*/
@Deprecated
OrderBy<T> orderBy();
/**
@@ -1388,9 +1439,8 @@ public interface Query<T> {
Query<T> setOrder(OrderBy<T> orderBy);
/**
* Deprecated migrate to {@link #setOrder(OrderBy)}
* Set an OrderBy object to replace any existing OrderBy clause.
*/
@Deprecated
Query<T> setOrderBy(OrderBy<T> orderBy);
/**
@@ -1600,8 +1650,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();
@@ -1609,7 +1683,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();
@@ -1617,7 +1692,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();
@@ -1627,9 +1703,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.
@@ -56,7 +56,7 @@ import java.util.Iterator;
*
* @param <T> the type of entity bean in the iteration
*/
public interface QueryIterator<T> extends Iterator<T>, java.io.Closeable {
public interface QueryIterator<T> extends Iterator<T>, AutoCloseable {
/**
* Returns <tt>true</tt> if the iteration has more elements.
@@ -70,12 +70,6 @@ public interface QueryIterator<T> extends Iterator<T>, java.io.Closeable {
@Override
T next();
/**
* Remove is not allowed.
*/
@Override
void remove();
/**
* Close the underlying resources held by this iterator.
*/
@@ -6,17 +6,13 @@ package io.ebean;
* <p>
* If you don't want to build object graphs you can use {@link SqlQuery} instead
* which returns {@link SqlRow} objects rather than entity beans.
* </p>
* <p>
* <b>Unparsed RawSql:</b>
* </p>
* <p>
* When RawSql is created via {@link RawSqlBuilder#unparsed(String)} then Ebean can not
* modify the SQL at all. It can't add any extra expressions into the SQL.
* </p>
* <p>
* <b>Parsed RawSql:</b>
* </p>
* <p>
* When RawSql is created via {@link RawSqlBuilder#parse(String)} then Ebean will parse the
* SQL and find places in the SQL where it can add extra where expressions, add
@@ -24,16 +20,13 @@ package io.ebean;
* explicitly tell Ebean where these insertion points are you can place special
* strings into your SQL ({@code ${where}} or {@code ${andWhere}} and {@code ${having}} or
* {@code ${andHaving})}.
* </p>
* <p>
* If the SQL already includes a WHERE clause put in {@code ${andWhere}} in the location
* you want Ebean to add any extra where expressions. If the SQL doesn't have a
* WHERE clause put {@code ${where}} in instead. Similarly you can put in {@code ${having}} or
* {@code ${andHaving}} where you want Ebean put add extra having expressions.
* </p>
* <p>
* <b>Aggregates:</b>
* </p>
* <p>
* Often RawSql will be used with Aggregate functions (sum, avg, max etc). The
* follow example shows an example based on Total Order Amount -
@@ -44,38 +37,37 @@ package io.ebean;
* on RawSql and not based on a real DB Table or DB View. It has some properties
* to hold the values for the aggregate functions (sum etc) and a &#064;OneToOne
* to Order.
* </p>
* <p>
* <h3>Example OrderAggregate</h3>
* <pre>{@code
* ...
* // @Sql indicates to that this bean
* // is based on RawSql rather than a table
* // @Sql indicates to that this bean
* // is based on RawSql rather than a table
*
* @Entity
* @Sql
* public class OrderAggregate {
* @Entity
* @Sql
* public class OrderAggregate {
*
* @OneToOne
* Order order;
* @OneToOne
* Order order;
*
* Double totalAmount;
* Double totalAmount;
*
* Double totalItems;
*
* // getters and setters
* ...
* Double totalItems;
*
* // getters and setters
* ...
* }
* }</pre>
* <p>
*
* <h3>Example 1:</h3>
* <p>
*
* <pre>{@code
*
* String sql = " select order_id, o.status, c.id, c.name, sum(d.order_qty*d.unit_price) as totalAmount"
* + " from o_order o"
* + " join o_customer c on c.id = o.kcustomer_id "
* + " join o_order_detail d on d.order_id = o.id " + " group by order_id, o.status ";
* String sql = " select order_id, o.status, c.id, c.name, sum(l.order_qty*l.unit_price) as totalAmount"
* + " from order o"
* + " join customer c on c.id = o.customer_id "
* + " join order_line l on l.order_id = o.id " + " group by order_id, o.status ";
*
* RawSql rawSql = RawSqlBuilder.parse(sql)
* // map the sql result columns to bean properties
@@ -95,18 +87,17 @@ package io.ebean;
*
*
* }</pre>
* <p>
*
* <h3>Example 2:</h3>
* <p>
* The following example uses a FetchConfig().query() so that after the initial
* RawSql query is executed Ebean executes a secondary query to fetch the
* associated order status, orderDate along with the customer name.
* </p>
* <p>
*
* <pre>{@code
*
* String sql = " select order_id, 'ignoreMe', sum(d.order_qty*d.unit_price) as totalAmount "
* + " from o_order_detail d"
* String sql = " select order_id, 'ignoreMe', sum(l.order_qty*l.unit_price) as totalAmount "
* + " from order_line l"
* + " group by order_id ";
*
* RawSql rawSql = RawSqlBuilder.parse(sql)
@@ -116,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)
@@ -125,25 +116,23 @@ package io.ebean;
* .findList();
*
* }</pre>
* <p>
* <h3>Example 3: tableAliasMapping</h3>
* <p>
* Instead of mapping each column you can map each table alias to a path using tableAliasMapping().
* </p>
* <pre>{@code
*
* String rs = "select o.id, o.status, c.id, c.name, "+
* " d.id, d.order_qty, p.id, p.name " +
* "from o_order o join o_customer c on c.id = o.kcustomer_id " +
* "join o_order_detail d on d.order_id = o.id " +
* "join o_product p on p.id = d.product_id " +
* " l.id, l.order_qty, p.id, p.name " +
* "from orders o join o_customer c on c.id = o.customer_id " +
* "join order_line l on l.order_id = o.id " +
* "join product p on p.id = l.product_id " +
* "where o.id <= :maxOrderId and p.id = :productId "+
* "order by o.id, d.id asc";
* "order by o.id, l.id asc";
*
* RawSql rawSql = RawSqlBuilder.parse(rs)
* .tableAliasMapping("c", "customer")
* .tableAliasMapping("d", "details")
* .tableAliasMapping("p", "details.product")
* .tableAliasMapping("l", "lines")
* .tableAliasMapping("p", "lines.product")
* .create();
*
* List<Order> ordersFromRaw = DB.find(Order.class)
@@ -154,9 +143,7 @@ package io.ebean;
*
* }</pre>
* <p>
* <p>
* Note that lazy loading also works with object graphs built with RawSql.
* </p>
*/
public interface RawSql {
@@ -37,7 +37,7 @@ import java.util.function.Predicate;
*
* }</pre>
*/
public interface SqlQuery extends Serializable {
public interface SqlQuery extends Serializable, CancelableQuery {
/**
* Execute the query returning a list.
@@ -224,12 +224,49 @@ public interface SqlQuery extends Serializable {
*
* }</pre>
*
* <p>
* When binding a collection of values into a IN expression we should use
* indexed parameters like ?1, ?2, ?3 etc rather than just ?.
* </p>
*
* <pre>{@code
*
* String sql = "select c.id, c.name from customer c where c.name in (?1)";
*
* List<SqlRow> rows = DB.sqlQuery(sql)
* .setParameter(asList("Rob", "Fiona", "Jack"))
* .findList();
*
*
* List<SqlRow> rows = DB.sqlQuery(sql)
* .setParameter(1, asList("Rob", "Fiona", "Jack"))
* .findList();
* }</pre>
*
* @param value The value to bind
*/
SqlQuery setParameter(Object value);
/**
* Bind the parameter by its index position (1 based like JDBC).
* <p>
* When binding a collection of values into a IN expression we should use
* indexed parameters like ?1, ?2, ?3 etc rather than just ?.
* </p>
*
* <pre>{@code
*
* String sql = "select c.id, c.name from customer c where c.name in (?1)";
*
* List<SqlRow> rows = DB.sqlQuery(sql)
* .setParameter(asList("Rob", "Fiona", "Jack"))
* .findList();
*
*
* List<SqlRow> rows = DB.sqlQuery(sql)
* .setParameter(1, asList("Rob", "Fiona", "Jack"))
* .findList();
* }</pre>
*/
SqlQuery setParameter(int position, Object value);
@@ -328,5 +365,10 @@ public interface SqlQuery extends Serializable {
* Return the list of values.
*/
List<T> findList();
/**
* Find streaming the result effectively consuming a row at a time.
*/
void findEach(Consumer<T> consumer);
}
}
@@ -5,18 +5,16 @@ package io.ebean;
* <p>
* Provides a simple way to execute raw SQL insert update or delete statements
* without having to resort to JDBC.
* </p>
* <p>
* Supports the use of positioned or named parameters and can automatically
* notify Ebean of the table modified so that Ebean can maintain its cache.
* </p>
* <p>
* Note that {@link #setAutoTableMod(boolean)} and
* Ebean#externalModification(String, boolean, boolean, boolean)} can be to
* notify Ebean of external changes and enable Ebean to maintain it's "L2"
* server cache.
* </p>
*
* <h2>Positioned parameter example</h2>
* <pre>{@code
*
* // example using 'positioned' parameters
@@ -30,6 +28,7 @@ package io.ebean;
*
* }</pre>
*
* <h2>Named parameter example</h2>
* <pre>{@code
*
* // example using 'named' parameters
@@ -45,8 +44,31 @@ package io.ebean;
* String msg = "There were " + rows + " rows updated";
*
* }</pre>
*
* <h2>Index parameter examples (e.g. ?1, ?2, ?3 ...)</h2>
* <p>
* <h3>Example: Using setNextParameter()</h3>
* We can use index parameters like ?1, ?2, ?3 etc when binding arrays/collections
* of values into an IN expression.
* </p>
* <pre>{@code
*
* // Binding a list of 3 values (9991, 9992, 9993) into an IN expression
*
* DB.sqlUpdate("delete from o_customer where name = ? and id in (?2)")
* .setParameter(1, "Foo")
* .setParameter(2, asList(9991, 9992, 9993))
* .execute();
*
* // note this effectively is the same as
*
* DB.sqlUpdate("delete from o_customer where name = ? and id in (?2)")
* .setParameter("Foo")
* .setParameter(asList(9991, 9992, 9993))
* .execute();
*
* }</pre>
*
* <h3>Example: Using setParameter()</h3>
* <pre>{@code
*
* String sql = "insert into audit_log (id, description, modified_description) values (?,?,?)";
@@ -56,19 +78,19 @@ package io.ebean;
* try (Transaction txn = DB.beginTransaction()) {
* txn.setBatchMode(true);
*
* insert.setNextParameter(10000);
* insert.setNextParameter("hello");
* insert.setNextParameter("rob");
* insert.setParameter(10000);
* insert.setParameter("hello");
* insert.setParameter("rob");
* insert.execute();
*
* insert.setNextParameter(10001);
* insert.setNextParameter("goodbye");
* insert.setNextParameter("rob");
* insert.setParameter(10001);
* insert.setParameter("goodbye");
* insert.setParameter("rob");
* insert.execute();
*
* insert.setNextParameter(10002);
* insert.setNextParameter("chow");
* insert.setNextParameter("bob");
* insert.setParameter(10002);
* insert.setParameter("chow");
* insert.setParameter("bob");
* insert.execute();
*
* txn.commit();
@@ -81,19 +103,19 @@ package io.ebean;
*
* try (Transaction txn = DB.beginTransaction()) {
*
* insert.setNextParameter(10000);
* insert.setNextParameter("hello");
* insert.setNextParameter("rob");
* insert.setParameter(10000);
* insert.setParameter("hello");
* insert.setParameter("rob");
* insert.addBatch();
*
* insert.setNextParameter(10001);
* insert.setNextParameter("goodbye");
* insert.setNextParameter("rob");
* insert.setParameter(10001);
* insert.setParameter("goodbye");
* insert.setParameter("rob");
* insert.addBatch();
*
* insert.setNextParameter(10002);
* insert.setNextParameter("chow");
* insert.setNextParameter("bob");
* insert.setParameter(10002);
* insert.setParameter("chow");
* insert.setParameter("bob");
* insert.addBatch();
*
* int[] rows = insert.executeBatch();
@@ -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;
@@ -59,6 +59,14 @@ public interface Transaction extends AutoCloseable {
*/
void register(TransactionCallback callback);
/**
* EXPERIMENTAL - turn on automatic persistence of dirty beans and batchMode true.
* <p>
* With this turned on beans that are dirty in the persistence context
* are automatically persisted on flush() and commit().
*/
void setAutoPersistUpdates(boolean autoPersistUpdates);
/**
* Set a label on the transaction.
* <p>
@@ -226,7 +234,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 +243,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 +284,7 @@ public interface Transaction extends AutoCloseable {
*
* }</pre>
*
* @see ServerConfig#isSkipCacheAfterWrite()
* @see DatabaseConfig#isSkipCacheAfterWrite()
*/
void setSkipCache(boolean skipCache);
@@ -313,7 +321,7 @@ public interface Transaction extends AutoCloseable {
* <h3>getGeneratedKeys</h3>
* <p>
* Often with large batch inserts we want to turn off getGeneratedKeys. We do
* this via {@link #setBatchGetGeneratedKeys(boolean)}.
* this via {@link #setGetGeneratedKeys(boolean)}.
* Also note that some JDBC drivers do not support getGeneratedKeys in JDBC batch mode.
* </p>
* <pre>{@code
@@ -339,15 +347,12 @@ public interface Transaction extends AutoCloseable {
* The batch is automatically flushed when it hits the batch size and also when we
* execute queries or when we mix UpdateSql and CallableSql with save and delete of
* beans.
* </p>
* <p>
* We use {@link #flush()} to explicitly flush the batch and we can use
* {@link #setBatchFlushOnQuery(boolean)} and {@link #setBatchFlushOnMixed(boolean)}
* {@link #setFlushOnQuery(boolean)} and {@link #setFlushOnMixed(boolean)}
* to control the automatic flushing behaviour.
* </p>
* <p>
* Example: batch processing of CallableSql executing every 10 rows
* </p>
*
* <pre>{@code
*
@@ -392,17 +397,14 @@ public interface Transaction extends AutoCloseable {
* <p>
* This only takes effect when batch mode on the transaction has not already meant that
* JDBC batch mode is being used.
* </p>
* <p>
* This is useful when the single save() or delete() cascades. For example, inserting a 'master' cascades
* and inserts a collection of 'detail' beans. The detail beans can be inserted using JDBC batch.
* </p>
* <p>
* This is effectively already turned on for all platforms apart from older Sql Server.
* </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);
@@ -422,17 +424,29 @@ public interface Transaction extends AutoCloseable {
int getBatchSize();
/**
* Specify if you want batched inserts to use getGeneratedKeys.
* Specify if we want batched inserts to use getGeneratedKeys.
* <p>
* By default batched inserts will try to use getGeneratedKeys if it is
* supported by the underlying jdbc driver and database.
* </p>
* <p>
* You may want to turn getGeneratedKeys off when you are inserting a large
* number of objects and you don't care about getting back the ids.
* </p>
* We want to turn off getGeneratedKeys when we are inserting a large
* number of objects and we don't care about getting back the ids. In this
* way we avoid the extra cost of getting back the generated id values
* from the database.
* <p>
* Note that when we do turn off getGeneratedKeys then we have the limitation
* that after a bean has been inserted we are unable to then mutate the bean
* and update it in the same transaction as we have not obtained it's id value.
*/
void setBatchGetGeneratedKeys(boolean getGeneratedKeys);
void setGetGeneratedKeys(boolean getGeneratedKeys);
/**
* Deprecated renamed to setGetGeneratedKeys().
*/
@Deprecated
default void setBatchGetGeneratedKeys(boolean getGeneratedKeys) {
setGetGeneratedKeys(getGeneratedKeys);
}
/**
* By default when mixing UpdateSql (or CallableSql) with Beans the batch is
@@ -441,15 +455,21 @@ public interface Transaction extends AutoCloseable {
* <p>
* If you want to execute both WITHOUT having the batch automatically flush
* you need to call this with batchFlushOnMixed = false.
* </p>
* <p>
* Note that UpdateSql and CallableSql are ALWAYS executed first (before the
* beans are executed). This is because the UpdateSql and CallableSql have
* already been bound to their PreparedStatements. The beans on the other hand
* have a 2 step process (delayed binding).
* </p>
*/
void setBatchFlushOnMixed(boolean batchFlushOnMixed);
void setFlushOnMixed(boolean batchFlushOnMixed);
/**
* Deprecated renamed to setFlushOnMixed().
*/
@Deprecated
default void setBatchFlushOnMixed(boolean batchFlushOnMixed) {
setFlushOnMixed(batchFlushOnMixed);
}
/**
* By default executing a query will automatically flush any batched
@@ -457,25 +477,38 @@ public interface Transaction extends AutoCloseable {
* <p>
* Calling this method with batchFlushOnQuery = false means that you can
* execute a query and the batch will not be automatically flushed.
* </p>
*/
void setBatchFlushOnQuery(boolean batchFlushOnQuery);
void setFlushOnQuery(boolean batchFlushOnQuery);
/**
* Deprecated renamed to setFlushOnQuery().
*/
@Deprecated
default void setBatchFlushOnQuery(boolean batchFlushOnQuery) {
setFlushOnQuery(batchFlushOnQuery);
}
/**
* Return true if the batch (of persisted beans or executed UpdateSql etc)
* should be flushed prior to executing a query.
* <p>
* The default is for this to be true.
* </p>
*/
boolean isBatchFlushOnQuery();
boolean isFlushOnQuery();
/**
* Deprecated renamed to isFlushOnQuery().
*/
@Deprecated
default boolean isBatchFlushOnQuery() {
return isFlushOnQuery();
}
/**
* The batch will be flushing automatically but you can use this to explicitly
* flush the batch if you like.
* <p>
* Flushing occurs automatically when:
* </p>
* <ul>
* <li>the batch size is reached</li>
* <li>A query is executed on the same transaction</li>
@@ -487,11 +520,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;
/**
@@ -501,11 +534,9 @@ public interface Transaction extends AutoCloseable {
* commit() rollback() and end() methods on the Transaction should still be
* used. Calling these methods on the Connection would be a big no no unless
* you know what you are doing.
* </p>
* <p>
* Examples of when a developer may wish to use the connection directly are:
* Savepoints, advanced CLOB BLOB use and advanced stored procedure calls.
* </p>
*/
Connection getConnection();
@@ -513,17 +544,14 @@ public interface Transaction extends AutoCloseable {
* Add table modification information to the TransactionEvent.
* <p>
* Use this in conjunction with getConnection() and raw JDBC.
* </p>
* <p>
* This effectively informs Ebean of the data that has been changed by the
* transaction and this information is normally automatically handled by Ebean
* when you save entity beans or use UpdateSql etc.
* </p>
* <p>
* If you use raw JDBC then you can use this method to inform Ebean for the
* tables that have been modified. Ebean uses this information to keep its
* caches in synch and maintain text indexes.
* </p>
*/
void addModification(String tableName, boolean inserts, boolean updates, boolean deletes);
@@ -2,6 +2,7 @@ package io.ebean;
import io.ebean.annotation.PersistBatch;
import io.ebean.annotation.TxIsolation;
import io.ebean.annotation.TxOption;
import io.ebean.annotation.TxType;
import java.util.ArrayList;
@@ -33,6 +34,8 @@ public final class TxScope {
private TxIsolation isolation;
private TxOption autoPersistUpdates;
private PersistBatch batch;
private PersistBatch batchOnCascade;
@@ -123,6 +126,13 @@ public final class TxScope {
+ "] serverName[" + serverName + "] rollbackFor[" + rollbackFor + "] noRollbackFor[" + noRollbackFor + "]";
}
/**
* Return the AutoPersistUpdates mode as a nullable Boolean.
*/
public Boolean getAutoPersistUpdates() {
return autoPersistUpdates == null ? null : autoPersistUpdates.asBoolean();
}
/**
* Return true if PersistBatch has been set.
*/
@@ -176,6 +186,14 @@ public final class TxScope {
return this;
}
/**
* Set the autoPersistUpdates mode.
*/
public TxScope setAutoPersistUpdates(TxOption autoPersistUpdates) {
this.autoPersistUpdates = autoPersistUpdates;
return this;
}
/**
* Return the transaction profile id.
*/
@@ -12,26 +12,27 @@ package io.ebean;
* The following is an example of named updates on an entity bean.
* </p>
* <pre>{@code
* ...
* @NamedUpdates(value = {
* @NamedUpdate(
* name = "setTitle",
* notifyCache = false,
* update = "update topic set title = :title, postCount = :count where id = :id"),
* @NamedUpdate(
* name = "setPostCount",
* notifyCache = false,
* update = "update f_topic set post_count = :postCount where id = :id"),
* @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")
* public class Topic {
* ...
* ...
* @NamedUpdates(value = {
* @NamedUpdate(
* name = "setTitle",
* notifyCache = false,
* update = "update topic set title = :title, postCount = :count where id = :id"),
* @NamedUpdate(
* name = "setPostCount",
* notifyCache = false,
* update = "update f_topic set post_count = :postCount where id = :id"),
* @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")
* public class Topic {
* ...
* }
* }</pre>
*
* <p>
@@ -13,12 +13,10 @@ import java.util.Set;
* from the Map Set or List. The purpose of gathering the additions and removals
* is to support persisting ManyToMany objects. The additions and removals
* become inserts and deletes from the intersection table.
* </p>
* <p>
* Technically this is <em>NOT</em> an extension of
* <em>java.util.Collection</em>. The reason being that java.util.Map is not a
* Collection. I realise this makes this name confusing so I apologise for that.
* </p>
*/
public interface BeanCollection<E> extends Serializable {
@@ -68,7 +66,6 @@ public interface BeanCollection<E> extends Serializable {
* Return true if the collection is uninitialised or is empty without any held modifications.
* <p>
* Returning true means can safely skip cascade save for this bean collection.
* </p>
*/
boolean isSkipSave();
@@ -93,7 +90,6 @@ public interface BeanCollection<E> extends Serializable {
* <p>
* That is, if the collection was not loaded due to filterMany predicates etc
* then make sure the collection is set to empty.
* </p>
*/
boolean checkEmptyLazyLoad();
@@ -136,10 +132,7 @@ public interface BeanCollection<E> extends Serializable {
boolean isReadOnly();
/**
* Add the bean to the collection.
* <p>
* This is disallowed for BeanMap.
* </p>
* Add the bean to the collection. This is disallowed for BeanMap.
*/
void internalAdd(Object bean);
@@ -168,7 +161,6 @@ public interface BeanCollection<E> extends Serializable {
* Map.Entry.
* <p>
* For maps this returns the entrySet as we need the keys of the map.
* </p>
*/
Collection<?> getActualEntries();
@@ -185,6 +177,11 @@ public interface BeanCollection<E> extends Serializable {
*/
boolean isReference();
/**
* Return true if the collection is modify listening and has modifications.
*/
boolean hasModifications();
/**
* Set modify listening on or off. This is used to keep track of objects that
* have been added to or removed from the list set or map.
@@ -192,7 +189,6 @@ public interface BeanCollection<E> extends Serializable {
* This is required only for ManyToMany collections. The additions and
* deletions are used to insert or delete entries from the intersection table.
* Otherwise modifyListening is false.
* </p>
*/
void setModifyListening(ModifyListenMode modifyListenMode);
@@ -206,7 +202,6 @@ public interface BeanCollection<E> extends Serializable {
* <p>
* This will potentially end up as an insert into a intersection table for a
* ManyToMany.
* </p>
*/
void modifyAddition(E bean);
@@ -215,7 +210,6 @@ public interface BeanCollection<E> extends Serializable {
* <p>
* This will potentially end up as an delete from an intersection table for a
* ManyToMany.
* </p>
*/
void modifyRemoval(Object bean);
@@ -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();
}
@@ -27,17 +27,6 @@ public interface EntityBean extends Serializable {
throw new NotEnhancedException();
}
/**
* Return the enhancement marker value.
* <p>
* This is the class name of the enhanced class and used to check that all
* entity classes are enhanced (specifically not just a super class).
* </p>
*/
default String _ebean_getMarker() {
throw new NotEnhancedException();
}
/**
* Create and return a new entity bean instance.
*/
@@ -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,35 +32,52 @@ public final class EntityBeanIntercept implements Serializable {
private static final int STATE_REFERENCE = 1;
private static final int STATE_LOADED = 2;
/**
* Used when a bean is partially filled.
*/
private static final byte FLAG_LOADED_PROP = 1;
private static final byte FLAG_CHANGED_PROP = 2;
private static final byte FLAG_CHANGEDLOADED_PROP = 3;
/**
* Flags indicating if a property is a dirty embedded bean. Used to distinguish
* between an embedded bean being completely overwritten and one of its
* embedded properties being made dirty.
*/
private static final byte FLAG_EMBEDDED_DIRTY = 4;
/**
* Flags indicating if a property is a dirty embedded bean. Used to distinguish
* between an embedded bean being completely overwritten and one of its
* embedded properties being made dirty.
*/
private static final byte FLAG_ORIG_VALUE_SET = 8;
/**
* Flags indicating if the mutable hash is set.
*/
private static final byte FLAG_MUTABLE_HASH_SET = 16;
private transient final ReentrantLock lock = new ReentrantLock();
private transient NodeUsageCollector nodeUsageCollector;
private transient PersistenceContext persistenceContext;
private transient BeanLoader beanLoader;
private transient PreGetterCallback preGetterCallback;
private String ebeanServerName;
private boolean deletedFromCollection;
/**
* The actual entity bean that 'owns' this intercept.
*/
private final EntityBean owner;
private EntityBean embeddedOwner;
private int embeddedOwnerIndex;
/**
* One of NEW, REF, UPD.
*/
private int state;
private boolean forceUpdate;
private boolean readOnly;
private boolean dirty;
/**
* Flag set to disable lazy loading - typically for SQL "report" type entity beans.
*/
@@ -68,41 +87,26 @@ public final class EntityBeanIntercept implements Serializable {
* Flag set when lazy loading failed due to the underlying bean being deleted in the DB.
*/
private boolean lazyLoadFailure;
/**
* Used when a bean is partially filled.
*/
private static final byte FLAG_LOADED_PROP = 1;
/**
* Set of changed properties.
*/
private static final byte FLAG_CHANGED_PROP = 2;
/**
* Flags indicating if a property is a dirty embedded bean. Used to distingush
* between an embedded bean being completely overwritten and one of its
* embedded properties being made dirty.
*/
private static final byte FLAG_EMBEDDED_DIRTY = 4;
/**
* Flags indicating if a property is a dirty embedded bean. Used to distingush
* between an embedded bean being completely overwritten and one of its
* embedded properties being made dirty.
*/
private static final byte FLAG_ORIG_VALUE_SET = 8;
private final byte[] flags;
private boolean fullyLoadedBean;
private boolean loadedFromCache;
private final byte[] flags;
private Object[] origValues;
private Exception[] loadErrors;
private int lazyLoadProperty = -1;
private Object ownerId;
private int sortOrder;
/**
* Holds information of json loaded jackson beans (e.g. the original json or checksum).
*/
private MutableValueInfo[] mutableInfo;
/**
* Holds json content determined at point of dirty check.
* Stored here on dirty check such that we only convert to json once.
*/
private MutableValueNext[] mutableNext;
/**
* Create a intercept with a given entity.
*/
@@ -240,6 +244,17 @@ public final class EntityBeanIntercept implements Serializable {
* if any embedded beans are either new or dirty (and hence need saving).
*/
public boolean isDirty() {
if (dirty) {
return true;
}
if (mutableInfo != null) {
for (int i = 0; i < mutableInfo.length; i++) {
if (mutableInfo[i] != null && !mutableInfo[i].isEqualToObject(owner._ebean_getField(i))) {
dirty = true;
break;
}
}
}
return dirty;
}
@@ -369,28 +384,35 @@ public final class EntityBeanIntercept implements Serializable {
/**
* Set the loaded state to true.
* <p>
* Calls to setter methods after the bean is loaded can result in 'Old Values'
* being created to support ConcurrencyMode.ALL
* </p>
* Calls to setter methods after the bean is loaded can result in
* 'Old Values' being created.
* <p>
* Worth noting that this is also set after a insert/update. By doing so it
* 'resets' the bean for making further changes and saving again.
* </p>
*/
public void setLoaded() {
this.state = STATE_LOADED;
this.owner._ebean_setEmbeddedLoaded();
this.lazyLoadProperty = -1;
this.origValues = null;
// after save, transfer the mutable next values back to mutable info
if (mutableNext != null) {
for (int i = 0; i < mutableNext.length; i++) {
MutableValueNext next = mutableNext[i];
if (next != null) {
mutableInfo(i, next.info());
}
}
}
this.mutableNext = null;
for (int i = 0; i < flags.length; i++) {
flags[i] &= ~(FLAG_CHANGED_PROP + FLAG_ORIG_VALUE_SET);
flags[i] &= ~(FLAG_CHANGED_PROP | FLAG_ORIG_VALUE_SET);
}
this.dirty = false;
}
/**
* When finished loading for lazy or refresh on an already partially populated
* bean.
* When finished loading for lazy or refresh on an already partially populated bean.
*/
public void setLoadedLazy() {
this.state = STATE_LOADED;
@@ -421,9 +443,6 @@ public final class EntityBeanIntercept implements Serializable {
/**
* Set true to turn off lazy loading.
* <p>
* Typically used to disable lazy loading on SQL based report beans.
* </p>
*/
public void setDisableLazyLoad(boolean disableLazyLoad) {
this.disableLazyLoad = disableLazyLoad;
@@ -443,7 +462,6 @@ public final class EntityBeanIntercept implements Serializable {
* Return true if the embedded bean is new or dirty and hence needs saving.
*/
public boolean isEmbeddedNewOrDirty(Object embeddedBean) {
if (embeddedBean == null) {
// if it was previously set then the owning bean would
// have oldValues containing the previous embedded bean
@@ -451,7 +469,6 @@ public final class EntityBeanIntercept implements Serializable {
}
if (embeddedBean instanceof EntityBean) {
return ((EntityBean) embeddedBean)._ebean_getIntercept().isNewOrDirty();
} else {
// non-enhanced so must assume it is new and needs to be saved
return true;
@@ -462,6 +479,10 @@ public final class EntityBeanIntercept implements Serializable {
* Return the original value that was changed via an update.
*/
public Object getOrigValue(int propertyIndex) {
if ((flags[propertyIndex] & (FLAG_ORIG_VALUE_SET | FLAG_MUTABLE_HASH_SET)) == FLAG_MUTABLE_HASH_SET) {
// mutable hash set, but not ORIG_VALUE
setOriginalValue(propertyIndex, mutableInfo[propertyIndex].get());
}
if (origValues == null) {
return null;
}
@@ -469,8 +490,8 @@ public final class EntityBeanIntercept implements Serializable {
}
/**
* Finds the index position of a given property. Returns -1 if the property
* can not be found.
* Finds the index position of a given property. Returns -1 if the
* property can not be found.
*/
public int findProperty(String propertyName) {
String[] names = owner._ebean_getPropertyNames();
@@ -493,10 +514,10 @@ public final class EntityBeanIntercept implements Serializable {
}
/**
* Return the number of properties.s
* Return the number of properties.
*/
public int getPropertyLength() {
return owner._ebean_getPropertyNames().length;
return flags.length;
}
/**
@@ -515,8 +536,7 @@ public final class EntityBeanIntercept implements Serializable {
}
/**
* Set the property to be treated as unloaded. Used for properties initialised in default
* constructor.
* Set the property to be treated as unloaded. Used for properties initialised in default constructor.
*/
public void setPropertyUnloaded(int propertyIndex) {
flags[propertyIndex] &= ~FLAG_LOADED_PROP;
@@ -572,6 +592,10 @@ public final class EntityBeanIntercept implements Serializable {
flags[propertyIndex] |= FLAG_CHANGED_PROP;
}
private void setChangeLoaded(int propertyIndex) {
flags[propertyIndex] |= FLAG_CHANGEDLOADED_PROP;
}
/**
* Set that an embedded bean has had one of its properties changed.
*/
@@ -581,7 +605,7 @@ public final class EntityBeanIntercept implements Serializable {
private void setOriginalValue(int propertyIndex, Object value) {
if (origValues == null) {
origValues = new Object[owner._ebean_getPropertyNames().length];
origValues = new Object[flags.length];
}
if ((flags[propertyIndex] & FLAG_ORIG_VALUE_SET) == 0) {
flags[propertyIndex] |= FLAG_ORIG_VALUE_SET;
@@ -594,7 +618,7 @@ public final class EntityBeanIntercept implements Serializable {
*/
private void setOriginalValueForce(int propertyIndex, Object value) {
if (origValues == null) {
origValues = new Object[owner._ebean_getPropertyNames().length];
origValues = new Object[flags.length];
}
origValues[propertyIndex] = value;
}
@@ -603,7 +627,6 @@ public final class EntityBeanIntercept implements Serializable {
* For forced update on a 'New' bean set all the loaded properties to changed.
*/
public void setNewBeanForUpdate() {
for (int i = 0; i < flags.length; i++) {
if ((flags[i] & FLAG_LOADED_PROP) != 0) {
flags[i] |= FLAG_CHANGED_PROP;
@@ -656,10 +679,9 @@ public final class EntityBeanIntercept implements Serializable {
public void addDirtyPropertyNames(Set<String> props, String prefix) {
int len = getPropertyLength();
for (int i = 0; i < len; i++) {
if ((flags[i] & FLAG_CHANGED_PROP) != 0) {
if (isChangedProp(i)) {
// the property has been changed on this bean
String propName = (prefix == null ? getProperty(i) : prefix + getProperty(i));
props.add(propName);
props.add((prefix == null ? getProperty(i) : prefix + getProperty(i)));
} else if ((flags[i] & FLAG_EMBEDDED_DIRTY) != 0) {
// an embedded property has been changed - recurse
EntityBean embeddedBean = (EntityBean) owner._ebean_getField(i);
@@ -672,12 +694,10 @@ public final class EntityBeanIntercept implements Serializable {
* Return true if any of the given property names are dirty.
*/
public boolean hasDirtyProperty(Set<String> propertyNames) {
String[] names = owner._ebean_getPropertyNames();
int len = getPropertyLength();
for (int i = 0; i < len; i++) {
if ((flags[i] & FLAG_CHANGED_PROP) != 0) {
// the property has been changed on this bean
if (isChangedProp(i)) {
if (propertyNames.contains(names[i])) {
return true;
}
@@ -705,15 +725,14 @@ public final class EntityBeanIntercept implements Serializable {
public void addDirtyPropertyValues(Map<String, ValuePair> dirtyValues, String prefix) {
int len = getPropertyLength();
for (int i = 0; i < len; i++) {
if ((flags[i] & FLAG_CHANGED_PROP) != 0) {
if (isChangedProp(i)) {
// the property has been changed on this bean
String propName = (prefix == null ? getProperty(i) : prefix + getProperty(i));
Object newVal = owner._ebean_getField(i);
Object oldVal = getOrigValue(i);
if (!areEqual(oldVal, newVal)) {
if (notEqual(oldVal, newVal)) {
dirtyValues.put(propName, new ValuePair(newVal, oldVal));
}
} else if ((flags[i] & FLAG_EMBEDDED_DIRTY) != 0) {
// an embedded property has been changed - recurse
EntityBean embeddedBean = (EntityBean) owner._ebean_getField(i);
@@ -728,14 +747,13 @@ public final class EntityBeanIntercept implements Serializable {
public void addDirtyPropertyValues(BeanDiffVisitor visitor) {
int len = getPropertyLength();
for (int i = 0; i < len; i++) {
if ((flags[i] & FLAG_CHANGED_PROP) != 0) {
if (isChangedProp(i)) {
// the property has been changed on this bean
Object newVal = owner._ebean_getField(i);
Object oldVal = getOrigValue(i);
if (!areEqual(oldVal, newVal)) {
if (notEqual(oldVal, newVal)) {
visitor.visit(i, newVal, oldVal);
}
} else if ((flags[i] & FLAG_EMBEDDED_DIRTY) != 0) {
// an embedded property has been changed - recurse
EntityBean embeddedBean = (EntityBean) owner._ebean_getField(i);
@@ -756,7 +774,7 @@ public final class EntityBeanIntercept implements Serializable {
}
/**
* Add and return a dirty property hash recursing into embedded beans.
* Add and return a dirty property hash.
*/
private void addDirtyPropertyKey(StringBuilder sb) {
if (sortOrder > 0) {
@@ -764,7 +782,7 @@ public final class EntityBeanIntercept implements Serializable {
}
int len = getPropertyLength();
for (int i = 0; i < len; i++) {
if ((flags[i] & FLAG_CHANGED_PROP) != 0) {
if ((flags[i] & FLAG_CHANGED_PROP) != 0) { // we do not check against mutablecontent here.
sb.append(i).append(',');
} else if ((flags[i] & FLAG_EMBEDDED_DIRTY) != 0) {
// an embedded property has been changed - recurse
@@ -816,25 +834,28 @@ 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) {
throw new PersistenceException("Database [" + ebeanServerName + "] was not found?");
}
// 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();
}
}
@@ -842,32 +863,24 @@ public final class EntityBeanIntercept implements Serializable {
* Invoke the lazy loading. This method is synchronised externally.
*/
private void loadBeanInternal(int loadProperty, BeanLoader loader) {
if ((flags[loadProperty] & FLAG_LOADED_PROP) != 0) {
// race condition where multiple threads calling preGetter concurrently
return;
}
if (lazyLoadFailure) {
// failed when batch lazy loaded by another bean in the batch
throw new EntityNotFoundException("(Lazy) loading failed on type:" + owner.getClass().getName() + " id:" + ownerId + " - Bean has been deleted");
}
if (lazyLoadProperty == -1) {
lazyLoadProperty = loadProperty;
if (nodeUsageCollector != null) {
nodeUsageCollector.setLoadProperty(getProperty(lazyLoadProperty));
}
loader.loadBean(this);
if (lazyLoadFailure) {
// failed when lazy loading this bean
throw new EntityNotFoundException("Lazy loading failed on type:" + owner.getClass().getName() + " id:" + ownerId + " - Bean has been deleted.");
}
// bean should be loaded and intercepting now. setLoaded() has
// been called by the lazy loading mechanism
}
@@ -877,32 +890,31 @@ public final class EntityBeanIntercept implements Serializable {
* Helper method to check if two objects are equal.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
protected boolean areEqual(Object obj1, Object obj2) {
protected static boolean notEqual(Object obj1, Object obj2) {
if (obj1 == null) {
return (obj2 == null);
return (obj2 != null);
}
if (obj2 == null) {
return false;
return true;
}
if (obj1 == obj2) {
return true;
return false;
}
if (obj1 instanceof BigDecimal) {
// Use comparable for BigDecimal as equals
// uses scale in comparison...
if (obj2 instanceof BigDecimal) {
Comparable com1 = (Comparable) obj1;
return (com1.compareTo(obj2) == 0);
return (com1.compareTo(obj2) != 0);
} else {
return false;
return true;
}
}
if (obj1 instanceof URL) {
// use the string format to determine if dirty
return obj1.toString().equals(obj2.toString());
return !obj1.toString().equals(obj2.toString());
}
return obj1.equals(obj2);
return !obj1.equals(obj2);
}
/**
@@ -913,6 +925,7 @@ public final class EntityBeanIntercept implements Serializable {
}
private void preGetterCallback(int propertyIndex) {
PreGetterCallback preGetterCallback = this.preGetterCallback;
if (preGetterCallback != null) {
preGetterCallback.preGetterTrigger(propertyIndex);
}
@@ -942,25 +955,24 @@ public final class EntityBeanIntercept implements Serializable {
}
/**
* OneToMany and ManyToMany don't have any interception so just check for
* PropertyChangeSupport.
* 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");
}
setChangeLoaded(propertyIndex);
}
setLoadedProperty(propertyIndex);
}
private void setChangedPropertyValue(int propertyIndex, boolean setDirtyState, Object origValue) {
if (readOnly) {
throw new IllegalStateException("This bean is readOnly");
}
setChangedProperty(propertyIndex);
if (setDirtyState) {
setOriginalValue(propertyIndex, origValue);
setDirtyStatus();
@@ -985,20 +997,17 @@ public final class EntityBeanIntercept implements Serializable {
* the old values for use with ConcurrencyMode.ALL.
*/
public void preSetter(boolean intercept, int propertyIndex, Object oldValue, Object newValue) {
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else if (!areEqual(oldValue, newValue)) {
} else if (notEqual(oldValue, newValue)) {
setChangedPropertyValue(propertyIndex, intercept, oldValue);
}
}
/**
* Check for primitive boolean.
*/
public void preSetter(boolean intercept, int propertyIndex, boolean oldValue, boolean newValue) {
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else if (oldValue != newValue) {
@@ -1010,7 +1019,6 @@ public final class EntityBeanIntercept implements Serializable {
* Check for primitive int.
*/
public void preSetter(boolean intercept, int propertyIndex, int oldValue, int newValue) {
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else if (oldValue != newValue) {
@@ -1022,7 +1030,6 @@ public final class EntityBeanIntercept implements Serializable {
* long.
*/
public void preSetter(boolean intercept, int propertyIndex, long oldValue, long newValue) {
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else if (oldValue != newValue) {
@@ -1034,7 +1041,6 @@ public final class EntityBeanIntercept implements Serializable {
* double.
*/
public void preSetter(boolean intercept, int propertyIndex, double oldValue, double newValue) {
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else if (Double.compare(oldValue, newValue) != 0) {
@@ -1046,7 +1052,6 @@ public final class EntityBeanIntercept implements Serializable {
* float.
*/
public void preSetter(boolean intercept, int propertyIndex, float oldValue, float newValue) {
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else if (Float.compare(oldValue, newValue) != 0) {
@@ -1058,7 +1063,6 @@ public final class EntityBeanIntercept implements Serializable {
* short.
*/
public void preSetter(boolean intercept, int propertyIndex, short oldValue, short newValue) {
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else if (oldValue != newValue) {
@@ -1070,7 +1074,6 @@ public final class EntityBeanIntercept implements Serializable {
* char.
*/
public void preSetter(boolean intercept, int propertyIndex, char oldValue, char newValue) {
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else if (oldValue != newValue) {
@@ -1082,7 +1085,6 @@ public final class EntityBeanIntercept implements Serializable {
* byte.
*/
public void preSetter(boolean intercept, int propertyIndex, byte oldValue, byte newValue) {
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else if (oldValue != newValue) {
@@ -1094,7 +1096,6 @@ public final class EntityBeanIntercept implements Serializable {
* char[].
*/
public void preSetter(boolean intercept, int propertyIndex, char[] oldValue, char[] newValue) {
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else if (!Arrays.equals(oldValue, newValue)) {
@@ -1106,7 +1107,6 @@ public final class EntityBeanIntercept implements Serializable {
* byte[].
*/
public void preSetter(boolean intercept, int propertyIndex, byte[] oldValue, byte[] newValue) {
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else if (!Arrays.equals(oldValue, newValue)) {
@@ -1137,12 +1137,23 @@ public final class EntityBeanIntercept implements Serializable {
this.sortOrder = sortOrder;
}
/**
* Set if the entity was deleted from a BeanCollection.
*/
public void setDeletedFromCollection(final boolean deletedFromCollection) {
this.deletedFromCollection = deletedFromCollection;
}
public boolean isOrphanDelete() {
return deletedFromCollection && !isNew();
}
/**
* Set the load error that happened on this property.
*/
public void setLoadError(int propertyIndex, Exception t) {
if (loadErrors == null) {
loadErrors = new Exception[owner._ebean_getPropertyNames().length];
loadErrors = new Exception[flags.length];
}
loadErrors[propertyIndex] = t;
flags[propertyIndex] |= FLAG_LOADED_PROP;
@@ -1168,4 +1179,60 @@ public final class EntityBeanIntercept implements Serializable {
}
return ret;
}
private boolean isChangedProp(int i) {
if ((flags[i] & FLAG_CHANGED_PROP) != 0) {
return true;
} else if (mutableInfo == null || mutableInfo[i] == null || mutableInfo[i].isEqualToObject(owner._ebean_getField(i))) {
return false;
} else {
// mark for change
flags[i] |= FLAG_CHANGED_PROP;
dirty = true; // this makes the bean automatically dirty!
return true;
}
}
/**
* Return the MutableValueInfo for the given property or null.
*/
public MutableValueInfo mutableInfo(int propertyIndex) {
return mutableInfo == null ? null : mutableInfo[propertyIndex];
}
/**
* Set the MutableValueInfo for the given property.
*/
public void mutableInfo(int propertyIndex, MutableValueInfo info) {
if (mutableInfo == null) {
mutableInfo = new MutableValueInfo[flags.length];
}
flags[propertyIndex] |= FLAG_MUTABLE_HASH_SET;
mutableInfo[propertyIndex] = info;
}
/**
* Dirty detection set the next mutable property content and info .
* <p>
* Set here as the mutable property dirty detection is based on json content comparison.
* We only want to perform the json serialisation once so storing it here as part of
* dirty detection so that we can get it back to bind in insert or update etc.
*/
public void mutableNext(int propertyIndex, MutableValueNext next) {
if (mutableNext == null) {
mutableNext = new MutableValueNext[flags.length];
}
mutableNext[propertyIndex] = next;
}
/**
* Update the 'next' mutable info returning the content that was obtained via dirty detection.
*/
public String mutableNext(int propertyIndex) {
if (mutableNext == null) {
return null;
}
return mutableNext[propertyIndex].content();
}
}
@@ -0,0 +1,42 @@
package io.ebean.bean;
/**
* Holds information on mutable values (like plain beans stored as json).
* <p>
* Used internally in EntityBeanIntercept for dirty detection on mutable values.
* Typically, mutation detection is based on a hash/checksum of json content or the
* original json content itself.
* <p>
* Refer to the mapping options {@code @DbJson(mutationDetection)}.
*/
public interface MutableValueInfo {
/**
* Compares the given json returning null if deemed unchanged or returning
* the MutableValueNext to use if deemed dirty/changed.
* <p>
* Returning MutableValueNext allows an implementation based on hash/checksum
* to only perform that computation once.
*
* @return Null if deemed unchanged or the MutableValueNext if deemed changed.
*/
MutableValueNext nextDirty(String json);
/**
* Compares the given object to an internal value.
* <p>
* This is used to support changelog/beanState. The implementation can serialize the
* object into json form and compare it against the original json.
*/
boolean isEqualToObject(Object obj);
/**
* Creates a new instance from the internal json string.
* <p>
* This is used to provide an original/old value for change logging / persist listeners.
* This is only available for properties that have {@code @DbJson(keepSource=true)}.
*/
default Object get() {
return null;
}
}
@@ -0,0 +1,17 @@
package io.ebean.bean;
/**
* Represents a next value to use for mutable content properties (DbJson with jackson beans).
*/
public interface MutableValueNext {
/**
* Return the next content to use. Provided such that we serialise to json once.
*/
String content();
/**
* Return the next MutableValueInfo to use after an update.
*/
MutableValueInfo info();
}
@@ -5,7 +5,6 @@ package io.ebean.bean;
* <p>
* This is used to ensure only one instance for a given entity type and id is
* used to build object graphs from queries and lazy loading.
* </p>
*/
public interface PersistenceContext {
@@ -20,7 +19,6 @@ public interface PersistenceContext {
* <p>
* Returns an existing entity bean (if one is already there) and otherwise
* returns null.
* </p>
*/
Object putIfAbsent(Class<?> rootType, Object id, Object bean);
@@ -61,12 +59,27 @@ public interface PersistenceContext {
*/
int size(Class<?> rootType);
/**
* Return a copy of the Persistence context to use for large query iteration.
*/
PersistenceContext forIterate();
/**
* Return a new Persistence context during iteration of large query result.
*/
PersistenceContext forIterateReset();
/**
* Return true if the persistence context has grown and hit the 'reset limit'
* during large query iteration.
*/
boolean resetLimit();
/**
* Wrapper on a bean to also indicate if a bean has been deleted.
* <p>
* If a bean has been deleted then for the same persistence context is should
* not be able to be fetched from persistence context or L2 cache.
* </p>
*/
class WithOption {
@@ -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