Compare commits

...
Author SHA1 Message Date
Rob Bygrave db2f8cd811 [maven-release-plugin] prepare release ebean-parent-12.12.1 2021-10-05 10:49:53 +13:00
Rob Bygrave b6e524f879 Disable test modules for release 2021-10-05 10:47:23 +13:00
Rob Bygrave 40492f487c #2404 - Initializing @OneToMany with mutableListOf() in Kotlin results in ClassCastException 2021-10-05 10:17:44 +13:00
Rob Bygrave 2cee03bc4b #172 Bump ebean-agent via maven plugin
The associated ebean-agent has the fix for the kotlin specific #172 issue.
2021-10-04 22:57:24 +13:00
Rob BygraveandGitHub e2c6125501 Merge pull request #2402 from ebean-orm/feature/ebean-agent-min-version
Modify EbeanVersion to check for minimum ebean-agent version
2021-09-30 10:42:33 +13:00
Rob Bygrave b53221fc0e Modify EbeanVersion to check for minimum ebean-agent version 2021-09-29 12:20:27 +13:00
Rob Bygrave b23551ce43 #2401 - Fix EbeanVersion for use in module-path (reads local ebean-api pom.properties) 2021-09-29 11:14:26 +13:00
Rob Bygrave 3971ccea1a Merge branch 'master' of github.com:ebean-orm/ebean 2021-09-29 11:11:55 +13:00
Rob BygraveandGitHub 35b1f835c5 Merge pull request #2400 from focbenz/patch-1
Update README.md typo fix Maven central
2021-09-29 09:47:28 +13:00
Michael BenzandGitHub ef5e3a796d Update README.md typo fix Maven central
typo fix Maven central
2021-09-28 20:02:12 +02:00
Rob Bygrave d3dbde4e79 Add a dummy placeholder so that we can sync to maven central
The sync needs javadoc and sources so adding a dummy class. Note that I think we only just got this due to the multi-version jar but not sure.
2021-09-24 21:42:23 +12:00
Rob Bygrave 033c579984 #2398 - Fix compiler warning for annotation processing query bean generators 2021-09-24 17:51:36 +12:00
Rob Bygrave 1a34a56351 [maven-release-plugin] prepare for next development iteration 2021-09-24 10:12:14 +12:00
Rob Bygrave edfdbd56b1 [maven-release-plugin] prepare release ebean-parent-12.12.0 2021-09-24 10:12:07 +12:00
Rob Bygrave 8f94072afd Log error when ebean-ddl-generator not in classpath but ddlRun is true 2021-09-23 22:32:01 +12:00
Rob Bygrave d028b200fa Log error when ebean-ddl-generator not in classpath but ddlRun is true 2021-09-23 22:28:01 +12:00
Rob Bygrave 9af006b15b Update tests only for Oracle 2021-09-23 18:49:28 +12:00
Rob Bygrave 35a6ff7f02 #2392 - Oracle specific singleAttribute distinct query - not include the column twice with order by clause 2021-09-23 18:48:40 +12:00
Rob Bygrave cebac8040f #2391 - MySql specific NPE because the return value of "java.sql.ResultSetMetaData.getTableName(int)" is null 2021-09-23 17:20:59 +12:00
Rob Bygrave e8524c5b1a Fix tests only - fix tests for SqlServer 2021-09-23 17:07:35 +12:00
Rob Bygrave 3244314424 #2390 - Tidy generated SQL removing excess whitespace after id = ? predicate 2021-09-23 16:42:45 +12:00
Rob Bygrave 0a4c26965c No effective change - tidy whitespace in CQueryBuilder 2021-09-23 16:36:20 +12:00
Rob Bygrave 6238243c91 No effective change - tidy whitespace in CQueryBuilderRawSql 2021-09-23 16:35:35 +12:00
Rob Bygrave c1d7e77d85 No effective change - tidy whitespace in DtoMeta etc 2021-09-23 16:31:29 +12:00
Rob Bygrave 5b07309f51 #2389 - redis.clients.jedis.exceptions.JedisDataException: ERR wrong number of arguments for 'mget' command 2021-09-23 15:41:33 +12:00
Rob Bygrave 8ee67410f9 #2387 - Additionally support setIdIn(Collection<?> ids)
Add overloaded method taking Collection of id values.
2021-09-23 15:32:40 +12:00
Rob Bygrave dec114028f #2388 - Bump dependencies ebean-migration, classpath-scanner, avaje-config 2021-09-23 15:01:43 +12:00
Rob Bygrave 477e7eeeda #2387 - Hit the L2 bean cache via property IN expression (when property is the id property) 2021-09-23 00:23:23 +12:00
Rob Bygrave c9c61d9f97 #2386 - Fix test with logging change 2021-09-23 00:13:53 +12:00
Rob Bygrave d0909ad140 #2385 - Redis L2 cache regression - MPUT not working 2021-09-22 23:13:39 +12:00
Rob BygraveandGitHub 13c94ac78d Merge pull request #2386 from ebean-orm/feature/refactor-simplify-loggers
Refactor internals, reduce the number of loggers used and simplify
2021-09-22 22:33:49 +12:00
Rob Bygrave f467ca2e10 Refactor internals, reduce the number of loggers used and simplify 2021-09-22 22:29:41 +12:00
Rob BygraveandGitHub d5c24d327e Merge pull request #2384 from ebean-orm/feature/2039
#2039 Map LocalDateTime when generating DB migrations for Postgres to timestamp DB type
2021-09-22 16:53:17 +12:00
Rob Bygrave 23cd45b5d1 #2039 LocalDateTime ignore timestamp->localdatetime as a type change
Historically LocalDateTime mapped to logical timestamp and we need to treat that to be not a change in type. Migrations then will not generate a AlterColumn migration when we start using the new logical type localdatetime.
2021-09-22 16:51:47 +12:00
Rob Bygrave a14f7a1766 #2039 Map LocalDateTime when generating DB migrations for Postgres to timestamp DB type 2021-09-22 16:23:10 +12:00
Rob BygraveandGitHub c86a8c2d32 Merge pull request #2332 from ChenZhangg/Modify_MAVEN_1
Improve MAVEN build Performance
2021-09-22 14:15:13 +12:00
Rob Bygrave e85a471fcf #2380 Related test pom only changes
Note that we can't run both test-java16 and test-kotlin together as kotlin isn't yet working on JDK 16
2021-09-22 14:11:46 +12:00
Rob BygraveandGitHub 57689db291 Merge pull request #2380 from cit-consulting/isToManyDirty_cce
WIP: Try to fix ClassCastException in isToManyDirty() check
2021-09-22 14:00:19 +12:00
Rob Bygrave fec87b5281 Test against Postgres JDBC driver excluding the checker-qual dependency 2021-09-21 21:16:43 +12:00
Rob Bygrave 21bd83b417 Fix TestQueryJoinOnFormula with Postgres specific sql 2021-09-21 21:16:06 +12:00
Vladimir Konkov fde5350c43 Kotlin-based test 2021-09-21 11:49:36 +03:00
Rob Bygrave 769f6b72ae Bump to 12.12.0-SNAPSHOT 2021-09-21 15:04:08 +12:00
Rob Bygrave 97e9b3c473 #2383 - Refactor rename Pairs methods for consistency (that are expected to be used only internally) 2021-09-21 15:01:01 +12:00
Rob BygraveandGitHub 3550bf61c4 Refactor rename TransactionManager methods (#2382) 2021-09-21 14:54:26 +12:00
Rob BygraveandGitHub 0bf8c9eb64 Add module-info support via multi-version jar (#2381) 2021-09-21 14:37:51 +12:00
Vladimir Konkov 01e7ddcffd Try to fix ClassCastException in isToManyDirty() check 2021-09-20 20:02:58 +03:00
Rob Bygrave b450227b13 [maven-release-plugin] prepare for next development iteration 2021-09-20 12:41:40 +12:00
Rob Bygrave d7554cefc7 [maven-release-plugin] prepare release ebean-parent-12.11.5 2021-09-20 12:41:33 +12:00
rbygrave a7a056f041 #2379 - Refactor tidy internals only - method names and tidy for internal BatchPstmt and related 2021-09-20 12:35:00 +12:00
Rob BygraveandGitHub ad0befe90a Merge pull request #2308 from FOCONIS/bugfix/fix-gen-key-sequence-test
fixing test entity GenKeySequence
2021-09-20 11:59:15 +12:00
Rob BygraveandGitHub 59763777f3 Merge pull request #2378 from ebean-orm/FOCONIS-save-cascade-order
#2377 - Wrong order in batch save - Fix to transaction depth
2021-09-20 11:57:43 +12:00
rbygrave 1bf9cfde50 #2377 - Revert back the changes to BatchControl as no longer needed
With the fix to the depth we no longer need these changes to BatchControl
2021-09-20 11:53:31 +12:00
rbygrave f51f2269fb #2377 - Wrong order in batch save, fix transaction depth
The guts of this fix is in DefaultPersister.saveAssocOne() with the change to use the new transaction.depthDecrement() method. For our failing test cases this changes the depth from -1, 0 to be 0, 1.

We can see the impact of this change in the batch ordering via the logging of:
 io.ebean.SUM - txn[1001] BatchControl flush ...
2021-09-17 17:58:20 +12:00
rbygrave b38a21f8c4 Merge branch 'save-cascade-order' of https://github.com/FOCONIS/ebean into FOCONIS-save-cascade-order 2021-09-17 14:00:35 +12:00
Roland Praml bf62efd220 Add failing testcases for wrong order in batch save and possible fix for one of them 2021-09-16 16:52:20 +02:00
Rob Bygrave fc54ade8f6 #2363 - Bump ebean-migration to 12.11.2 2021-09-16 23:06:15 +12:00
Rob Bygrave aa5ba76707 #2376 - Whoops, revert logback-test.xml change 2021-09-16 23:01:43 +12:00
Rob Bygrave 3865fc8ffd #2376 - When Lazy load of soft deleted bean - javax.persistence.EntityNotFoundException: Bean not found during lazy load or refresh. id[*] type[class *] 2021-09-16 23:01:04 +12:00
Rob Bygrave b262c2e19d #2373 - Tidy up, migrate from deprecated methods 2021-09-16 11:58:45 +12:00
Rob BygraveandGitHub cf95372f32 Merge pull request #2373 from FOCONIS/pr/enh/post_process_find_controller
Allow post-processing in BeanFindController
2021-09-16 11:26:34 +12:00
Rob BygraveandGitHub 41bbfb0c9c Merge pull request #2372 from FOCONIS/pr/bugfix/optimistic_lock_undo_generated_properties
Undo generated properties on OptimisticLockException
2021-09-16 11:17:55 +12:00
Rob Bygrave 8129376b2a Merge branch 'FOCONIS-pr/enh/formula_in_where_and_order_by' 2021-09-16 11:12:39 +12:00
Jonas Pöhler d016f479e2 Merge remote-tracking branch 'ebean/master' into pr/enh/post_process_find_controller 2021-09-15 16:36:22 +02:00
Jonas Pöhler aea50b4805 Fix assert methods and import 2021-09-15 15:30:07 +02:00
Jonas Pöhler 864ae2ad9b Fix star imports 2021-09-15 13:55:24 +02:00
Jonas Pöhler 861fc813a7 Merge remote-tracking branch 'ebean/master' into pr/enh/formula_in_where_and_order_by 2021-09-15 13:54:10 +02:00
Rob Bygrave f3b66c555a #2368 - ebean-migration not loading properties properly from ebean as it's name isn't set 2021-09-15 22:35:10 +12:00
Rob Bygrave 04ab161421 #2367 - Modify ebean-ddl-generator to not have a dependency on ImportedId
Effectively remove the import io.ebeaninternal.server.deploy.id.ImportedId; dependency
2021-09-15 19:14:38 +12:00
Rob Bygrave 7226bb0ea3 #2367 - Modify ebean-ddl-generator to not have a dependency on MultiValueBind
Effectively remove the import io.ebeaninternal.server.persist.platform.MultiValueBind; dependency
2021-09-15 17:04:01 +12:00
Rob Bygrave 55bfd56574 #2367 - Modify ebean-test to use its own logger adapter (not reuse the one from ebean-core) 2021-09-15 16:56:12 +12:00
rbygrave 853a6a5c1d #2363 - Bump to dependencies that have module-info via mult-version jars etc 2021-09-15 11:28:02 +12:00
rbygrave 0206921eae #2366 - Rename methods with deprecation for QueryPlanCapture and Pairs 2021-09-15 11:22:25 +12:00
Rob BygraveandGitHub f3dbf216d2 Merge pull request #2365 from FOCONIS/pr/bugfix/cache_exists_queries
Allow caching of exists-queries
2021-09-15 08:59:56 +12:00
Jonas Pöhler 38139850de Merge remote-tracking branch 'ebean/master' into pr/enh/post_process_find_controller 2021-09-14 15:37:43 +02:00
Jonas Pöhler 37b3ea9e5a Merge remote-tracking branch 'ebean/master' into pr/bugfix/optimistic_lock_undo_generated_properties 2021-09-14 15:37:18 +02:00
Jonas Pöhler 4064be731f Re-add test and fix post-merge compile errors 2021-09-14 15:36:03 +02:00
Jonas Pöhler beec6b4b13 Merge remote-tracking branch 'ebean/master' into pr/enh/formula_in_where_and_order_by
# Conflicts:
#	ebean-core/src/test/java/org/tests/query/joins/TestQueryJoinOnFormula.java
2021-09-14 15:27:08 +02:00
Jonas Pöhler 6db44a05fe Merge remote-tracking branch 'ebean/master' into pr/bugfix/cache_exists_queries 2021-09-14 13:55:29 +02:00
Thomas Fellner 45e235cb64 Merge remote-tracking branch 'origin/master' into bugfix/fix-gen-key-sequence-test 2021-09-14 11:29:00 +02:00
Rob Bygrave 512ba24041 #2364 - Move tests only in ebean-ddl-generator 2021-09-14 19:10:23 +12:00
Rob Bygrave 1fbfcd393f #2363 - Bump to dependencies that have module-info via mult-version jars etc
Bump ebean-ddl-generator and avaje-config
2021-09-14 19:00:55 +12:00
Jonas Pöhler 5805c3e995 Re-add test 2021-09-13 17:12:32 +02:00
Jonas Pöhler c89255ec72 Merge remote-tracking branch 'ebean/master' into pr/bugfix/cache_exists_queries
# Conflicts:
#	ebean-core/src/test/java/org/tests/cache/TestQueryCache.java
2021-09-13 17:06:05 +02:00
Jonas Pöhler a582db9101 Re-add test and fix compile error 2021-09-13 17:04:22 +02:00
Jonas Pöhler 12fe54da24 Merge remote-tracking branch 'ebean/master' into pr/bugfix/optimistic_lock_undo_generated_properties
# Conflicts:
#	ebean-core/src/test/java/org/tests/basic/TestIUDVanilla.java
2021-09-13 16:47:06 +02:00
Jonas Pöhler a4eeda6449 Revert changes 2021-09-13 13:34:14 +02:00
Jonas Pöhler 1fecbbb618 Changes post-merge 2021-09-13 13:33:20 +02:00
Jonas Pöhler c363023c80 Merge remote-tracking branch 'ebean/master' into pr/enh/post_process_find_controller 2021-09-13 13:25:28 +02:00
Jonas Pöhler 0cfae9a13b Smaller changes pre-merge 2021-09-13 13:15:14 +02:00
Rob Bygrave 88f75bc62f #2363 - Bump to dependencies that have module-info via mult-version jars etc 2021-09-10 22:07:10 +12:00
Rob Bygrave fece3bb0df #2363 - Bump to dependencies that have module-info via mult-version jars etc 2021-09-10 22:00:18 +12:00
Rob Bygrave 268a39ae15 #2363 - Bump to dependencies that have module-info via mult-version jars etc 2021-09-10 21:59:52 +12:00
Rob Bygrave 9324d1cebe Delete the pom.xml.releaseBackup files that somehow got added 2021-09-10 21:47:27 +12:00
Rob Bygrave 2733608a72 [maven-release-plugin] prepare for next development iteration 2021-09-09 21:57:50 +12:00
Rob Bygrave e29e032693 [maven-release-plugin] prepare release ebean-parent-12.11.4 2021-09-09 21:57:43 +12:00
Rob Bygrave 9fc2ec044d #2362 - ENH: Add lock(bean) method as convenience for DB pessimistic locking 2021-09-09 18:18:16 +12:00
Rob Bygrave b739326fca #2361 - Update test-java16 tests - use record style accessors with entity beans 2021-09-09 12:13:34 +12:00
Rob Bygrave 88fd4f5569 #2361 - Update test-java16 test dependencies 2021-09-09 12:04:11 +12:00
Rob Bygrave 4cca3bfa98 #2361 - Tidy test dependencies bump tiles-maven-plugin 2021-09-09 11:44:27 +12:00
Rob Bygrave 8f8d031d91 #2361 - Tidy tests dependencies in ebean-core 2021-09-09 11:39:17 +12:00
Rob Bygrave 7a327cb644 #2361 - Tidy tests only, organise imports 2021-09-09 11:29:05 +12:00
Rob Bygrave 1696caadd4 #2361 - Tidy tests only, move to LoggedSql (ebean-test) 2021-09-09 11:25:04 +12:00
Rob BygraveandGitHub e5dceda4b9 Merge pull request #2361 from ebean-orm/feature/move-tests-to-ebean-test
Refactor move tests from ebean-core to ebean-test
2021-09-09 10:59:42 +12:00
rbygrave eab56d323b Refactor move tests from ebean-core to ebean-test 2021-09-08 22:49:23 +12:00
rbygrave 0b00a14fd3 Refactor tidy tests - remove unused test Main and test MainMemoryLeak 2021-09-08 21:48:53 +12:00
rbygrave c1d57c6b10 Refactor tidy tests 2021-09-08 21:47:52 +12:00
rbygrave 1049435f86 Tidy up ddl-generator BaseTestCase 2021-09-08 17:31:14 +12:00
rbygrave cee879d2f3 #2359 - Rename internal methods - BeanDescriptorManager 2021-09-08 15:34:23 +12:00
rbygrave 93ff2ef2e4 #2359 - Rename internal methods - SpiEbeanServer 2021-09-08 15:25:18 +12:00
rbygrave d389ac680f #2359 - Rename internal methods - BeanDescriptor 2021-09-08 15:17:17 +12:00
rbygrave d582e63c25 #2359 - Rename internal methods - STreeProperty 2021-09-08 14:41:12 +12:00
rbygrave cb9295658c #2359 - Rename internal methods - ElPropertyValue 2021-09-08 14:32:49 +12:00
rbygrave dbc1ab7a57 #2359 - Rename methods and tidy in cache API 2021-09-08 14:25:10 +12:00
rbygrave bb9532f42e #2359 - Rename Transaction.getConnection() method to connection() with deprecation 2021-09-08 14:17:30 +12:00
rbygrave 632f04c76b #2359 - Rename plugin api methods with deprecation - Property 2021-09-08 14:04:31 +12:00
rbygrave bc02eeac57 #2359 - Rename plugin api methods with deprecation - BeanType 2021-09-08 13:13:29 +12:00
rbygrave d6dc147497 #2359 - Rename plugin api methods with deprecation - BeanDocType 2021-09-08 10:59:20 +12:00
rbygrave a15e1ae0a7 #2359 - Rename plugin api methods with deprecation - QueryPlanMetric 2021-09-08 10:53:32 +12:00
rbygrave 8b98335e2e #2359 - Rename plugin api methods with deprecation - BeanDocType 2021-09-08 10:42:51 +12:00
rbygrave 01e07dd2be #2358 - Rename BeanState methods with deprecation 2021-09-08 10:30:18 +12:00
rbygrave 3ac8d6e1d3 #2357 - Modify ddl-generator CurrentModel away from deprecated methods 2021-09-07 21:45:23 +12:00
rbygrave 66143280fa #2357 - Update tests to move away from deprecated methods 2021-09-07 21:44:07 +12:00
rbygrave e95442d8ec #2357 - Update tests to use reference() 2021-09-07 18:13:03 +12:00
rbygrave aafde53b81 #2357 - Update tests to use beanState() 2021-09-07 18:11:51 +12:00
rbygrave 0887480865 #2357 - Update tests to use Database from EbeanServer 2021-09-07 18:10:36 +12:00
rbygrave 4ff8df9538 Tidy tests for ServerConfig -> DatabaseConfig 2021-09-07 17:33:06 +12:00
rbygrave ddb63c1488 Update tests for MariaDB 2021-09-07 16:30:39 +12:00
rbygrave aab2dff49c MySQL Ignore tests that use Hash/Source JSON dirty detection
MySQL JSON type will not preserve ordering of keys. No way to return a consistent JSON result with this type hence Hash/Source do not work
2021-09-07 16:04:07 +12:00
rbygrave d017b2ef39 MySQL Ignore tests that use Hash/Source JSON dirty detection
MySQL JSON type will not preserve ordering of keys. No way to return a consistent JSON result with this type hence Hash/Source do not work
2021-09-07 15:08:28 +12:00
rbygrave 70a967a3a7 Junit5 bump - ebean-core 2021-09-07 13:23:27 +12:00
rbygrave 796edae614 Junit5 bump - tidy ebean-test 2021-09-06 21:37:14 +12:00
rbygrave 50bb7086ac Junit5 bump - tidy ebean-test 2021-09-06 21:01:50 +12:00
rbygrave af8cf9c6c7 Junit5 bump - querybean-generator 2021-09-06 20:57:48 +12:00
rbygrave 6227b081cf Junit5 bump - ebean-test 2021-09-06 20:55:09 +12:00
rbygrave 42645f7236 Junit5 bump - ebean-redis 2021-09-06 20:51:58 +12:00
rbygrave eae8bbac82 Junit5 bump - ebean-querybean 2021-09-06 18:05:11 +12:00
rbygrave 43451c5342 Junit5 bump - ebean-postgis 2021-09-06 17:59:01 +12:00
rbygrave a6f27ca19f Junit5 bump - ebean-externalmapping-xml 2021-09-06 17:53:17 +12:00
rbygrave a7462e86c8 Junit5 bump - ebean-ddl-generator, autotune and api 2021-09-06 17:49:23 +12:00
rbygrave 0ddcfec70d Junit5 bump - ebean-ddl-generator, autotune and api 2021-09-06 17:49:06 +12:00
rbygrave bf70470b9a Junit5 bump - remove parent junit dependency 2021-09-06 16:55:11 +12:00
rbygrave 23c5bd65cf [maven-release-plugin] prepare for next development iteration 2021-09-05 10:54:24 +12:00
rbygrave 30aa05a243 [maven-release-plugin] prepare release ebean-parent-12.11.3 2021-09-05 10:54:17 +12:00
rbygrave 4ce70e401d No functional change - Simplify BeanDescriptor.isIdLoaded() 2021-09-04 22:24:59 +12:00
rbygrave a2f49a544c #2355 - Rename methods in SpiServer with deprecation 2021-09-04 22:01:16 +12:00
rbygrave 4d4065c54b #2355 - Rename methods in SpiServer with deprecation 2021-09-04 21:55:23 +12:00
rbygrave d072dd52cf #2355 - Rename methods in SpiServer with deprecation 2021-09-03 20:17:12 +12:00
rbygrave 25b9b37ac0 #2354 - Refactor internals - refactor rename methods in BeanRequest etc 2021-09-03 19:53:36 +12:00
rbygrave 5ea5b55882 #2353 Refactor rename internal methods for BeanRequest 2021-09-03 19:04:48 +12:00
rbygrave b69c00b01e #2353 - Rename BeanPersistRequest methods with deprecation 2021-09-03 18:01:27 +12:00
rbygrave aa53742a07 #2352 - Rename ServerCache methods with deprecation 2021-09-03 17:24:33 +12:00
rbygrave 7c2a77081b #2351 - Rename Database.getReference() to reference() with deprecation 2021-09-03 10:50:29 +12:00
rbygrave 57c0bceb63 #2351 - Rename Database.getReference() to reference() with deprecation 2021-09-03 10:47:56 +12:00
rbygrave 8cb43788dc #2350 - Rename Database.getBeanState() to beanState() with deprecation 2021-09-03 09:55:48 +12:00
rbygrave 921ee9f8a1 #2345 - Rename Database.getExpressionFactory() to expressionFactory with deprecation 2021-09-03 09:46:04 +12:00
rbygrave 058e16d1a8 #2349 - Rename Database.getBeanId() to beanId() with deprecation 2021-09-03 09:32:47 +12:00
rbygrave a5f9beabdf #2349 - Rename Database.getBeanId() to beanId() with deprecation 2021-09-03 09:31:16 +12:00
Rob Bygrave 0ed6ccf499 #2348 - Rename Database.getServerCacheManager() to cacheManager() with deprecation 2021-09-02 23:14:33 +12:00
Rob Bygrave fe67abce83 #2347 - Rename Database.getPlatform() to platform() with deprecation 2021-09-02 23:04:57 +12:00
Rob Bygrave 7fba9adc43 #2346 - Rename Database.getMetaInfoManager() to metaInfo() with deprecation 2021-09-02 22:58:09 +12:00
Rob Bygrave 4557bdfa6f #2345 - Rename Database.getExpressionFactory() to expressionFactory with deprecation 2021-09-02 22:55:47 +12:00
Rob Bygrave 7a7dbae313 #2342 - Rename Database.getName() to Database.name() with deprecation 2021-09-02 22:52:34 +12:00
Rob Bygrave 12c5e9ea5d #2344 - Rename Database.getDataSource() to dataSource() with deprecation 2021-09-02 22:48:09 +12:00
Rob Bygrave 239a444d4c #2343 - Rename Database.getAutoTune() to autoTune() with deprecation 2021-09-02 22:44:31 +12:00
Rob Bygrave f770b66f42 #2342 - Rename Database.getName() to Database.name() with deprecation 2021-09-02 22:41:51 +12:00
Rob Bygrave 6311d0bf4e No effective change - javadoc for ServerCache 2021-09-02 22:36:02 +12:00
Rob Bygrave 491d6a5461 #2341 - Refactor internal api LoadBeanBuffer LoadBeanRequest etc 2021-09-02 22:09:34 +12:00
Rob Bygrave b142319da0 Refactor tidy methods in LoadBeanRequest, LoadManyRequest, LoadRequest and DefaultBeanLoader 2021-09-02 21:50:43 +12:00
Rob Bygrave ac21fcb5cf Simplify load description in LoadBeanRequest and LoadManyRequest 2021-09-02 19:28:24 +12:00
Rob Bygrave 455914fb52 Use cast built into BeanDescriptor.beanId() rather than cast + getId() 2021-09-02 19:25:02 +12:00
Rob Bygrave 2419c6ab34 #2335 ReadOnly propagation test requiring cache clear 2021-09-02 19:23:40 +12:00
Rob BygraveandGitHub 8a0403ef6b Merge pull request #2340 from ebean-orm/feature/2335
#2335 -  L2 cache be triggered by in ?
2021-09-02 19:08:36 +12:00
rbygrave e0afeea6c4 #2335 - Modify test - Put back readOnly assert (#2340) 2021-09-02 19:03:54 +12:00
Rob BygraveandGitHub dd8b4f6416 Merge pull request #2338 from FOCONIS/delete-id-request-getbeantype
NEW: DeleteIdRequest can return beanType
2021-09-02 17:46:11 +12:00
rbygrave 97482c3372 No effective change - tidy DefaultCallableSql 2021-09-02 17:45:30 +12:00
rbygrave d2e36fc1d2 No effective change - tidy DefaultSqlUpdate raw types 2021-09-02 17:34:45 +12:00
rbygrave 99acd6d64f Tidy test only - static imports for QCustomerByteArrayTest 2021-09-02 17:28:04 +12:00
rbygrave 6fe6b8ba64 #2335 - L2 cache be triggered by in ? 2021-09-02 17:10:56 +12:00
Rob BygraveandGitHub c2b947d2e6 Merge pull request #2337 from Ryszard-Trojnacki/master
Query bean PByteArray type for byte[]
2021-09-02 15:05:20 +12:00
Rob BygraveandGitHub 7d6b25ff59 Merge pull request #2339 from FOCONIS/master12
No effective code change: Add missing @Override annotation
2021-09-02 15:02:03 +12:00
rbygrave d9cef737e3 #2335 Initial test work 2021-09-02 11:57:59 +12:00
rob 2f18e97a44 Allow format() for types UUID to handle string input 2021-09-02 11:52:26 +12:00
rob bf3c1629f7 Allow format() for types Integer and Long to handle string input 2021-09-02 11:44:51 +12:00
rob 1062adede4 No effective change - change setUseCache(false) to setBeanCacheMode(CacheMode.OFF) 2021-09-02 10:26:14 +12:00
rob 47c9a434bb Test tidy - remove @Cache from Order model 2021-09-02 10:15:33 +12:00
Roland Praml b2bfca7ec6 no effective code change: Add missing @Override annotation and removed duplicate methods in interfaces 2021-09-01 09:58:27 +02:00
Roland Praml 5d84f10110 NEW DeleteIdRequest can return beantype. Also provide alternative for deprecated 'getEbeanServer' 2021-09-01 09:44:31 +02:00
Ryszard Trojnacki 847ce5db88 Added PByteArray query bean type for byte[] column type. 2021-08-31 11:34:35 +02:00
Ryszard TrojnackiandGitHub afdfbd6173 Merge branch 'ebean-orm:master' into master 2021-08-31 09:46:26 +02:00
rbygrave c0007d3c1a [maven-release-plugin] prepare for next development iteration 2021-08-31 17:21:59 +12:00
rbygrave aa27aedca9 [maven-release-plugin] prepare release ebean-parent-12.11.2 2021-08-31 17:21:52 +12:00
rbygrave 172c1d10a1 Tidy test only - tidy TestDbArray_asSet 2021-08-31 14:28:54 +12:00
rbygrave da6f7d671b #2336 - @DbArray List or Set of UUID or enum returned as String (not converted) when DB does not support ARRAY 2021-08-31 14:26:52 +12:00
Thomas Fellner 7a13670594 Merge remote-tracking branch 'origin/master' into bugfix/fix-gen-key-sequence-test 2021-08-30 15:17:22 +02:00
rbygrave 6e10d641b2 Merge branch 'master' of github.com:ebean-orm/ebean 2021-08-30 22:43:06 +12:00
rbygrave c5dca69482 Tests only - update tests for sql server 2021-08-30 22:42:12 +12:00
rob 371a50176e Tidy tests only - ClusterTest and TestAggregateFormula 2021-08-30 22:39:11 +12:00
Roland PramlandJonas Pöhler 35bff7c3e7 FIX: Cache exist query results 2021-08-27 15:27:54 +02:00
Roland PramlandJonas Pöhler 83f8435000 FIX: Cache exist query results 2021-08-27 13:56:51 +02:00
Chen Zhang a1b4b1d8ca Improve MAVEN build Performance 2021-08-27 09:24:13 +08:00
Jonas Pöhler fad3e634d5 ADD: Formula properties can be used in orderBy and where clause 2021-08-26 17:15:38 +02:00
Jonas Pöhler 62712c976f ADD: BeanFindController supports postProcessing of retrieved entities 2021-08-26 14:37:51 +02:00
Rob BygraveandGitHub 56fed3ad87 Merge pull request #2331 from FOCONIS/pr/bugfix/npe_mutableNext_call
Fix for NPE in mutableNext in EBI
2021-08-25 10:38:32 +12:00
Rob BygraveandGitHub 9a65731be9 Merge pull request #2330 from FOCONIS/pr/enh/sort_order_in_bean_state
Make getSortOrder accessible in BeanState API
2021-08-25 10:36:29 +12:00
Rob BygraveandGitHub 34b011f683 Merge pull request #2329 from FOCONIS/pr/bugfix/oder_column_cache
@OrderdColum did not work properly with cached beans
2021-08-25 10:29:45 +12:00
Jonas Pöhler 69c721b66e ADD: getSortOrder accessible in BeanState API 2021-08-24 14:48:22 +02:00
Jonas Pöhler f2a578cd76 FIX: OrderdColums did not work properly with cache 2021-08-24 14:28:21 +02:00
rbygrave 1e34d65675 Tests only - update ddl review for Postgres 2021-08-24 15:59:58 +12:00
rbygrave 60db0b0999 #2328 - Postgres JSONB dirty checking - trim json 2021-08-24 15:58:29 +12:00
rbygrave 3bfb6dbc20 #2327 - Follow up and fix test TestQueryFilterMany 2021-08-24 15:04:52 +12:00
rbygrave d4d9bb204d #2327 - findSingleAttribute() on a ToMany path includes the id column
Follow up refactor SqlTreeBuilder
2021-08-24 15:04:23 +12:00
rbygrave bedb841fa9 #2327 - findSingleAttribute() on a ToMany path includes the id column
Follow up test changes
2021-08-24 14:52:54 +12:00
rbygrave c4c4663144 #2327 - findSingleAttribute() on a ToMany path includes the id column 2021-08-24 14:31:30 +12:00
rbygrave b392db866c Update tests for multi-platform testing 2021-08-22 17:48:19 +12:00
rbygrave 3556f9a42b Rename test helper StartPostgres (start docker postgres) 2021-08-22 16:39:44 +12:00
rbygrave 0345ca9f18 Update ddl review only - for #2326 2021-08-22 16:38:50 +12:00
rbygrave eacc4b907d Update ddl review only - for #2326 2021-08-22 15:55:45 +12:00
rbygrave 09cb5da3d3 #2326 - [ddl generator] Primary key constraint not generated for @IdClass 2021-08-22 15:55:08 +12:00
rbygrave b22791c15b Update ddl review for h2 2021-08-22 15:29:27 +12:00
rbygrave df3eda411a #2318 - Refactor internals - trim whitespace in deploy package 2021-08-22 13:59:08 +12:00
Jonas Pöhler 5b10c053de FIX: NPE when accessing mutableNext in EBI 2021-08-20 15:13:42 +02:00
rbygrave bf2d75e55e #2318 - Refactor internals - trim whitespace in deploy package 2021-08-20 17:51:01 +12:00
rbygrave 6f7efe6922 #2318 - Refactor internals - trim whitespace in deploy package 2021-08-20 17:39:11 +12:00
rbygrave 90e321ddbd #2318 - Refactor internals - trim whitespace in deploy package 2021-08-20 16:58:37 +12:00
Rob BygraveandGitHub 9649d71082 Merge pull request #2325 from FOCONIS/pr/bugfix/ordere_list_modify_listen_mode
Modification of a OneToMany-Relation with @OrderColumn was not detected
2021-08-20 15:29:22 +12:00
rbygrave 932337d83d Bump ebean-agent to 12.11.2 relating to fix for #2325 2021-08-20 13:09:59 +12:00
Jonas Pöhler 7e4bde8d34 FIX: Modification of a OneToMany-Relation with @OrderColumn was not detected 2021-08-19 17:11:31 +02:00
rbygrave 01e8b5f471 #2323 - Fallback to database query if redis connection fails 2021-08-18 20:41:09 +12:00
rbygrave 68a6da22be Fix imports on test TestQueryExists 2021-08-18 09:41:36 +12:00
rbygrave 986f3b5bca Merge branch 'master' of github.com:ebean-orm/ebean 2021-08-18 09:32:30 +12:00
rbygrave 4b1bb9d1ee #2324 - Bump ebean-datasource to 7.2 2021-08-18 09:11:24 +12:00
rbygrave ec340c0abe #2320 - Tidy only changes 2021-08-18 09:10:27 +12:00
rbygrave b062ec050c #2320 - Tidy only changes 2021-08-18 09:05:28 +12:00
rbygrave 965f4c6227 #2320 - Tidy only changes 2021-08-18 09:05:18 +12:00
Rob BygraveandGitHub bdc4022211 Merge pull request #2322 from FOCONIS/pr/bugfix/subquery_without_where
Fix for subqueries without where condition
2021-08-18 08:53:34 +12:00
rbygrave 7edfe3607d #2320 - When I use Redis for L2 cache, can I set the TTL of the cache key? 2021-08-18 08:43:06 +12:00
Jonas Pöhler e1731b87ec Merge remote-tracking branch 'ebean/master' into pr/bugfix/subquery_without_where 2021-08-17 16:07:02 +02:00
rbygrave ebadc92f63 #2319 - redis - ReentrantLock to replace synchronized(this) 2021-08-17 22:07:31 +12:00
rbygrave ea56ec7435 #2319 - redis - final classes 2021-08-17 22:06:48 +12:00
rbygrave 3b990fb6e1 #2319 - redis - remove unused PrefixKey 2021-08-17 22:03:33 +12:00
rbygrave 96b4fbea4b #2319 - redis - tidy whitespace 2021-08-17 22:02:57 +12:00
rbygrave 9161e17476 #2318 - Refactor internals - final classes in querybean package 2021-08-17 21:39:57 +12:00
rbygrave 190a2c47e9 #2318 - Refactor internals - final classes in cache package 2021-08-17 21:24:56 +12:00
rbygrave d096706685 #2318 - Refactor internals - final classes in internal api package 2021-08-17 21:03:53 +12:00
rbygrave 7521cb530e #2318 - Refactor internals - final classes in type packages 2021-08-17 20:48:15 +12:00
rbygrave dde9b507ce #2318 - Refactor internals - final classes in type packages 2021-08-17 20:09:27 +12:00
rbygrave 183416a640 #2318 - Delete unused ScalarTypeLongToTimestamp 2021-08-17 20:09:02 +12:00
rbygrave 826e8518ea #2318 - Refactor internals - final classes in type packages 2021-08-17 19:46:08 +12:00
rbygrave 55587b12aa #2318 - Refactor internals - final classes in el packages 2021-08-17 19:15:35 +12:00
rbygrave 285a94e5fe #2318 - Refactor internals - final classes in dto packages 2021-08-17 19:06:54 +12:00
rbygrave 16a05528b7 #2318 - Refactor internals - final classes in deploy packages etc 2021-08-17 19:00:55 +12:00
rbygrave b4f4ef3c1b #2318 - Refactor internals - final classes in server packages 2021-08-17 18:24:28 +12:00
rbygrave cd407ee467 #2318 - Refactor internals - final classes in changelog packages 2021-08-16 23:32:26 +12:00
rbygrave 9ee63144e5 #2318 - Refactor internals - final classes in core packages 2021-08-16 23:32:05 +12:00
rbygrave 0413d89a9e #2318 - Refactor internals - final classes in expression packages 2021-08-16 23:19:02 +12:00
rbygrave f33e54d8ba #2318 - Refactor internals - final classes in id and generated property packages 2021-08-16 22:53:38 +12:00
Rob BygraveandGitHub a2b19d46e1 Merge pull request #2316 from FOCONIS/pr/bugfix/json-null-formatValue
Fix: setting json values to null was throwing a NPE when persisting
2021-08-16 22:31:47 +12:00
rbygrave 4163b4dc25 #2317 - Plus test changes due to tidy whitespace on sql generation 2021-08-16 22:23:58 +12:00
rbygrave 12220d4322 #2317 - Incorrect SQL generated for @IdClass with fetch() on ToMany path 2021-08-16 22:21:49 +12:00
rbygrave 14262d4c25 #2317 - Incorrect SQL generated for @IdClass with fetch() on ToMany path 2021-08-16 22:20:21 +12:00
Jonas Pöhler (JPo) f3ec4a78c9 FIX: setting json values to null was throwing a NPE when persisting 2021-08-16 12:02:47 +02:00
rbygrave f7a0ae8b4a [maven-release-plugin] prepare for next development iteration 2021-08-16 09:23:18 +12:00
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
Thomas Fellner 9aa2fc824a second entity with SequenceGenerator added and test written 2021-08-13 08:36:25 +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
Thomas Fellner 531024b8b4 Fix test TestGeneratedKeys 2021-08-12 15:47:21 +02: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 4cebb367de FIX: subquery could not not have a where clause 2021-07-29 17:09:24 +02: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
Ryszard TrojnackiandGitHub 40a4546ac6 Merge pull request #4 from ebean-orm/master
Update to head
2020-11-28 13:16:05 +01: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
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
Tobias 85b21a02e8 Failing testcase for ebean query serializer 2020-10-12 13:23:49 +02:00
Tobias 4313fb6f58 Add .editorconfig 2020-10-12 11:51:44 +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 73ea91d4c9 [maven-release-plugin] prepare for next development iteration 2020-03-13 11:23:01 +13:00
rob bygrave 14839f0c0f [maven-release-plugin] prepare release ebean-postgis-12.2.1 2020-03-13 11:22:51 +13:00
rob bygrave db8f4e141d Bump to 12.2.1 2020-03-13 11:22:22 +13:00
rob bygrave 09fa406f84 [maven-release-plugin] prepare for next development iteration 2019-10-14 15:18:46 +13:00
rob bygrave 50d22ba357 [maven-release-plugin] prepare release ebean-postgis-12.1.1 2019-10-14 15:18:37 +13:00
rob bygrave c6f9d193be Bump to sync to Ebean 12.1.1 2019-10-14 15:18:01 +13:00
rob bygrave 5e1aa47c05 No effective change - update application-test.yml with dbSchema and ddlMode 2018-08-02 12:10:48 +12:00
rob bygrave 21dd8cee37 [maven-release-plugin] prepare for next development iteration 2018-08-02 11:51:10 +12:00
rob bygrave ece82996c2 [maven-release-plugin] prepare release ebean-postgis-11.1.1 2018-08-02 11:50:57 +12:00
rob bygrave fa520c95ea Bump to 11.1.1-SNAPSHOT 2018-08-02 11:50:25 +12:00
rob bygrave a6685141a4 #2 - No effective change - for running tests update to use docker postgis and application-test.yml 2018-08-02 11:48:49 +12:00
rob bygrave 78ab0ad923 No effective change - test logging config update 2018-08-02 11:44:25 +12:00
rob bygrave 4fb67a4c8c #1 - Support Ebean 11.x API - due to Ebean #1153 - Refactor move ExtraTypeFactory out of io.ebean.plugin into io.ebeaninternal 2018-08-02 11:43:52 +12:00
Rob Bygrave dd94e60d16 [maven-release-plugin] prepare for next development iteration 2016-12-13 21:59:31 +13:00
Rob Bygrave aa70e17657 [maven-release-plugin] prepare release ebean-postgis-0.1.3 2016-12-13 21:59:22 +13:00
Rob Bygrave 016cd3fb71 Update for Ebean 10.1.1 2016-12-13 21:58:56 +13:00
Rob Bygrave 17f28ba0aa [maven-release-plugin] prepare for next development iteration 2016-12-01 01:11:15 +13:00
Rob Bygrave ab88a879e9 [maven-release-plugin] prepare release ebean-postgis-0.1.2 2016-12-01 01:11:05 +13:00
Rob Bygrave 5b85f3c8dd Bump to java8 parent, update scm to ssh 2016-12-01 01:10:28 +13:00
Rob Bygrave 16a5100f35 Modify ScalarTypePgisBase to support the older protocol / objects when reading 2016-12-01 01:07:55 +13:00
Rob Bygrave 86b2c5d5b5 [maven-release-plugin] prepare for next development iteration 2016-10-25 22:53:16 +13:00
Rob Bygrave e0c3198ee6 [maven-release-plugin] prepare release ebean-postgis-0.1.1 2016-10-25 22:53:08 +13:00
Rob Bygrave 12bdd847b5 Update pom for initial release 2016-10-25 22:42:17 +13:00
Rob Bygrave 9860816ab7 Update 2016-10-25 22:36:38 +13:00
Rob Bygrave e17283726a Initial add 2016-10-21 02:37:13 +13:00
Rob Bygrave eff61ae5fc Initial commit 2016-10-21 01:32:47 +13:00
3347 changed files with 86826 additions and 29477 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
+1 -1
View File
@@ -34,7 +34,7 @@ env:
install: true
script:
- mvn clean test
- mvn -T 1C clean test
after_failure:
- ./.travis/print_surefire_reports
+1 -1
View File
@@ -293,6 +293,6 @@ ebean.tenant.schemaProvider
ebean.updateAllPropertiesInBatch
ebean.updateChangesOnly
ebean.updatesDeleteMissingChildren
ebean.useJavaxValidationNotNull
ebean.useValidationNotNull
ebean.useJtaTransactionManager
+1 -1
View File
@@ -36,7 +36,7 @@ Post questions or issues to the Ebean google group - https://groups.google.com/f
Goto [https://ebean.io/docs/](https://ebean.io/docs/)
## Maven cental links:
## Maven central links:
[Maven central - ebean](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22io.ebean%22%20AND%20a%3A%22ebean%22 "maven central ebean")
[Maven central - all related projects](http://search.maven.org/#search%7Cga%7C1%7Cebean "maven central all related projects")
+27 -37
View File
@@ -4,16 +4,13 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.5.2-SNAPSHOT</version>
<version>12.12.1</version>
</parent>
<name>ebean api</name>
<description>ebean api</description>
<artifactId>ebean-api</artifactId>
<properties>
<jackson-core.version>2.11.3</jackson-core.version>
<jackson-databind.version>2.11.3</jackson-databind.version>
</properties>
<dependencies>
<!--
@@ -23,14 +20,14 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
<version>1.7.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-config</artifactId>
<version>1.1</version>
<version>1.5</version>
</dependency>
<!--
@@ -40,45 +37,39 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsr305</artifactId>
<version>1.0</version>
<version>1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>persistence-api</artifactId>
<version>2.2.4</version>
<version>2.2.5</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-annotation</artifactId>
<version>6.13</version>
<version>7.3</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-types</artifactId>
<version>2.1</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-datasource</artifactId>
<version>6.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration</artifactId>
<version>12.1.4</version>
<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-core.version}</version>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
@@ -86,7 +77,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind.version}</version>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
@@ -106,14 +97,6 @@
<optional>true</optional>
</dependency>
<!-- provided scope to read validation annotations Size etc -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
@@ -121,21 +104,28 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
<tiles>
<tile>io.avaje.tile:moditech-module:1.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -1,33 +1,43 @@
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 thread pool service for executing of tasks asynchronously.
* Background executor service for executing of tasks asynchronously.
* <p>
* This service is used internally by Ebean for executing background tasks such
* as the {@link Query#findFutureList()} and also for executing background tasks
* periodically.
* </p>
* This service can be used to execute tasks in the background.
* <p>
* This service has been made available so you can use it for your application
* code if you want. It can be useful for some server caching implementations
* (background population and trimming of the cache etc).
* </p>
*
* @author rbygrave
* 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 task in the background.
* Execute a callable task in the background returning the Future.
*/
void execute(Runnable r);
<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.
@@ -36,27 +46,64 @@ public interface BackgroundExecutor {
* That is, this method has the same behaviour characteristics as
* {@link ScheduledExecutorService#scheduleWithFixedDelay(Runnable, long, long, TimeUnit)}
*/
void executePeriodically(Runnable r, long delay, TimeUnit unit);
@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.
*/
void executePeriodically(Runnable r, long initialDelay, long delay, TimeUnit unit);
@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
* whose get() method will return null upon completion
*/
ScheduledFuture<?> schedule(Runnable r, long delay, TimeUnit unit);
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> c, long delay, TimeUnit unit);
<V> ScheduledFuture<V> schedule(Callable<V> task, long delay, TimeUnit unit);
}
@@ -14,7 +14,7 @@ import java.util.Optional;
*
* public class CustomerFinder extends BeanFinder<Long,Customer> {
*
* Inject
* @Inject
* public CustomerFinder(Database database) {
* super(Customer.class, database);
* }
@@ -79,11 +79,11 @@ public abstract class BeanFinder<I,T> {
/**
* Creates an entity reference for this ID.
* <p>
* Equivalent to {@link Database#getReference(Class, Object)}
* Equivalent to {@link Database#reference(Class, Object)}
*/
@Nonnull
public T ref(I id) {
return db().getReference(type, id);
return db().reference(type, id);
}
/**
@@ -9,10 +9,10 @@ import java.util.Collection;
* <p>
* <pre>{@code
*
* Repository
* @Repository
* public class CustomerRepository extends BeanRepository<Long,Customer> {
*
* Inject
* @Inject
* public CustomerRepository(Database server) {
* super(Customer.class, server);
* }
@@ -57,7 +57,7 @@ public interface BeanState {
*
* // set loaded state on the email property to false so that
* // the email property is not included in a stateless update
* DB.getBeanState(user).setPropertyLoaded("email", false);
* DB.beanState(user).setPropertyLoaded("email", false);
*
* user.update();
*
@@ -72,25 +72,47 @@ public interface BeanState {
* bean.
* <p>
* Accessing another property will cause lazy loading to occur.
* </p>
*/
Set<String> getLoadedProps();
Set<String> loadedProps();
/**
* Deprecated migrate to loadedProps().
*/
@Deprecated
default Set<String> getLoadedProps() {
return loadedProps();
}
/**
* Return the set of changed properties.
*/
Set<String> getChangedProps();
Set<String> changedProps();
/**
* Deprecated migrate to changedProps().
*/
@Deprecated
default Set<String> getChangedProps() {
return changedProps();
}
/**
* Return a map of the updated properties and their new and old values.
*/
Map<String, ValuePair> getDirtyValues();
Map<String, ValuePair> dirtyValues();
/**
* Deprecated migrate to dirtyValues().
*/
@Deprecated
default Map<String, ValuePair> getDirtyValues() {
return dirtyValues();
}
/**
* Return true if the bean is readOnly.
* <p>
* If a setter is called on a readOnly bean it will throw an exception.
* </p>
*/
boolean isReadOnly();
@@ -114,8 +136,29 @@ public interface BeanState {
void resetForInsert();
/**
* Returns a map with load erros.
* Returns a map with load errors.
*/
@Nullable
Map<String, Exception> getLoadErrors();
Map<String, Exception> loadErrors();
/**
* Deprecated migrate to loadErrors().
*/
@Deprecated
default Map<String, Exception> getLoadErrors() {
return loadErrors();
}
/**
* Return the sort order value for an order column.
*/
int sortOrder();
/**
* Deprecated migrate to sortOrder().
*/
@Deprecated
default int getSortOrder() {
return sortOrder();
}
}
@@ -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();
}
+78 -10
View File
@@ -70,6 +70,13 @@ public final 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.
*/
@@ -119,8 +126,16 @@ public final class DB {
* an expression that uses OR like Expression e = Expr.or(..., ...);
* </p>
*/
public static ExpressionFactory expressionFactory() {
return getDefault().expressionFactory();
}
/**
* Deprecated migrate to expressionFactory().
*/
@Deprecated
public static ExpressionFactory getExpressionFactory() {
return getDefault().getExpressionFactory();
return expressionFactory();
}
/**
@@ -643,8 +658,16 @@ public final class DB {
* @param beanType the type of entity bean
* @param id the id value
*/
public static <T> T reference(Class<T> beanType, Object id) {
return getDefault().reference(beanType, id);
}
/**
* Deprecated migrate to beanId().
*/
@Deprecated
public static <T> T getReference(Class<T> beanType, Object id) {
return getDefault().getReference(beanType, id);
return reference(beanType, id);
}
/**
@@ -653,14 +676,12 @@ public final class DB {
* <ul>
* <li>asc - ascending order (which is the default)</li>
* <li>desc - Descending order</li>
* <li>nullsHigh - Treat null values as high/large values (which is the
* default)</li>
* <li>nullsHigh - Treat null values as high/large values (which is the default)</li>
* <li>nullsLow- Treat null values as low/very small values</li>
* </ul>
* <p>
* If you leave off any keywords the defaults are ascending order and treating
* nulls as high values.
* </p>
* <p>
* Note that the sorting uses a Comparator and Collections.sort(); and does
* not invoke a DB query.
@@ -1224,30 +1245,77 @@ public final class DB {
* This will return null if the bean is not an enhanced entity bean.
* </p>
*/
public static BeanState beanState(Object bean) {
return getDefault().beanState(bean);
}
/**
* Deprecated migrate to beanState().
*/
@Deprecated
public static BeanState getBeanState(Object bean) {
return getDefault().getBeanState(bean);
return beanState(bean);
}
/**
* Return the value of the Id property for a given bean.
*/
public static Object beanId(Object bean) {
return getDefault().beanId(bean);
}
/**
* Deprecated migrate to beanId().
*/
@Deprecated
public static Object getBeanId(Object bean) {
return getDefault().getBeanId(bean);
return beanId(bean);
}
/**
* Load and lock the bean using {@code select for update}.
* <p>
* This should be executed inside a transaction.
* <p>
* The bean needs to have an ID property set and can be a reference bean (only has ID)
* or partially or fully populated bean. This will load all the properties of the bean
* from the database using {@code select for update}.
*
* @param bean The entity bean that we wish to obtain a database lock on.
*/
public static void lock(Object bean) {
getDefault().lock(bean);
}
/**
* Deprecated migrate to cacheManager().
*/
@Deprecated
public static ServerCacheManager getServerCacheManager() {
return getDefault().cacheManager();
}
/**
* Return the manager of the level 2 cache ("L2" cache).
*/
public static ServerCacheManager getServerCacheManager() {
return getDefault().getServerCacheManager();
public static ServerCacheManager cacheManager() {
return getDefault().cacheManager();
}
/**
* Return the BackgroundExecutor service for asynchronous processing of
* queries.
*/
public static BackgroundExecutor backgroundExecutor() {
return getDefault().backgroundExecutor();
}
/**
* Deprecated migrate to backgroundExecutor().
*/
@Deprecated
public static BackgroundExecutor getBackgroundExecutor() {
return getDefault().getBackgroundExecutor();
return backgroundExecutor();
}
/**
+150 -13
View File
@@ -14,6 +14,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.persistence.OptimisticLockException;
import javax.persistence.PersistenceException;
import javax.sql.DataSource;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -119,24 +120,82 @@ public interface Database {
/**
* Return AutoTune which is used to control the AutoTune service at runtime.
*/
AutoTune getAutoTune();
AutoTune autoTune();
/**
* Deprecated migrate to autoTune().
*/
@Deprecated
default AutoTune getAutoTune() {
return autoTune();
}
/**
* Return the associated DataSource for this Database instance.
*/
DataSource dataSource();
/**
* Deprecated migrate to dataSource().
*/
@Deprecated
default DataSource getDataSource() {
return dataSource();
}
/**
* Return the associated read only DataSource for this Database instance (can be null).
*/
DataSource readOnlyDataSource();
/**
* Deprecated migrate to readOnlyDataSource().
*/
@Deprecated
default DataSource getReadOnlyDataSource() {
return readOnlyDataSource();
}
/**
* Return the name. This is used with {@link DB#byName(String)} to get a
* Database that was registered with the DB singleton.
*/
String getName();
String name();
/**
* Deprecated migrate to name().
*/
@Deprecated
default String getName() {
return name();
}
/**
* Return the ExpressionFactory for this database.
*/
ExpressionFactory getExpressionFactory();
ExpressionFactory expressionFactory();
/**
* Deprecated migrate to expressionFactory().
*/
@Deprecated
default ExpressionFactory getExpressionFactory() {
return expressionFactory();
}
/**
* Return the MetaInfoManager which is used to get meta data from the Database
* such as query execution statistics.
*/
MetaInfoManager getMetaInfoManager();
MetaInfoManager metaInfo();
/**
* Deprecated migrate to metaInfo().
*/
@Deprecated
default MetaInfoManager getMetaInfoManager() {
return metaInfo();
}
/**
* Return the platform used for this database instance.
@@ -155,12 +214,28 @@ public interface Database {
*
* @return platform for this database instance
*/
Platform getPlatform();
Platform platform();
/**
* Deprecated migrate to platform().
*/
@Deprecated
default Platform getPlatform() {
return platform();
}
/**
* Return the extended API intended for use by plugins.
*/
SpiServer getPluginApi();
SpiServer pluginApi();
/**
* Deprecated migrate to pluginApi().
*/
@Deprecated
default SpiServer getPluginApi() {
return pluginApi();
}
/**
* Return the BeanState for a given entity bean.
@@ -168,12 +243,28 @@ public interface Database {
* This will return null if the bean is not an enhanced entity bean.
* </p>
*/
BeanState getBeanState(Object bean);
BeanState beanState(Object bean);
/**
* Deprecated migrate to beanState().
*/
@Deprecated
default BeanState getBeanState(Object bean) {
return beanState(bean);
}
/**
* Return the value of the Id property for a given bean.
*/
Object getBeanId(Object bean);
Object beanId(Object bean);
/**
* Deprecated migrate to beanId().
*/
@Deprecated
default Object getBeanId(Object bean) {
return beanId(bean);
}
/**
* Set the Id value onto the bean converting the type of the id value if necessary.
@@ -185,7 +276,15 @@ public interface Database {
* @param bean The entity bean to set the id value on.
* @param id The id value to set.
*/
Object setBeanId(Object bean, Object id);
Object beanId(Object bean, Object id);
/**
* Deprecated migrate to beanId().
*/
@Deprecated
default Object setBeanId(Object bean, Object id) {
return beanId(bean, id);
}
/**
* Return a map of the differences between two objects of the same type.
@@ -851,7 +950,15 @@ public interface Database {
* @param id the id value
*/
@Nonnull
<T> T getReference(Class<T> beanType, Object id);
<T> T reference(Class<T> beanType, Object id);
/**
* Deprecated migrate to reference().
*/
@Deprecated
default <T> T getReference(Class<T> beanType, Object id) {
return reference(beanType, id);
}
/**
* Return the extended API for Database.
@@ -886,7 +993,7 @@ public interface Database {
* <pre>{@code
* public class Order { ...
*
* OneToMany(cascade=CascadeType.ALL, mappedBy="order")
* @OneToMany(cascade=CascadeType.ALL, mappedBy="order")
* List<OrderDetail> details;
* ...
* }
@@ -1420,13 +1527,29 @@ public interface Database {
/**
* Return the manager of the server cache ("L2" cache).
*/
ServerCacheManager getServerCacheManager();
ServerCacheManager cacheManager();
/**
* Deprecated migrate to cacheManager().
*/
@Deprecated
default ServerCacheManager getServerCacheManager() {
return cacheManager();
}
/**
* Return the BackgroundExecutor service for asynchronous processing of
* queries.
*/
BackgroundExecutor getBackgroundExecutor();
BackgroundExecutor backgroundExecutor();
/**
* Deprecated migrate to backgroundExecutor().
*/
@Deprecated
default BackgroundExecutor getBackgroundExecutor() {
return backgroundExecutor();
}
/**
* Return the JsonContext for reading/writing JSON.
@@ -1591,6 +1714,20 @@ public interface Database {
*/
<T> Set<String> validateQuery(Query<T> query);
/**
* Load and lock the bean using {@code select for update}.
* <p>
* This should be executed inside a transaction and results in the bean being loaded or
* refreshed from the database and a database row lock held via {@code select for update}.
* <p>
* The bean needs to have an ID property set and can be a reference bean (only has ID)
* or partially or fully populated bean. This will load all the properties of the bean
* from the database using {@code select for update} obtaining a database row lock (using WAIT).
*
* @param bean The entity bean that we wish to obtain a database lock on.
*/
void lock(Object bean);
/**
* Truncate all the given tables.
*/
@@ -16,23 +16,21 @@ import java.util.concurrent.locks.ReentrantLock;
* <p>
* This uses either DatabaseConfig or properties in the application.properties file to
* configure and create a Database instance.
* </p>
* <p>
* The Database instance can either be registered with the DB singleton or
* not. The DB singleton effectively holds a map of Database by a name.
* If the Database is registered with the DB singleton you can retrieve it
* later via {@link DB#byName(String)}.
* </p>
* <p>
* One Database can be nominated as the 'default/primary' Database. Many
* methods on the DB singleton such as {@link DB#find(Class)} are just a
* convenient way of using the 'default/primary' Database.
* </p>
*/
public class DatabaseFactory {
private static final ReentrantLock lock = new ReentrantLock(false);
private static final ReentrantLock lock = new ReentrantLock();
private static SpiContainer container;
private static String defaultServerName;
static {
EbeanVersion.getVersion();
@@ -47,7 +45,7 @@ public class DatabaseFactory {
public static void initialiseContainer(ContainerConfig containerConfig) {
lock.lock();
try {
getContainer(containerConfig);
container(containerConfig);
} finally {
lock.unlock();
}
@@ -59,7 +57,7 @@ public class DatabaseFactory {
public static Database create(String name) {
lock.lock();
try {
return getContainer(null).createServer(name);
return container(null).createServer(name);
} finally {
lock.unlock();
}
@@ -67,6 +65,16 @@ public class DatabaseFactory {
/**
* 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();
@@ -76,6 +84,12 @@ public class DatabaseFactory {
}
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());
}
@@ -108,7 +122,6 @@ public class DatabaseFactory {
* Shutdown gracefully all Database instances cleaning up any resources as required.
* <p>
* This is typically invoked via JVM shutdown hook and not explicitly called.
* </p>
*/
public static void shutdown() {
lock.lock();
@@ -120,15 +133,15 @@ public class DatabaseFactory {
}
private static Database createInternal(DatabaseConfig config) {
return getContainer(config.getContainerConfig()).createServer(config);
return container(config.getContainerConfig()).createServer(config);
}
/**
* Get the EbeanContainer initialising it if necessary.
* Return the SpiContainer initialising it if necessary.
*
* @param containerConfig the configuration controlling clustering communication
*/
private static SpiContainer getContainer(ContainerConfig containerConfig) {
private static SpiContainer container(ContainerConfig containerConfig) {
// thread safe in that all calling methods hold lock
if (container != null) {
return container;
@@ -15,8 +15,7 @@ import java.util.concurrent.locks.ReentrantLock;
*/
final class DbContext {
private static final Logger logger = LoggerFactory.getLogger(DbContext.class);
private static final Logger log = LoggerFactory.getLogger("io.ebean");
static {
EbeanVersion.getVersion();
}
@@ -27,7 +26,7 @@ final class DbContext {
private final HashMap<String, Database> syncMap = new HashMap<>();
private final ReentrantLock lock = new ReentrantLock(false);
private final ReentrantLock lock = new ReentrantLock();
/**
* The 'default' Database.
@@ -39,7 +38,6 @@ final class DbContext {
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());
}
@@ -54,7 +52,7 @@ final class DbContext {
throw new DataSourceConfigurationException(msg, e);
} catch (Throwable e) {
logger.error("Error trying to create the default Database", e);
log.error("Error trying to create the default Database", e);
throw new RuntimeException(e);
}
}
@@ -115,7 +113,7 @@ final class DbContext {
* Register a server so we can get it by its name.
*/
void register(Database server, boolean isDefault) {
registerWithName(server.getName(), server, isDefault);
registerWithName(server.name(), server, isDefault);
}
private void registerWithName(String name, Database server, boolean isDefault) {
@@ -12,7 +12,7 @@ import java.util.concurrent.locks.ReentrantLock;
*/
class DbPrimary {
private static final ReentrantLock lock = new ReentrantLock(false);
private static final ReentrantLock lock = new ReentrantLock();
private static String defaultServerName;
private static boolean skip;
@@ -2,8 +2,8 @@ package io.ebean;
import io.ebean.docstore.DocQueryContext;
import io.ebean.docstore.RawDoc;
import javax.annotation.Nullable;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -149,7 +149,7 @@ public interface DocumentStore {
* .setUseDocStore(true)
* .where()... // perhaps add predicates
* .findEachWhile(new Predicate<Order>() {
* Override
* @Override
* public void accept(Order bean) {
* // process the bean
*
+33 -1
View File
@@ -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>
+6 -6
View File
@@ -103,7 +103,7 @@ public final class Ebean {
* </p>
*/
public static ExpressionFactory getExpressionFactory() {
return getDefault().getExpressionFactory();
return getDefault().expressionFactory();
}
/**
@@ -346,7 +346,7 @@ public final class Ebean {
* <pre>{@code
* public class Order { ...
*
* OneToMany(cascade=CascadeType.ALL, mappedBy="order")
* @OneToMany(cascade=CascadeType.ALL, mappedBy="order")
* List<OrderDetail> details;
* ...
* }
@@ -642,7 +642,7 @@ public final class Ebean {
* @param id the id value
*/
public static <T> T getReference(Class<T> beanType, Object id) {
return getDefault().getReference(beanType, id);
return getDefault().reference(beanType, id);
}
/**
@@ -1201,14 +1201,14 @@ public final class Ebean {
* </p>
*/
public static BeanState getBeanState(Object bean) {
return getDefault().getBeanState(bean);
return getDefault().beanState(bean);
}
/**
* Return the manager of the server cache ("L2" cache).
*/
public static ServerCacheManager getServerCacheManager() {
return getDefault().getServerCacheManager();
return getDefault().cacheManager();
}
/**
@@ -1216,7 +1216,7 @@ public final class Ebean {
* queries.
*/
public static BackgroundExecutor getBackgroundExecutor() {
return getDefault().getBackgroundExecutor();
return getDefault().backgroundExecutor();
}
/**
@@ -2,13 +2,6 @@ package io.ebean;
import io.ebean.config.ContainerConfig;
import io.ebean.config.ServerConfig;
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;
/**
* Deprecated - please migrate to DatabaseFactory.
@@ -14,26 +14,75 @@ import java.util.Properties;
*/
public class EbeanVersion {
private static final Logger logger = LoggerFactory.getLogger(EbeanVersion.class);
private static final Logger log = LoggerFactory.getLogger("io.ebean");
/**
* Maintain the minimum ebean-agent version manually based on required ebean-agent bug fixes.
*/
private static final int MIN_AGENT_MAJOR_VERSION = 12;
private static final int MIN_AGENT_MINOR_VERSION = 12;
private static String version = "unknown";
static {
readVersion();
checkAgentVersion();
}
private static void readVersion() {
try {
Properties prop = new Properties();
try (InputStream in = DB.class.getResourceAsStream("/META-INF/maven/io.ebean/ebean/pom.properties")) {
try (InputStream in = ClassLoader.getSystemResourceAsStream("META-INF/maven/io.ebean/ebean-api/pom.properties")) {
if (in != null) {
prop.load(in);
in.close();
version = prop.getProperty("version");
version = readVersion(in);
}
}
logger.info("ebean version: {}", version);
log.info("ebean version: {}", version);
} catch (IOException e) {
logger.warn("Could not determine ebean version: {}", e.getMessage());
log.warn("Could not determine ebean version: {}", e.getMessage());
}
}
private static void checkAgentVersion() {
try {
try (InputStream in = ClassLoader.getSystemResourceAsStream("META-INF/maven/io.ebean/ebean-agent/pom.properties")) {
// often we only have ebean-agent during development (with build time enhancement), null is expected
if (in != null) {
String agentVersion = readVersion(in);
if (agentVersion != null) {
if (checkMinAgentVersion(agentVersion)) {
log.error("Expected minimum ebean-agent version {}.{}.0 but we have {}, please update the ebean-agent", MIN_AGENT_MAJOR_VERSION, MIN_AGENT_MINOR_VERSION, agentVersion);
}
}
}
}
} catch (IOException e) {
log.warn("Could not check minimum ebean-agent version {}.{}.0 required due to - {}", MIN_AGENT_MAJOR_VERSION, MIN_AGENT_MINOR_VERSION, e.getMessage());
}
}
/**
* Return true if ebean-agent is NOT at our minimum version.
*/
static boolean checkMinAgentVersion(String agentVersion) {
String[] versionSegments = agentVersion.split("\\.");
if (versionSegments.length != 3) {
return true;
} else {
int major = Integer.parseInt(versionSegments[0]);
int minor = Integer.parseInt(versionSegments[1]);
if (major < MIN_AGENT_MAJOR_VERSION) {
return true;
} else {
return major == MIN_AGENT_MAJOR_VERSION && minor < MIN_AGENT_MINOR_VERSION;
}
}
}
private static String readVersion(InputStream in) throws IOException {
Properties prop = new Properties();
prop.load(in);
in.close();
return prop.getProperty("version");
}
private EbeanVersion() {
// hide
}
+40 -45
View File
@@ -16,7 +16,7 @@ import java.util.Map;
* This provides a convenient way to create expressions for the default
* database.
* <p>
* See also {@link DB#getExpressionFactory()}
* See also {@link DB#expressionFactory()}
* </p>
* <p>
* Creates standard common expressions for using in a Query Where or Having
@@ -34,14 +34,14 @@ public class Expr {
* Equal To - property equal to the given value.
*/
public static Expression eq(String propertyName, Object value) {
return DB.getExpressionFactory().eq(propertyName, value);
return DB.expressionFactory().eq(propertyName, value);
}
/**
* Not Equal To - property not equal to the given value.
*/
public static Expression ne(String propertyName, Object value) {
return DB.getExpressionFactory().ne(propertyName, value);
return DB.expressionFactory().ne(propertyName, value);
}
/**
@@ -49,7 +49,7 @@ public class Expr {
* using a lower() function to make it case insensitive).
*/
public static Expression ieq(String propertyName, String value) {
return DB.getExpressionFactory().ieq(propertyName, value);
return DB.expressionFactory().ieq(propertyName, value);
}
/**
@@ -59,28 +59,28 @@ public class Expr {
* </p>
*/
public static Expression inRange(String propertyName, Object value1, Object value2) {
return DB.getExpressionFactory().inRange(propertyName, value1, value2);
return DB.expressionFactory().inRange(propertyName, value1, value2);
}
/**
* Between - property between the two given values.
*/
public static Expression between(String propertyName, Object value1, Object value2) {
return DB.getExpressionFactory().between(propertyName, value1, value2);
return DB.expressionFactory().between(propertyName, value1, value2);
}
/**
* Between - value between two given properties.
*/
public static Expression between(String lowProperty, String highProperty, Object value) {
return DB.getExpressionFactory().betweenProperties(lowProperty, highProperty, value);
return DB.expressionFactory().betweenProperties(lowProperty, highProperty, value);
}
/**
* Greater Than - property greater than the given value.
*/
public static Expression gt(String propertyName, Object value) {
return DB.getExpressionFactory().gt(propertyName, value);
return DB.expressionFactory().gt(propertyName, value);
}
/**
@@ -88,42 +88,42 @@ public class Expr {
* value.
*/
public static Expression ge(String propertyName, Object value) {
return DB.getExpressionFactory().ge(propertyName, value);
return DB.expressionFactory().ge(propertyName, value);
}
/**
* Less Than - property less than the given value.
*/
public static Expression lt(String propertyName, Object value) {
return DB.getExpressionFactory().lt(propertyName, value);
return DB.expressionFactory().lt(propertyName, value);
}
/**
* Less Than or Equal to - property less than or equal to the given value.
*/
public static Expression le(String propertyName, Object value) {
return DB.getExpressionFactory().le(propertyName, value);
return DB.expressionFactory().le(propertyName, value);
}
/**
* Is Null - property is null.
*/
public static Expression isNull(String propertyName) {
return DB.getExpressionFactory().isNull(propertyName);
return DB.expressionFactory().isNull(propertyName);
}
/**
* Is Not Null - property is not null.
*/
public static Expression isNotNull(String propertyName) {
return DB.getExpressionFactory().isNotNull(propertyName);
return DB.expressionFactory().isNotNull(propertyName);
}
/**
* Case insensitive {@link #exampleLike(Object)}
*/
public static ExampleExpression iexampleLike(Object example) {
return DB.getExpressionFactory().iexampleLike(example);
return DB.expressionFactory().iexampleLike(example);
}
/**
@@ -131,14 +131,14 @@ public class Expr {
* LikeType.RAW (you need to add you own wildcards % and _).
*/
public static ExampleExpression exampleLike(Object example) {
return DB.getExpressionFactory().exampleLike(example);
return DB.expressionFactory().exampleLike(example);
}
/**
* Create the query by Example expression specifying more options.
*/
public static ExampleExpression exampleLike(Object example, boolean caseInsensitive, LikeType likeType) {
return DB.getExpressionFactory().exampleLike(example, caseInsensitive, likeType);
return DB.expressionFactory().exampleLike(example, caseInsensitive, likeType);
}
/**
@@ -146,7 +146,7 @@ public class Expr {
* characters % (percentage) and _ (underscore).
*/
public static Expression like(String propertyName, String value) {
return DB.getExpressionFactory().like(propertyName, value);
return DB.expressionFactory().like(propertyName, value);
}
/**
@@ -155,14 +155,14 @@ public class Expr {
* a lower() function to make the expression case insensitive.
*/
public static Expression ilike(String propertyName, String value) {
return DB.getExpressionFactory().ilike(propertyName, value);
return DB.expressionFactory().ilike(propertyName, value);
}
/**
* Starts With - property like value%.
*/
public static Expression startsWith(String propertyName, String value) {
return DB.getExpressionFactory().startsWith(propertyName, value);
return DB.expressionFactory().startsWith(propertyName, value);
}
/**
@@ -170,14 +170,14 @@ public class Expr {
* lower() function to make the expression case insensitive.
*/
public static Expression istartsWith(String propertyName, String value) {
return DB.getExpressionFactory().istartsWith(propertyName, value);
return DB.expressionFactory().istartsWith(propertyName, value);
}
/**
* Ends With - property like %value.
*/
public static Expression endsWith(String propertyName, String value) {
return DB.getExpressionFactory().endsWith(propertyName, value);
return DB.expressionFactory().endsWith(propertyName, value);
}
/**
@@ -185,14 +185,14 @@ public class Expr {
* function to make the expression case insensitive.
*/
public static Expression iendsWith(String propertyName, String value) {
return DB.getExpressionFactory().iendsWith(propertyName, value);
return DB.expressionFactory().iendsWith(propertyName, value);
}
/**
* Contains - property like %value%.
*/
public static Expression contains(String propertyName, String value) {
return DB.getExpressionFactory().contains(propertyName, value);
return DB.expressionFactory().contains(propertyName, value);
}
/**
@@ -200,42 +200,42 @@ public class Expr {
* function to make the expression case insensitive.
*/
public static Expression icontains(String propertyName, String value) {
return DB.getExpressionFactory().icontains(propertyName, value);
return DB.expressionFactory().icontains(propertyName, value);
}
/**
* For collection properties that are empty (have not existing elements).
*/
public static Expression isEmpty(String propertyName) {
return DB.getExpressionFactory().isEmpty(propertyName);
return DB.expressionFactory().isEmpty(propertyName);
}
/**
* For collection properties that are not empty (have existing elements).
*/
public static Expression isNotEmpty(String propertyName) {
return DB.getExpressionFactory().isNotEmpty(propertyName);
return DB.expressionFactory().isNotEmpty(propertyName);
}
/**
* In - property has a value in the array of values.
*/
public static Expression in(String propertyName, Object[] values) {
return DB.getExpressionFactory().in(propertyName, values);
return DB.expressionFactory().in(propertyName, values);
}
/**
* In - using a subQuery.
*/
public static Expression in(String propertyName, Query<?> subQuery) {
return DB.getExpressionFactory().in(propertyName, subQuery);
return DB.expressionFactory().in(propertyName, subQuery);
}
/**
* In - property has a value in the collection of values.
*/
public static Expression in(String propertyName, Collection<?> values) {
return DB.getExpressionFactory().in(propertyName, values);
return DB.expressionFactory().in(propertyName, values);
}
/**
@@ -272,14 +272,14 @@ public class Expr {
* }</pre>
*/
public static Expression inOrEmpty(String propertyName, Collection<?> values) {
return DB.getExpressionFactory().inOrEmpty(propertyName, values);
return DB.expressionFactory().inOrEmpty(propertyName, values);
}
/**
* Id Equal to - ID property is equal to the value.
*/
public static Expression idEq(Object value) {
return DB.getExpressionFactory().idEq(value);
return DB.expressionFactory().idEq(value);
}
/**
@@ -292,7 +292,7 @@ public class Expr {
* @param propertyMap a map keyed by property names.
*/
public static Expression allEq(Map<String, Object> propertyMap) {
return DB.getExpressionFactory().allEq(propertyMap);
return DB.expressionFactory().allEq(propertyMap);
}
/**
@@ -303,7 +303,7 @@ public class Expr {
* </p>
*/
public static Expression raw(String raw, Object value) {
return DB.getExpressionFactory().raw(raw, value);
return DB.expressionFactory().raw(raw, value);
}
/**
@@ -314,53 +314,48 @@ public class Expr {
* </p>
*/
public static Expression raw(String raw, Object[] values) {
return DB.getExpressionFactory().raw(raw, values);
return DB.expressionFactory().raw(raw, values);
}
/**
* Add raw expression with no parameters.
*/
public static Expression raw(String raw) {
return DB.getExpressionFactory().raw(raw);
return DB.expressionFactory().raw(raw);
}
/**
* And - join two expressions with a logical and.
*/
public static Expression and(Expression expOne, Expression expTwo) {
return DB.getExpressionFactory().and(expOne, expTwo);
return DB.expressionFactory().and(expOne, expTwo);
}
/**
* Or - join two expressions with a logical or.
*/
public static Expression or(Expression expOne, Expression expTwo) {
return DB.getExpressionFactory().or(expOne, expTwo);
return DB.expressionFactory().or(expOne, expTwo);
}
/**
* Negate the expression (prefix it with NOT).
*/
public static Expression not(Expression exp) {
return DB.getExpressionFactory().not(exp);
return DB.expressionFactory().not(exp);
}
/**
* Return a list of expressions that will be joined by AND's.
*/
public static <T> Junction<T> conjunction(Query<T> query) {
return DB.getExpressionFactory().conjunction(query);
return DB.expressionFactory().conjunction(query);
}
/**
* Return a list of expressions that will be joined by OR's.
*/
public static <T> Junction<T> disjunction(Query<T> query) {
return DB.getExpressionFactory().disjunction(query);
return DB.expressionFactory().disjunction(query);
}
}
@@ -200,7 +200,7 @@ public interface ExpressionFactory {
Expression gtOrNull(String propertyName, Object value);
/**
* Greater than or Equal to OR Null <code> >= or null </code>
* 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.
@@ -227,7 +227,7 @@ public interface ExpressionFactory {
Expression ltOrNull(String propertyName, Object value);
/**
* Less Than or Equal to OR Null <code> <= or null </code>
* 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.
@@ -169,6 +169,28 @@ public interface ExpressionList<T> {
*/
UpdateQuery<T> asUpdate();
/**
* Execute the query with the given lock type and WAIT.
* <p>
* Note that <code>forUpdate()</code> is the same as
* <code>withLock(LockType.UPDATE)</code>.
* <p>
* Provides us with the ability to explicitly use Postgres
* SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks.
*/
Query<T> withLock(Query.LockType lockType);
/**
* Execute the query with the given lock type and lock wait.
* <p>
* Note that <code>forUpdateNoWait()</code> is the same as
* <code>withLock(LockType.UPDATE, LockWait.NOWAIT)</code>.
* <p>
* Provides us with the ability to explicitly use Postgres
* SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks.
*/
Query<T> withLock(Query.LockType lockType, Query.LockWait lockWait);
/**
* Execute using "for update" clause which results in the DB locking the record.
*/
@@ -285,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.
@@ -887,7 +916,7 @@ public interface ExpressionList<T> {
ExpressionList<T> gtOrNull(String propertyName, Object value);
/**
* Greater Than or Equal to OR Null - <code> >= or null </code>.
* Greater Than or Equal to OR Null - ({@code >= or null }).
*/
ExpressionList<T> geOrNull(String propertyName, Object value);
@@ -908,7 +937,7 @@ public interface ExpressionList<T> {
ExpressionList<T> ltOrNull(String propertyName, Object value);
/**
* Less Than or Equal to OR Null - <code> <= or null </code>.
* Less Than or Equal to OR Null - ({@code <= or null }).
*/
ExpressionList<T> leOrNull(String propertyName, Object value);
@@ -1642,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.
@@ -159,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>
+138 -185
View File
@@ -3,30 +3,13 @@ package io.ebean;
import java.io.Serializable;
/**
* Defines the configuration options for a "query fetch" or a
* "lazy loading fetch". This gives you the ability to use multiple smaller
* queries to populate an object graph as opposed to a single large query.
* <p>
* The primary goal is to provide efficient ways of loading complex object
* graphs avoiding SQL Cartesian product and issues around populating object
* graphs that have multiple *ToMany relationships.
* </p>
* <p>
* It also provides the ability to control the lazy loading queries (batch size,
* selected properties and fetches) to avoid N+1 queries etc.
* <p>
* There can also be cases loading across a single OneToMany where 2 SQL queries
* using Ebean FetchConfig.query() can be more efficient than one SQL query.
* When the "One" side is wide (lots of columns) and the cardinality difference
* is high (a lot of "Many" beans per "One" bean) then this can be more
* efficient loaded as 2 SQL queries.
* </p>
* 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();
*
* // Find Orders join details using a single SQL query
* }</pre>
* <p>
* Example: Using a "query join" instead of a "fetch join" we instead use 2 SQL queries
@@ -37,103 +20,13 @@ import java.io.Serializable;
* // This will use 2 SQL queries to build this object graph
* List<Order> list =
* DB.find(Order.class)
* .fetch("details", new FetchConfig().query())
* .fetch("details", FetchConfig.ofQuery())
* .findList();
*
* // query 1) find order
* // query 2) find orderDetails where order.id in (?,?...) // first 100 order id's
*
* }</pre>
* <p>
* Example: Using 2 "query joins"
* </p>
* <p>
* <pre>{@code
*
* // This will use 3 SQL queries to build this object graph
* List<Order> list =
* DB.find(Order.class)
* .fetch("details", new FetchConfig().query())
* .fetch("customer", new FetchConfig().queryFirst(5))
* .findList();
*
* // query 1) find order
* // query 2) find orderDetails where order.id in (?,?...) // first 100 order id's
* // query 3) find customer where id in (?,?,?,?,?) // first 5 customers
*
* }</pre>
* <p>
* Example: Using "query joins" and partial objects
* </p>
* <p>
*
* <pre>{@code
* // This will use 3 SQL queries to build this object graph
* List<Order> list =
* DB.find(Order.class)
* .select("status, shipDate")
* .fetch("details", "quantity, price", new FetchConfig().query())
* .fetch("details.product", "sku, name")
* .fetch("customer", "name", new FetchConfig().queryFirst(5))
* .fetch("customer.contacts")
* .fetch("customer.shippingAddress")
* .findList();
*
* // query 1) find order (status, shipDate)
* // query 2) find orderDetail (quantity, price) fetch product (sku, name) where
* // order.id in (?,? ...)
* // query 3) find customer (name) fetch contacts (*) fetch shippingAddress (*)
* // where id in (?,?,?,?,?)
*
* // Note: the fetch of "details.product" is automatically included into the
* // fetch of "details"
* //
* // Note: the fetch of "customer.contacts" and "customer.shippingAddress"
* // are automatically included in the fetch of "customer"
* }</pre>
* <p>
* You can use query() and lazy together on a single join. The query is executed
* immediately and the lazy defines the batch size to use for further lazy
* loading (if lazy loading is invoked).
* </p>
* <p>
* <pre>{@code
*
* List<Order> list =
* DB.find(Order.class)
* .fetch("customer", new FetchConfig().query(10).lazy(5))
* .findList();
*
* // query 1) find order
* // query 2) find customer where id in (?,?,?,?,?,?,?,?,?,?) // first 10 customers
* // .. then if lazy loading of customers is invoked
* // .. use a batch size of 5 to load the customers
*
* }</pre>
* <p>
* <p>
* Example of controlling the lazy loading query:
* </p>
* <p>
* This gives us the ability to optimise the lazy loading query for a given use
* case.
* </p>
* <p>
* <pre>{@code
*
* List<Order> list = DB.find(Order.class)
* .fetch("customer","name", new FetchConfig().lazy(5))
* .fetch("customer.contacts","contactName, phone, email")
* .fetch("customer.shippingAddress")
* .where().eq("status",Order.Status.NEW)
* .findList();
*
* // query 1) find order where status = Order.Status.NEW
* //
* // .. if lazy loading of customers is invoked
* // .. use a batch size of 5 to load the customers
*
* }</pre>
*
* @author mario
* @author rbygrave
@@ -142,149 +35,209 @@ public class FetchConfig implements Serializable {
private static final long serialVersionUID = 1L;
private int lazyBatchSize = -1;
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 queryBatchSize = -1;
private boolean queryAll;
private boolean cache;
private int mode;
private int batchSize;
private int hashCode;
/**
* Construct the fetch configuration object.
* 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;
}
/**
* Specify that this path should be lazy loaded using the default batch load
* size.
* 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() {
this.lazyBatchSize = 0;
this.queryAll = false;
return this;
return mutate(LAZY_MODE, 0);
}
/**
* Specify that this path should be lazy loaded with a specified batch size.
*
* @param lazyBatchSize the batch size for lazy loading
* Deprecated - migrate to FetchConfig.ofLazy(batchSize).
*/
public FetchConfig lazy(int lazyBatchSize) {
this.lazyBatchSize = lazyBatchSize;
this.queryAll = false;
return this;
@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.
* </p>
*/
@Deprecated
public FetchConfig query() {
this.queryBatchSize = 0;
this.queryAll = true;
return this;
}
/**
* Eagerly fetch the beans fetching the beans from the L2 bean cache
* and using the DB for beans not in the cache.
*/
public FetchConfig cache() {
this.cache = true;
this.queryBatchSize = 0;
this.queryAll = true;
return this;
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>
* <p>
* This will load all beans on this path eagerly unless a {@link #lazy(int)}
* is also used.
* </p>
*
* @param queryBatchSize the batch size used to load beans on this path
* @param batchSize the batch size used to load beans on this path
*/
public FetchConfig query(int queryBatchSize) {
this.queryBatchSize = queryBatchSize;
// queryAll true as long as a lazy batch size has not already been set
this.queryAll = (lazyBatchSize == -1);
return this;
@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.
* </p>
*
* @param queryBatchSize the number of parent beans this path is populated for
* @param batchSize the number of parent beans this path is populated for
*/
public FetchConfig queryFirst(int queryBatchSize) {
this.queryBatchSize = queryBatchSize;
this.queryAll = false;
return this;
@Deprecated
public FetchConfig queryFirst(int batchSize) {
return query(batchSize);
}
/**
* Return the batch size for lazy loading.
* 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.
*/
public int getLazyBatchSize() {
return lazyBatchSize;
@Deprecated
public FetchConfig cache() {
return mutate(CACHE_MODE, 100);
}
/**
* Return the batch size for separate query load.
* Return the batch size for fetching.
*/
public int getQueryBatchSize() {
return queryBatchSize;
public int getBatchSize() {
return batchSize;
}
/**
* Return true if the query fetch should fetch 'all' rather than just the
* 'first' batch.
*/
public boolean isQueryAll() {
return queryAll;
}
/**
* Return true if this uses L2 bean cache.
* Return true if the fetch should use the L2 cache.
*/
public boolean isCache() {
return cache;
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;
FetchConfig that = (FetchConfig) o;
if (lazyBatchSize != that.lazyBatchSize) return false;
if (queryBatchSize != that.queryBatchSize) return false;
if (cache != that.cache) return false;
return queryAll == that.queryAll;
return (hashCode == ((FetchConfig) o).hashCode);
}
@Override
public int hashCode() {
int result = lazyBatchSize;
result = 92821 * result + queryBatchSize;
result = 92821 * result + (queryAll ? 1 : 0);
result = 92821 * result + (cache ? 1 : 0);
return result;
return hashCode;
}
}
+4 -4
View File
@@ -37,7 +37,7 @@ import java.util.List;
* }
* }
*
* Entity
* @Entity
* public class Customer extends BaseModel {
*
* public static final CustomerFinder find = new CustomerFinder();
@@ -80,7 +80,7 @@ public class Finder<I, T> {
* // ... add extra customer specific finder methods
* }
*
* Entity
* @Entity
* public class Customer extends BaseModel {
*
* public static final CustomerFinder find = new CustomerFinder();
@@ -137,11 +137,11 @@ public class Finder<I, T> {
/**
* Creates an entity reference for this ID.
* <p>
* Equivalent to {@link Database#getReference(Class, Object)}
* Equivalent to {@link Database#reference(Class, Object)}
*/
@Nonnull
public T ref(I id) {
return db().getReference(type, id);
return db().reference(type, id);
}
/**
+6 -6
View File
@@ -32,16 +32,16 @@ import io.ebean.bean.EntityBean;
* // Typically there is a common base model that has some
* // common properties like the ones below
*
* MappedSuperclass
* @MappedSuperclass
* public class BaseModel extends Model {
*
* Id Long id;
* @Id Long id;
*
* Version Long version;
* @Version Long version;
*
* WhenCreated Timestamp whenCreated;
* @WhenCreated Timestamp whenCreated;
*
* WhenUpdated Timestamp whenUpdated;
* @WhenUpdated Timestamp whenUpdated;
*
* ...
* }
@@ -52,7 +52,7 @@ import io.ebean.bean.EntityBean;
*
* // Extend the mappedSuperclass
*
* Entity Table(name="o_account")
* @Entity @Table(name="o_account")
* public class Customer extends BaseModel {
*
* String name;
@@ -1,11 +1,9 @@
package io.ebeaninternal.json;
import java.io.Serializable;
package io.ebean;
/**
* Owner object notified when a modification is detected.
*/
public interface ModifyAwareOwner extends Serializable {
public interface ModifyAwareType {
/**
* Return true if the value is considered dirty.
@@ -16,11 +14,6 @@ public interface ModifyAwareOwner extends Serializable {
/**
* Marks the object as modified.
*/
void markAsModified();
/**
* Reset the dirty state to clean.
*/
void resetMarkedDirty();
void setMarkedDirty(boolean markedDirty);
}
+4 -11
View File
@@ -16,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;
@@ -69,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;
}
@@ -98,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.
*/
@@ -207,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);
}
@@ -249,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;
@@ -415,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);
@@ -467,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) {
+28 -15
View File
@@ -3,6 +3,7 @@ package io.ebean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* Holds a list of value object pairs.
@@ -18,7 +19,7 @@ import java.util.List;
*
* // where a bean is annotated with a complex
* // natural key made of several properties
* Cache(naturalKey = {"store","code","sku"})
* @Cache(naturalKey = {"store","code","sku"})
*
*
* Pairs pairs = new Pairs("sku", "code");
@@ -62,15 +63,14 @@ import java.util.List;
* </p>
* <pre>{@code sql
*
* create index ix_name on table_name ((sku || '-' || code));
* create index ix_name on table_name (sku || '-' || code);
*
* }</pre>
*/
public class Pairs {
public final class Pairs {
private final String property0;
private final String property1;
private final List<Entry> entries = new ArrayList<>();
/**
@@ -111,54 +111,70 @@ public class Pairs {
/**
* Return the first property name.
*/
public String getProperty0() {
public String property0() {
return property0;
}
/**
* Return the second property name.
*/
public String getProperty1() {
public String property1() {
return property1;
}
/**
* Return all the value pairs.
*/
public List<Entry> getEntries() {
public List<Entry> entries() {
return Collections.unmodifiableList(entries);
}
/**
* Return the separator character used with DB varchar concatenation to combine the 2 values.
*/
public String getConcatSeparator() {
public String concatSeparator() {
return concatSeparator;
}
/**
* Set the separator character used with DB varchar concatenation to combine the 2 values.
*/
public Pairs setConcatSeparator(String concatSeparator) {
public Pairs concatSeparator(String concatSeparator) {
this.concatSeparator = concatSeparator;
return this;
}
/**
* Deprecated migrate to concatSeparator()
*/
@Deprecated
public Pairs setConcatSeparator(String concatSeparator) {
return concatSeparator(concatSeparator);
}
/**
* Return a suffix used with DB varchar concatenation to combine the 2 values.
*/
public String getConcatSuffix() {
public String concatSuffix() {
return concatSuffix;
}
/**
* Add a suffix used with DB varchar concatenation to combine the 2 values.
*/
public Pairs setConcatSuffix(String concatSuffix) {
public Pairs concatSuffix(String concatSuffix) {
this.concatSuffix = concatSuffix;
return this;
}
/**
* Deprecated migrate to concatSuffix()
*/
@Deprecated
public Pairs setConcatSuffix(String concatSuffix) {
return concatSuffix(concatSuffix);
}
@Override
public String toString() {
return "p0:" + property0 + " p1:" + property1 + " entries:" + entries;
@@ -208,16 +224,13 @@ public class Pairs {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Entry that = (Entry) o;
return a.equals(that.a) && b.equals(that.b);
}
@Override
public int hashCode() {
int result = a.hashCode();
result = 92821 * result + b.hashCode();
return result;
return Objects.hash(a, b);
}
}
}
+94 -26
View File
@@ -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>
@@ -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>
@@ -779,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
*
@@ -798,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.
@@ -808,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)
@@ -1613,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();
@@ -1622,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();
@@ -1630,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();
@@ -1640,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.
*/
+5 -5
View File
@@ -41,14 +41,14 @@ package io.ebean;
* <h3>Example OrderAggregate</h3>
* <pre>{@code
* ...
* // Sql indicates to that this bean
* // @Sql indicates to that this bean
* // is based on RawSql rather than a table
*
* Entity
* Sql
* @Entity
* @Sql
* public class OrderAggregate {
*
* OneToOne
* @OneToOne
* Order order;
*
* Double totalAmount;
@@ -107,7 +107,7 @@ package io.ebean;
*
* List<OrderAggregate> orders = DB.find(OrderAggregate.class)
* .setRawSql(rawSql)
* .fetch("order", "status,orderDate", new FetchConfig().query())
* .fetch("order", "status,orderDate", FetchConfig.ofQuery())
* .fetch("order.customer", "name")
* .where().gt("order.id", 0)
* .having().gt("totalAmount", 20)
@@ -22,7 +22,7 @@ import java.sql.SQLException;
* //
* class CustomerMapper implements RowMapper<CustomerDto> {
*
* Override
* @Override
* public CustomerDto map(ResultSet rset, int rowNum) throws SQLException {
*
* long id = rset.getLong(1);
@@ -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.
@@ -365,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);
}
}
@@ -2,8 +2,8 @@ package io.ebean;
import io.ebean.annotation.DocStoreMode;
import io.ebean.annotation.PersistBatch;
import io.ebean.config.DocStoreConfig;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.DocStoreConfig;
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>
@@ -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 #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,14 +397,11 @@ 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.DatabaseConfig#setPersistBatchOnCascade(PersistBatch)
@@ -422,15 +424,19 @@ 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 setGetGeneratedKeys(boolean getGeneratedKeys);
@@ -449,13 +455,11 @@ 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 setFlushOnMixed(boolean batchFlushOnMixed);
@@ -473,7 +477,6 @@ 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 setFlushOnQuery(boolean batchFlushOnQuery);
@@ -490,7 +493,6 @@ public interface Transaction extends AutoCloseable {
* should be flushed prior to executing a query.
* <p>
* The default is for this to be true.
* </p>
*/
boolean isFlushOnQuery();
@@ -507,7 +509,6 @@ public interface Transaction extends AutoCloseable {
* 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>
@@ -519,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;
/**
@@ -533,29 +534,32 @@ 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();
Connection connection();
/**
* Deprecated migrate to connection().
*/
@Deprecated
default Connection getConnection() {
return connection();
}
/**
* 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.
*/
+6 -6
View File
@@ -13,23 +13,23 @@ package io.ebean;
* </p>
* <pre>{@code
* ...
* NamedUpdates(value = {
* NamedUpdate(
* @NamedUpdates(value = {
* @NamedUpdate(
* name = "setTitle",
* notifyCache = false,
* update = "update topic set title = :title, postCount = :count where id = :id"),
* NamedUpdate(
* @NamedUpdate(
* name = "setPostCount",
* notifyCache = false,
* update = "update f_topic set post_count = :postCount where id = :id"),
* NamedUpdate(
* @NamedUpdate(
* name = "incrementPostCount",
* notifyCache = false,
* update = "update Topic set postCount = postCount + 1 where id = :id")
* //update = "update f_topic set post_count = post_count + 1 where id = :id")
* })
* Entity
* Table(name = "f_topic")
* @Entity
* @Table(name = "f_topic")
* public class Topic {
* ...
* }
@@ -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);
@@ -11,7 +11,7 @@ public interface BeanCollectionLoader {
/**
* Return the name of the associated Database.
*/
String getName();
String name();
/**
* Invoke the lazy loading for this bean collection.
@@ -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.
*/
@@ -32,39 +32,52 @@ public final class EntityBeanIntercept implements Serializable {
private static final int STATE_REFERENCE = 1;
private static final int STATE_LOADED = 2;
private transient final ReentrantLock lock = new ReentrantLock(false);
/**
* 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.
*/
@@ -74,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 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;
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.
*/
@@ -246,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;
}
@@ -386,8 +395,18 @@ public final class EntityBeanIntercept implements Serializable {
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;
}
@@ -460,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;
}
@@ -494,7 +517,7 @@ public final class EntityBeanIntercept implements Serializable {
* Return the number of properties.
*/
public int getPropertyLength() {
return owner._ebean_getPropertyNames().length;
return flags.length;
}
/**
@@ -569,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.
*/
@@ -578,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;
@@ -591,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;
}
@@ -652,7 +679,7 @@ 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
props.add((prefix == null ? getProperty(i) : prefix + getProperty(i)));
} else if ((flags[i] & FLAG_EMBEDDED_DIRTY) != 0) {
@@ -670,7 +697,7 @@ public final class EntityBeanIntercept implements Serializable {
String[] names = owner._ebean_getPropertyNames();
int len = getPropertyLength();
for (int i = 0; i < len; i++) {
if ((flags[i] & FLAG_CHANGED_PROP) != 0) {
if (isChangedProp(i)) {
if (propertyNames.contains(names[i])) {
return true;
}
@@ -698,7 +725,7 @@ 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);
@@ -720,7 +747,7 @@ 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);
@@ -755,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,7 +843,7 @@ public final class EntityBeanIntercept implements Serializable {
}
// For stand alone reference bean or after deserialisation lazy load
// using the ebeanServer. Synchronise only on the bean.
loadBeanInternal(loadProperty, database.getPluginApi().beanLoader());
loadBeanInternal(loadProperty, database.pluginApi().beanLoader());
return;
}
} finally {
@@ -931,10 +958,14 @@ public final class EntityBeanIntercept implements Serializable {
* OneToMany and ManyToMany only set loaded state.
*/
public void preSetterMany(boolean interceptField, int propertyIndex, Object oldValue, Object newValue) {
if (readOnly) {
throw new IllegalStateException("This bean is readOnly");
if (state == STATE_NEW) {
setLoadedProperty(propertyIndex);
} else {
if (readOnly) {
throw new IllegalStateException("This bean is readOnly");
}
setChangeLoaded(propertyIndex);
}
setLoadedProperty(propertyIndex);
}
private void setChangedPropertyValue(int propertyIndex, boolean setDirtyState, Object origValue) {
@@ -973,7 +1004,6 @@ public final class EntityBeanIntercept implements Serializable {
}
}
/**
* Check for primitive boolean.
*/
@@ -1123,7 +1153,7 @@ public final class EntityBeanIntercept implements Serializable {
*/
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;
@@ -1149,4 +1179,61 @@ 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;
}
final MutableValueNext next = mutableNext[propertyIndex];
return next != null ? next.content() : null;
}
}
@@ -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);
@@ -82,7 +80,6 @@ public interface PersistenceContext {
* <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 {
@@ -10,7 +10,7 @@ import java.util.concurrent.locks.ReentrantLock;
*/
public abstract class SingleBeanLoader implements BeanLoader {
private final ReentrantLock lock = new ReentrantLock(false);
private final ReentrantLock lock = new ReentrantLock();
protected final Database database;
@@ -20,7 +20,7 @@ public abstract class SingleBeanLoader implements BeanLoader {
@Override
public String getName() {
return database.getName();
return database.name();
}
@Override
@@ -39,7 +39,7 @@ public abstract class SingleBeanLoader implements BeanLoader {
@Override
public void loadBean(EntityBeanIntercept ebi) {
database.getPluginApi().loadBeanL2(ebi);
database.pluginApi().loadBeanL2(ebi);
}
}
@@ -53,7 +53,7 @@ public abstract class SingleBeanLoader implements BeanLoader {
@Override
public void loadBean(EntityBeanIntercept ebi) {
database.getPluginApi().loadBeanRef(ebi);
database.pluginApi().loadBeanRef(ebi);
}
}
@@ -67,7 +67,7 @@ public abstract class SingleBeanLoader implements BeanLoader {
@Override
public void loadBean(EntityBeanIntercept ebi) {
database.getPluginApi().loadBean(ebi);
database.pluginApi().loadBean(ebi);
}
}
}
@@ -13,9 +13,7 @@ import java.util.Set;
public class QueryCacheEntry {
private final Object value;
private final Set<String> dependentTables;
private final long timestamp;
/**
+19 -3
View File
@@ -10,17 +10,17 @@ import java.util.Set;
* Represents part of the "L2" server side cache.
* <p>
* This is used to cache beans or query results (bean collections).
* </p>
* <p>
* There are 2 ServerCache's for each bean type. One is used as the 'bean cache'
* which holds beans of a given type. The other is the 'query cache' holding
* query results for a given type.
* </p>
*/
public interface ServerCache {
/**
* Get values for many keys.
*/
default Map<Object, Object> getAll(Set<Object> keys) {
Map<Object, Object> map = new LinkedHashMap<>();
for (Object key : keys) {
Object value = get(key);
@@ -73,6 +73,14 @@ public interface ServerCache {
/**
* Return the hit ratio the cache is currently getting.
*/
default int hitRatio() {
return getHitRatio();
}
/**
* Deprecated migrate to hitRatio().
*/
@Deprecated
int getHitRatio();
/**
@@ -80,6 +88,14 @@ public interface ServerCache {
*
* @param reset if true the statistics are reset.
*/
default ServerCacheStatistics statistics(boolean reset) {
return getStatistics(reset);
}
/**
* Deprecated migrate to statistics().
*/
@Deprecated
ServerCacheStatistics getStatistics(boolean reset);
/**
@@ -21,7 +21,15 @@ public interface ServerCacheManager {
* rather than background processing.
* </p>
*/
boolean isLocalL2Caching();
boolean localL2Caching();
/**
* Deprecated migrate to localL2Caching().
*/
@Deprecated
default boolean isLocalL2Caching() {
return localL2Caching();
}
/**
* Return all the cache regions.
@@ -36,37 +44,78 @@ public interface ServerCacheManager {
*
* @param regions A region name or comma delimited list of region names.
*/
void setEnabledRegions(String regions);
void enabledRegions(String regions);
/**
* Deprecated migrate to enabledRegions().
*/
@Deprecated
default void setEnabledRegions(String regions) {
enabledRegions(regions);
}
/**
* Enable or disable all the cache regions.
*/
void setAllRegionsEnabled(boolean enabled);
void allRegionsEnabled(boolean enabled);
/**
* Return the cache region by name. Typically to enable or disable the region.
* Deprecated migrate to allRegionsEnabled().
*/
ServerCacheRegion getRegion(String name);
@Deprecated
default void setAllRegionsEnabled(boolean enabled) {
allRegionsEnabled(enabled);
}
/**
* Return the cache region by name. Typically, to enable or disable the region.
*/
ServerCacheRegion region(String name);
@Deprecated
default ServerCacheRegion getRegion(String name) {
return region(name);
}
/**
* Return the cache for mapping natural keys to id values.
*/
ServerCache getNaturalKeyCache(Class<?> beanType);
ServerCache naturalKeyCache(Class<?> beanType);
@Deprecated
default ServerCache getNaturalKeyCache(Class<?> beanType) {
return naturalKeyCache(beanType);
}
/**
* Return the cache for beans of a particular type.
*/
ServerCache getBeanCache(Class<?> beanType);
ServerCache beanCache(Class<?> beanType);
@Deprecated
default ServerCache getBeanCache(Class<?> beanType) {
return beanCache(beanType);
}
/**
* Return the cache for associated many properties of a bean type.
*/
ServerCache getCollectionIdsCache(Class<?> beanType, String propertyName);
ServerCache collectionIdsCache(Class<?> beanType, String propertyName);
@Deprecated
default ServerCache getCollectionIdsCache(Class<?> beanType, String propertyName) {
return collectionIdsCache(beanType, propertyName);
}
/**
* Return the cache for query results of a particular type of bean.
*/
ServerCache getQueryCache(Class<?> beanType);
ServerCache queryCache(Class<?> beanType);
@Deprecated
default ServerCache getQueryCache(Class<?> beanType) {
return queryCache(beanType);
}
/**
* This clears both the bean and query cache for a given type.
@@ -18,7 +18,6 @@ public class ServerCacheOptions {
* Construct with no set options.
*/
public ServerCacheOptions() {
}
/**
@@ -73,7 +72,6 @@ public class ServerCacheOptions {
* Return a copy of this object.
*/
public ServerCacheOptions copy() {
ServerCacheOptions copy = new ServerCacheOptions();
copy.maxSize = maxSize;
copy.maxIdleSecs = maxIdleSecs;
@@ -8,7 +8,15 @@ public interface ServerCacheRegion {
/**
* Return the region name.
*/
String getName();
String name();
/**
* Deprecated migrate to name().
*/
@Deprecated
default String getName() {
return name();
}
/**
* Return true if the cache region is enabled.
@@ -16,7 +16,7 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
private static final long serialVersionUID = 3365725236140187588L;
protected final ReentrantLock lock = new ReentrantLock(false);
protected final ReentrantLock lock = new ReentrantLock();
protected boolean readOnly;
@@ -63,7 +63,7 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
*/
AbstractBeanCollection(BeanCollectionLoader loader, EntityBean ownerBean, String propertyName) {
this.loader = loader;
this.ebeanServerName = loader.getName();
this.ebeanServerName = loader.name();
this.ownerBean = ownerBean;
this.propertyName = propertyName;
this.readOnly = ownerBean != null && ownerBean._ebean_getIntercept().isReadOnly();
@@ -111,7 +111,7 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
public void setLoader(BeanCollectionLoader loader) {
this.registeredWithLoadContext = true;
this.loader = loader;
this.ebeanServerName = loader.getName();
this.ebeanServerName = loader.name();
}
@Override
@@ -135,6 +135,11 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
// Support for modify additions deletions etc - ManyToMany
// ---------------------------------------------------------
@Override
public boolean hasModifications() {
return modifyHolder != null && modifyHolder.hasModifications();
}
@Override
public ModifyListenMode getModifyListening() {
return modifyListenMode;
@@ -145,7 +150,6 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
*/
@Override
public void setModifyListening(ModifyListenMode mode) {
this.modifyListenMode = mode;
this.modifyListening = mode != null && ModifyListenMode.NONE != mode;
if (modifyListening) {
@@ -87,7 +87,7 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
@Override
public void internalAddWithCheck(Object bean) {
if (list == null || !containsInstance(bean)) {
if (list == null || bean == null || !containsInstance(bean)) {
internalAdd(bean);
}
}
@@ -198,10 +198,9 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
}
if (list == null) {
sb.append("deferred ");
} else {
sb.append("size[").append(list.size()).append("] ");
sb.append("list").append(list).append("");
sb.append("list").append(list);
}
return sb.toString();
}
@@ -77,7 +77,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
}
public void internalPutWithCheck(Object key, Object bean) {
if (map == null || !map.containsKey(key)) {
if (map == null || key == null || !map.containsKey(key)) {
internalPut(key, bean);
}
}
@@ -175,10 +175,6 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
/**
* Returns the map entrySet.
* <p>
* This is because the key values may need to be set against the details (so
* they don't need to be set twice).
* </p>
*/
@Override
public Collection<?> getActualEntries() {
@@ -194,7 +190,6 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
}
if (map == null) {
sb.append("deferred ");
} else {
sb.append("size[").append(map.size()).append("]");
sb.append(" map").append(map);
@@ -243,17 +238,12 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
}
@Override
@SuppressWarnings({"unchecked"})
public Set<Entry<K, E>> entrySet() {
init();
if (isReadOnly()) {
return Collections.unmodifiableSet(map.entrySet());
}
if (modifyListening) {
Set<Entry<K, E>> s = map.entrySet();
return new ModifySet(this, s);
}
return map.entrySet();
return modifyListening ? new ModifyEntrySet<>(this, map.entrySet()) : map.entrySet();
}
@Override
@@ -274,8 +264,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
if (isReadOnly()) {
return Collections.unmodifiableSet(map.keySet());
}
// we don't really care about modifications to the ketSet?
return map.keySet();
return modifyListening ? new ModifyKeySet<>(this, map.keySet()) : map.keySet();
}
@Override
@@ -346,11 +335,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
if (isReadOnly()) {
return Collections.unmodifiableCollection(map.values());
}
if (modifyListening) {
Collection<E> c = map.values();
return new ModifyCollection<>(this, c);
}
return map.values();
return modifyListening ? new ModifyCollection<>(this, map.values()) : map.values();
}
@Override
@@ -70,9 +70,8 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
@Override
public void internalAddWithCheck(Object bean) {
if (set == null || !set.contains(bean)) {
internalAdd(bean);
}
// set add() already de-dups so just add it
internalAdd(bean);
}
@Override
@@ -177,7 +176,6 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
}
if (set == null) {
sb.append("deferred ");
} else {
sb.append("size[").append(set.size()).append("]");
sb.append(" set").append(set);
@@ -20,7 +20,7 @@ public final class CopyOnFirstWriteList<E> extends AbstractList<E> implements Li
private static final long serialVersionUID = 1L;
private final ReentrantLock lock = new ReentrantLock(false);
private final ReentrantLock lock = new ReentrantLock();
/**
* The underlying List implementation.
@@ -25,7 +25,7 @@ class ModifyCollection<E> implements Collection<E> {
* The owner is notified of the additions and removals.
* </p>
*/
public ModifyCollection(BeanCollection<E> owner, Collection<E> c) {
ModifyCollection(BeanCollection<E> owner, Collection<E> c) {
this.owner = owner;
this.c = c;
}
@@ -0,0 +1,131 @@
package io.ebean.common;
import java.util.*;
/**
* Handles the Entry Set for BeanMap.
*/
class ModifyEntrySet<K, E> implements Set<Map.Entry<K, E>> {
private final BeanMap<K, E> owner;
private final Set<Map.Entry<K, E>> entrySet;
ModifyEntrySet(BeanMap<K, E> owner, Set<Map.Entry<K, E>> entrySet) {
this.owner = owner;
this.entrySet = entrySet;
}
@Override
public int size() {
return entrySet.size();
}
@Override
public boolean isEmpty() {
return entrySet.isEmpty();
}
@Override
public boolean contains(Object o) {
return entrySet.contains(o);
}
@Override
public Object[] toArray() {
return entrySet.toArray();
}
@Override
public <T> T[] toArray(T[] a) {
return entrySet.toArray(a);
}
@Override
public boolean containsAll(Collection<?> entries) {
return entrySet.containsAll(entries);
}
@Override
public void clear() {
owner.clear();
}
@Override
public boolean add(Map.Entry<K, E> entry) {
throw new UnsupportedOperationException();
}
@Override
public boolean addAll(Collection<? extends Map.Entry<K, E>> c) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("rawtypes")
@Override
public boolean remove(Object o) {
if (o instanceof Map.Entry) {
Map.Entry entry = (Map.Entry) o;
final E val = owner.get(entry.getKey());
if (Objects.equals(val, entry.getValue())) {
owner.remove(entry.getKey());
return true;
}
}
return false;
}
@Override
public boolean retainAll(Collection<?> entries) {
boolean modified = false;
final Iterator<Map.Entry<K, E>> it = iterator();
while (it.hasNext()) {
if (!entries.contains(it.next())) {
it.remove();
modified = true;
}
}
return modified;
}
@Override
public boolean removeAll(Collection<?> entries) {
boolean modified = false;
for (Object entry : entries) {
modified |= remove(entry);
}
return modified;
}
@Override
public Iterator<Map.Entry<K, E>> iterator() {
return new EntrySetIterator(new ArrayList<>(entrySet).iterator());
}
class EntrySetIterator implements Iterator<Map.Entry<K, E>> {
private final Iterator<Map.Entry<K, E>> iterator;
private Map.Entry<K, E> entry;
EntrySetIterator(Iterator<Map.Entry<K, E>> iterator) {
this.iterator = iterator;
}
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public Map.Entry<K, E> next() {
entry = iterator.next();
return entry;
}
@Override
public void remove() {
owner.remove(entry.getKey());
iterator.remove();
}
}
}
@@ -3,9 +3,7 @@ package io.ebean.common;
import io.ebean.bean.EntityBean;
import java.io.Serializable;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.*;
/**
* Holds sets of additions and deletions from a 'owner' List Set or Map.
@@ -23,19 +21,19 @@ class ModifyHolder<E> implements Serializable {
/**
* Deletions list for manyToMany persistence.
*/
private Set<E> modifyDeletions = new LinkedHashSet<>();
private Map<E,Object> modifyDeletions = new IdentityHashMap<>();
/**
* Additions list for manyToMany persistence.
*/
private Set<E> modifyAdditions = new LinkedHashSet<>();
private Map<E,Object> modifyAdditions = new IdentityHashMap<>();
private boolean touched;
void reset() {
touched = false;
modifyDeletions = new LinkedHashSet<>();
modifyAdditions = new LinkedHashSet<>();
modifyDeletions = new IdentityHashMap<>();
modifyAdditions = new IdentityHashMap<>();
}
/**
@@ -50,51 +48,46 @@ class ModifyHolder<E> implements Serializable {
}
private boolean undoDeletion(E bean) {
return (bean != null) && modifyDeletions.remove(bean);
return (bean != null) && modifyDeletions.remove(bean) != null;
}
void modifyAddition(E bean) {
if (bean != null) {
touched = true;
if (bean instanceof EntityBean) {
((EntityBean) bean)._ebean_getIntercept().setDeletedFromCollection(false);
}
// If it is to delete then just remove the deletion
if (!undoDeletion(bean)) {
// Insert
modifyAdditions.add(bean);
modifyAdditions.put(bean, bean);
}
}
}
private boolean undoAddition(Object bean) {
return (bean != null) && modifyAdditions.remove(bean);
return (bean != null) && modifyAdditions.remove(bean) != null;
}
@SuppressWarnings("unchecked")
void modifyRemoval(Object bean) {
if (bean != null) {
touched = true;
if (bean instanceof EntityBean) {
((EntityBean) bean)._ebean_getIntercept().setDeletedFromCollection(true);
}
// If it is to be added then just remove the addition
if (!undoAddition(bean)) {
modifyDeletions.add((E) bean);
modifyDeletions.put((E) bean, bean);
}
}
}
Set<E> getModifyAdditions() {
return modifyAdditions;
return modifyAdditions.keySet();
}
Set<E> getModifyRemovals() {
return modifyDeletions;
return modifyDeletions.keySet();
}
/**
@@ -0,0 +1,126 @@
package io.ebean.common;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
/**
* Handle the Key Set for BeanMap.
*/
class ModifyKeySet<E> implements Set<E> {
private final Set<E> keySet;
private final BeanMap<E, ?> owner;
ModifyKeySet(BeanMap<E, ?> owner, Set<E> keySet) {
this.owner = owner;
this.keySet = keySet;
}
@Override
public int size() {
return keySet.size();
}
@Override
public boolean isEmpty() {
return keySet.isEmpty();
}
@Override
public boolean contains(Object o) {
return keySet.contains(o);
}
@Override
public Object[] toArray() {
return keySet.toArray();
}
@Override
public <T> T[] toArray(T[] a) {
return keySet.toArray(a);
}
@Override
public boolean add(E key) {
throw new UnsupportedOperationException();
}
@Override
public boolean addAll(Collection<? extends E> keys) {
throw new UnsupportedOperationException();
}
@Override
public boolean remove(Object o) {
return owner.remove(o) != null;
}
@Override
public boolean containsAll(Collection<?> keys) {
return keySet.containsAll(keys);
}
@Override
public void clear() {
owner.clear();
}
@Override
public Iterator<E> iterator() {
return new KeySetIterator<>(new ArrayList<>(keySet).iterator());
}
@Override
public boolean retainAll(Collection<?> keys) {
return keysMatch(keys, false);
}
@Override
public boolean removeAll(Collection<?> keys) {
return keysMatch(keys, true);
}
private boolean keysMatch(Collection<?> keys, boolean containsMatch) {
boolean changed = false;
final Iterator<E> iterator = iterator();
while (iterator.hasNext()) {
final E key = iterator.next();
if (keys.contains(key) == containsMatch) {
iterator.remove();
changed = true;
}
}
return changed;
}
class KeySetIterator<K> implements Iterator<K> {
private final Iterator<K> iterator;
private K key;
KeySetIterator(Iterator<K> iterator) {
this.iterator = iterator;
}
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public K next() {
key = iterator.next();
return key;
}
@Override
public void remove() {
owner.remove(key);
iterator.remove();
}
}
}
@@ -1,24 +0,0 @@
package io.ebean.common;
import io.ebean.bean.BeanCollection;
import java.util.Set;
/**
* Wraps a Set for the purposes of notifying removals and additions to the
* BeanCollection owner.
* <p>
* This is required for persisting ManyToMany objects. Additions and removals
* become inserts and deletes to the intersection table.
* </p>
*/
class ModifySet<E> extends ModifyCollection<E> implements Set<E> {
/**
* Create with an Owner that is notified of any additions or deletions.
*/
public ModifySet(BeanCollection<E> owner, Set<E> s) {
super(owner, s);
}
}
@@ -7,6 +7,8 @@ import javax.persistence.DiscriminatorValue;
import javax.persistence.Inheritance;
import javax.persistence.Table;
import static io.ebean.util.StringHelper.isNull;
/**
* Provides some base implementation for NamingConventions.
*
@@ -78,10 +80,16 @@ public abstract class AbstractNamingConvention implements NamingConvention {
@Override
public String getSequenceName(String rawTableName, String pkColumn) {
final String tableNameUnquoted = databasePlatform.unQuote(rawTableName);
TableName tableName = new TableName(rawTableName);
String seqName = seqName(pkColumn, tableName.getName());
return tableName.withCatalogAndSchema(seqName);
}
private String seqName(String pkColumn, String tableName) {
final String tableNameUnquoted = unQuote(tableName);
String seqName = sequenceFormat.replace("{table}", tableNameUnquoted);
pkColumn = (pkColumn == null) ? "" : databasePlatform.unQuote(pkColumn);
return seqName.replace("{column}", pkColumn);
pkColumn = (pkColumn == null) ? "" : unQuote(pkColumn);
return quoteIdentifiers(seqName.replace("{column}", pkColumn));
}
/**
@@ -216,15 +224,13 @@ public abstract class AbstractNamingConvention implements NamingConvention {
|| AnnotationUtil.has(supCls, DiscriminatorValue.class);
}
@Override
public TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable) {
StringBuilder buffer = new StringBuilder();
buffer.append(lhsTable.getName());
buffer.append(unQuote(lhsTable.getName()));
buffer.append("_");
String rhsTableName = rhsTable.getName();
String rhsTableName = unQuote(rhsTable.getName());
if (rhsTableName.indexOf('_') < rhsPrefixLength) {
// trim off a xx_ prefix if there is one
rhsTableName = rhsTableName.substring(rhsTableName.indexOf('_') + 1);
@@ -238,7 +244,13 @@ public abstract class AbstractNamingConvention implements NamingConvention {
buffer.setLength(maxTableNameLength);
}
return new TableName(lhsTable.getCatalog(), lhsTable.getSchema(), buffer.toString());
String tableName = quoteIdentifiers(buffer.toString());
return new TableName(lhsTable.getCatalog(), lhsTable.getSchema(), tableName);
}
@Override
public String deriveM2MColumn(String tableName, String dbColumn) {
return quoteIdentifiers(unQuote(tableName) +"_" + unQuote(dbColumn));
}
/**
@@ -255,14 +267,29 @@ public abstract class AbstractNamingConvention implements NamingConvention {
return null;
}
@Override
public String getTableName(String catalog, String schema, String name) {
StringBuilder sb = new StringBuilder();
if (!isNull(catalog)) {
sb.append(quoteIdentifiers(catalog)).append(".");
}
if (!isNull(schema)) {
sb.append(quoteIdentifiers(schema)).append(".");
}
return sb.append(quoteIdentifiers(name)).toString();
}
/**
* Replace back ticks (if they are used) with database platform specific
* quoted identifiers.
* Replace back ticks (if they are used) with database platform specific quoted identifiers.
*/
protected String quoteIdentifiers(String s) {
return databasePlatform.convertQuotedIdentifiers(s);
}
private String unQuote(String val) {
return databasePlatform.unQuote(val);
}
/**
* Checks string is null or empty .
*/
@@ -1,10 +1,5 @@
package io.ebean.config;
import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
/**
* Helper to find classes taking into account the context class loader.
*/
@@ -26,20 +21,6 @@ public class ClassLoadConfig {
this.context = new ClassLoaderContext(classLoader);
}
/**
* Return true if the Java.time types are available and should be supported.
*/
public boolean isJavaTimePresent() {
return isPresent("java.time.LocalDate");
}
/**
* Return true if Java7 is present.
*/
public boolean isJava7Present() {
return isPresent("java.nio.file.Path");
}
/**
* Return true if the Joda types are available and should be supported.
*/
@@ -54,6 +35,13 @@ public class ClassLoadConfig {
return isPresent("javax.validation.constraints.NotNull");
}
/**
* Return true if jakarta validation annotations like Size and NotNull are present.
*/
public boolean isJakartaValidationAnnotationsPresent() {
return isPresent("jakarta.validation.constraints.NotNull");
}
/**
* Return true if javax PostConstruct annotation is present (maybe not in java9).
* If not we don't support PostConstruct lifecycle events.
@@ -84,22 +72,14 @@ public class ClassLoadConfig {
* Return a new instance of the class using the default constructor.
*/
public Object newInstance(String className) {
try {
Class<?> cls = forName(className);
return cls.newInstance();
return cls.getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new IllegalArgumentException("Error constructing " + className, e);
}
}
/**
* Return the resources for the given name.
*/
public Enumeration<URL> getResources(String name) throws IOException {
return context.getResources(name);
}
/**
* Return true if the given class is present.
*/
@@ -136,9 +116,7 @@ public class ClassLoadConfig {
* Optional - if set only use this classLoader (no fallback).
*/
protected final ClassLoader preferredLoader;
protected final ClassLoader contextLoader;
protected final ClassLoader callerLoader;
ClassLoaderContext(ClassLoader preferredLoader) {
@@ -152,15 +130,7 @@ public class ClassLoadConfig {
return (loader != null) ? loader : callerLoader;
}
Enumeration<URL> getResources(String name) throws IOException {
if (preferredLoader != null) {
return preferredLoader.getResources(name);
}
return contextLoader().getResources(name);
}
Class<?> forName(String name) throws ClassNotFoundException {
if (preferredLoader != null) {
// only use the explicitly set classLoader
return classForName(name, preferredLoader);
@@ -1,7 +1,7 @@
package io.ebean.config;
import io.ebean.config.dbplatform.DbType;
import io.ebean.annotation.Platform;
import io.ebean.config.dbplatform.DbType;
/**
* Custom mappings for DB types that override the default.
@@ -2,46 +2,28 @@ package io.ebean.config;
import com.fasterxml.jackson.core.JsonFactory;
import io.avaje.config.Config;
import io.ebean.DatabaseFactory;
import io.ebean.PersistenceContextScope;
import io.ebean.Query;
import io.ebean.Transaction;
import io.ebean.annotation.Encrypted;
import io.ebean.annotation.PersistBatch;
import io.ebean.annotation.Platform;
import io.ebean.*;
import io.ebean.annotation.*;
import io.ebean.cache.ServerCachePlugin;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.config.dbplatform.DbEncrypt;
import io.ebean.config.dbplatform.DbType;
import io.ebean.config.dbplatform.IdType;
import io.ebean.datasource.DataSourceConfig;
import io.ebean.event.BeanFindController;
import io.ebean.event.BeanPersistController;
import io.ebean.event.BeanPersistListener;
import io.ebean.event.BeanPostConstructListener;
import io.ebean.event.BeanPostLoad;
import io.ebean.event.BeanQueryAdapter;
import io.ebean.event.BulkTableEventListener;
import io.ebean.event.ServerConfigStartup;
import io.ebean.event.*;
import io.ebean.event.changelog.ChangeLogListener;
import io.ebean.event.changelog.ChangeLogPrepare;
import io.ebean.event.changelog.ChangeLogRegister;
import io.ebean.event.readaudit.ReadAuditLogger;
import io.ebean.event.readaudit.ReadAuditPrepare;
import io.ebean.migration.MigrationRunner;
import io.ebean.util.StringHelper;
import javax.persistence.EnumType;
import javax.sql.DataSource;
import java.time.Clock;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.ServiceLoader;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
* The configuration used for creating a Database.
@@ -82,7 +64,6 @@ import java.util.ServiceLoader;
*/
public class DatabaseConfig {
/**
* The Database name.
*/
@@ -191,6 +172,11 @@ public class DatabaseConfig {
*/
private JsonConfig.Include jsonInclude = JsonConfig.Include.ALL;
/**
* The default mode used for {@code @DbJson} with Jackson ObjectMapper.
*/
private MutationDetection jsonMutationDetection = MutationDetection.HASH;
/**
* The database platform name. Used to imply a DatabasePlatform to use.
*/
@@ -230,6 +216,12 @@ public class DatabaseConfig {
*/
private String historyTableSuffix = "_history";
/**
* When true explicit transactions beans that have been made dirty will be
* automatically persisted via update on flush.
*/
private boolean autoPersistUpdates;
/**
* Use for transaction scoped batch mode.
*/
@@ -277,6 +269,25 @@ public class DatabaseConfig {
private String ddlSeedSql;
private String ddlHeader;
/**
* Mode used to check non-null columns added via migration have a default value specified etc.
*/
private boolean ddlStrictMode = true;
/**
* Comma and equals delimited key/value placeholders to replace in DDL scripts.
*/
private String ddlPlaceholders;
/**
* Map of key/value placeholders to replace in DDL scripts.
*/
private Map<String, String> ddlPlaceholderMap;
private boolean runMigration;
/**
* When true L2 bean cache use is skipped after a write has occurred on a transaction.
*/
@@ -289,6 +300,8 @@ public class DatabaseConfig {
*/
private ExternalTransactionManager externalTransactionManager;
private boolean skipDataSourceCheck;
/**
* The data source (if programmatically provided).
*/
@@ -322,11 +335,6 @@ public class DatabaseConfig {
*/
private String dbSchema;
/**
* The db migration config (migration resource path etc).
*/
private DbMigrationConfig migrationConfig = new DbMigrationConfig();
/**
* The ClassLoadConfig used to detect Joda, Java8, Jackson etc and create plugin instances given a className.
*/
@@ -375,8 +383,8 @@ public class DatabaseConfig {
private List<BeanPostConstructListener> postConstructListeners = new ArrayList<>();
private List<BeanPersistListener> persistListeners = new ArrayList<>();
private List<BeanQueryAdapter> queryAdapters = new ArrayList<>();
private List<BulkTableEventListener> bulkTableEventListeners = new ArrayList<>();
private List<ServerConfigStartup> configStartupListeners = new ArrayList<>();
private final List<BulkTableEventListener> bulkTableEventListeners = new ArrayList<>();
private final List<ServerConfigStartup> configStartupListeners = new ArrayList<>();
/**
* By default inserts are included in the change log.
@@ -384,42 +392,26 @@ public class DatabaseConfig {
private boolean changeLogIncludeInserts = true;
private ChangeLogPrepare changeLogPrepare;
private ChangeLogListener changeLogListener;
private ChangeLogRegister changeLogRegister;
private boolean changeLogAsync = true;
private ReadAuditLogger readAuditLogger;
private ReadAuditPrepare readAuditPrepare;
private EncryptKeyManager encryptKeyManager;
private EncryptDeployManager encryptDeployManager;
private Encryptor encryptor;
private boolean dbOffline;
private DbEncrypt dbEncrypt;
private boolean dbOffline;
private ServerCachePlugin serverCachePlugin;
/**
* The default PersistenceContextScope used if one is not explicitly set on a query.
*/
private PersistenceContextScope persistenceContextScope = PersistenceContextScope.TRANSACTION;
private JsonFactory jsonFactory;
private boolean localTimeWithNanos;
private boolean durationWithNanos;
private int maxCallStack = 5;
private boolean transactionRollbackOnChecked = true;
// configuration for the background executor service (thread pool)
@@ -473,7 +465,7 @@ public class DatabaseConfig {
* Should the javax.validation.constraints.NotNull enforce a notNull column in DB.
* If set to false, use io.ebean.annotation.NotNull or Column(nullable=true).
*/
private boolean useJavaxValidationNotNull = true;
private boolean useValidationNotNull = true;
/**
* Generally we want to perform L2 cache notification in the background and not impact
@@ -482,14 +474,23 @@ public class DatabaseConfig {
private boolean notifyL2CacheInForeground;
/**
* Set to true to support query plan capture.
* Set to true to enable bind capture required for query plan capture.
*/
private boolean collectQueryPlans;
private boolean queryPlanEnable;
/**
* The default threshold in micros for collecting query plans.
*/
private long collectQueryPlanThresholdMicros = Long.MAX_VALUE;
private long queryPlanThresholdMicros = Long.MAX_VALUE;
/**
* Set to true to enable automatic periodic query plan capture.
*/
private boolean queryPlanCapture;
private long queryPlanCapturePeriodSecs = 60 * 10; // 10 minutes
private long queryPlanCaptureMaxTimeMillis = 10_000; // 10 seconds
private int queryPlanCaptureMaxCount = 10;
private QueryPlanListener queryPlanListener;
/**
* The time in millis used to determine when a query is alerted for being slow.
@@ -706,6 +707,24 @@ public class DatabaseConfig {
this.jsonInclude = jsonInclude;
}
/**
* Return the default MutableDetection to use with {@code @DbJson} using Jackson.
*
* @see DbJson#mutationDetection()
*/
public MutationDetection getJsonMutationDetection() {
return jsonMutationDetection;
}
/**
* Set the default MutableDetection to use with {@code @DbJson} using Jackson.
*
* @see DbJson#mutationDetection()
*/
public void setJsonMutationDetection(MutationDetection jsonMutationDetection) {
this.jsonMutationDetection = jsonMutationDetection;
}
/**
* Return the name of the Database.
*/
@@ -880,6 +899,20 @@ public class DatabaseConfig {
this.tenantCatalogProvider = tenantCatalogProvider;
}
/**
* Return true if dirty beans are automatically persisted.
*/
public boolean isAutoPersistUpdates() {
return autoPersistUpdates;
}
/**
* Set to true if dirty beans are automatically persisted.
*/
public void setAutoPersistUpdates(boolean autoPersistUpdates) {
this.autoPersistUpdates = autoPersistUpdates;
}
/**
* Return the PersistBatch mode to use by default at the transaction level.
* <p>
@@ -1029,7 +1062,6 @@ public class DatabaseConfig {
* This is a performance optimisation to reduce the number times Ebean
* requests a sequence to be used as an Id for a bean (aka reduce network
* chatter).
*/
public void setDatabaseSequenceBatchSize(int databaseSequenceBatchSize) {
platformConfig.setDatabaseSequenceBatchSize(databaseSequenceBatchSize);
@@ -1212,20 +1244,6 @@ public class DatabaseConfig {
this.dbSchema = dbSchema;
}
/**
* Return the DB migration configuration.
*/
public DbMigrationConfig getMigrationConfig() {
return migrationConfig;
}
/**
* Set the DB migration configuration.
*/
public void setMigrationConfig(DbMigrationConfig migrationConfig) {
this.migrationConfig = migrationConfig;
}
/**
* Return the Geometry SRID.
*/
@@ -1600,6 +1618,20 @@ public class DatabaseConfig {
this.autoTuneConfig = autoTuneConfig;
}
/**
* Return true if the startup DataSource check should be skipped.
*/
public boolean skipDataSourceCheck() {
return skipDataSourceCheck;
}
/**
* Set to true to skip the startup DataSource check.
*/
public void setSkipDataSourceCheck(boolean skipDataSourceCheck) {
this.skipDataSourceCheck = skipDataSourceCheck;
}
/**
* Return the DataSource.
*/
@@ -2026,7 +2058,15 @@ public class DatabaseConfig {
* as it is often the only thing we need to configure for migrations.
*/
public void setRunMigration(boolean runMigration) {
migrationConfig.setRunMigration(runMigration);
this.runMigration = runMigration;
}
/**
* Return true if the DB migration should run on server start.
*/
public boolean isRunMigration() {
final String run = System.getProperty("ebean.migration.run");
return (run != null) ? Boolean.parseBoolean(run) : runMigration;
}
/**
@@ -2134,6 +2174,67 @@ public class DatabaseConfig {
return ddlExtra;
}
/**
* Set the header to use with DDL generation.
*/
public void setDdlHeader(String ddlHeader) {
this.ddlHeader = ddlHeader;
}
/**
* Return the header to use with DDL generation.
*/
public String getDdlHeader() {
if (ddlHeader != null && !ddlHeader.isEmpty()) {
String header = ddlHeader.replace("${version}", EbeanVersion.getVersion());
header = header.replace("${timestamp}", ZonedDateTime.now().format(DateTimeFormatter.ISO_INSTANT));
return header;
}
return ddlHeader;
}
/**
* Return true if strict mode is used which includes a check that non-null columns have a default value.
*/
public boolean isDdlStrictMode() {
return ddlStrictMode;
}
/**
* Set to false to turn off strict mode allowing non-null columns to not have a default value.
*/
public void setDdlStrictMode(boolean ddlStrictMode) {
this.ddlStrictMode = ddlStrictMode;
}
/**
* Return a comma and equals delimited placeholders that are substituted in DDL scripts.
*/
public String getDdlPlaceholders() {
return ddlPlaceholders;
}
/**
* Set a comma and equals delimited placeholders that are substituted in DDL scripts.
*/
public void setDdlPlaceholders(String ddlPlaceholders) {
this.ddlPlaceholders = ddlPlaceholders;
}
/**
* Return a map of placeholder values that are substituted in DDL scripts.
*/
public Map<String, String> getDdlPlaceholderMap() {
return ddlPlaceholderMap;
}
/**
* Set a map of placeholder values that are substituted in DDL scripts.
*/
public void setDdlPlaceholderMap(Map<String, String> ddlPlaceholderMap) {
this.ddlPlaceholderMap = ddlPlaceholderMap;
}
/**
* Return true if the class path search should be disabled.
*/
@@ -2605,24 +2706,13 @@ public class DatabaseConfig {
this.classLoadConfig = classLoadConfig;
}
/**
* Return the service loader using the classLoader defined in ClassLoadConfig.
*/
public <T> ServiceLoader<T> serviceLoad(Class<T> spiService) {
return ServiceLoader.load(spiService, classLoadConfig.getClassLoader());
}
/**
* Return the first service using the service loader (or null).
*/
public <T> T service(Class<T> spiService) {
ServiceLoader<T> load = serviceLoad(spiService);
Iterator<T> serviceInstances = load.iterator();
return serviceInstances.hasNext() ? serviceInstances.next() : null;
}
/**
* Load settings from ebean.properties.
* Load settings from application.properties, application.yaml and other sources.
* <p>
* Uses <code>avaje-config</code> to load configuration properties. Goto https://avaje.io/config
* for detail on how and where properties are loaded from.
*/
public void loadFromProperties() {
this.properties = Config.asProperties();
@@ -2655,7 +2745,7 @@ public class DatabaseConfig {
*/
private List<AutoConfigure> autoConfiguration() {
List<AutoConfigure> list = new ArrayList<>();
for (AutoConfigure autoConfigure : serviceLoad(AutoConfigure.class)) {
for (AutoConfigure autoConfigure : ServiceLoader.load(AutoConfigure.class)) {
autoConfigure.preConfigure(this);
list.add(autoConfigure);
}
@@ -2699,13 +2789,8 @@ public class DatabaseConfig {
* Load the configuration settings from the properties file.
*/
protected void loadSettings(PropertiesWrapper p) {
dbSchema = p.get("dbSchema", dbSchema);
if (dbSchema != null) {
migrationConfig.setDefaultDbSchema(dbSchema);
}
profilingConfig.loadSettings(p, name);
migrationConfig.loadSettings(p, name);
platformConfig.loadSettings(p);
if (platformConfig.isAllQuotedIdentifiers()) {
adjustNamingConventionForAllQuoted();
@@ -2729,21 +2814,27 @@ public class DatabaseConfig {
}
loadDocStoreSettings(p);
defaultServer = p.getBoolean("defaultServer", defaultServer);
autoPersistUpdates = p.getBoolean("autoPersistUpdates", autoPersistUpdates);
loadModuleInfo = p.getBoolean("loadModuleInfo", loadModuleInfo);
maxCallStack = p.getInt("maxCallStack", maxCallStack);
dumpMetricsOnShutdown = p.getBoolean("dumpMetricsOnShutdown", dumpMetricsOnShutdown);
dumpMetricsOptions = p.get("dumpMetricsOptions", dumpMetricsOptions);
queryPlanTTLSeconds = p.getInt("queryPlanTTLSeconds", queryPlanTTLSeconds);
slowQueryMillis = p.getLong("slowQueryMillis", slowQueryMillis);
collectQueryPlans = p.getBoolean("collectQueryPlans", collectQueryPlans);
collectQueryPlanThresholdMicros = p.getLong("collectQueryPlanThresholdMicros", collectQueryPlanThresholdMicros);
queryPlanEnable = p.getBoolean("queryPlan.enable", queryPlanEnable);
queryPlanThresholdMicros = p.getLong("queryPlan.thresholdMicros", queryPlanThresholdMicros);
queryPlanCapture = p.getBoolean("queryPlan.capture", queryPlanCapture);
queryPlanCapturePeriodSecs = p.getLong("queryPlan.capturePeriodSecs", queryPlanCapturePeriodSecs);
queryPlanCaptureMaxTimeMillis = p.getLong("queryPlan.captureMaxTimeMillis", queryPlanCaptureMaxTimeMillis);
queryPlanCaptureMaxCount = p.getInt("queryPlan.captureMaxCount", queryPlanCaptureMaxCount);
docStoreOnly = p.getBoolean("docStoreOnly", docStoreOnly);
disableL2Cache = p.getBoolean("disableL2Cache", disableL2Cache);
localOnlyL2Cache = p.getBoolean("localOnlyL2Cache", localOnlyL2Cache);
enabledL2Regions = p.get("enabledL2Regions", enabledL2Regions);
notifyL2CacheInForeground = p.getBoolean("notifyL2CacheInForeground", notifyL2CacheInForeground);
useJtaTransactionManager = p.getBoolean("useJtaTransactionManager", useJtaTransactionManager);
useJavaxValidationNotNull = p.getBoolean("useJavaxValidationNotNull", useJavaxValidationNotNull);
useValidationNotNull = p.getBoolean("useValidationNotNull", useValidationNotNull);
autoReadOnlyDataSource = p.getBoolean("autoReadOnlyDataSource", autoReadOnlyDataSource);
idGeneratorAutomatic = p.getBoolean("idGeneratorAutomatic", idGeneratorAutomatic);
@@ -2806,13 +2897,19 @@ public class DatabaseConfig {
jsonInclude = p.getEnum(JsonConfig.Include.class, "jsonInclude", jsonInclude);
jsonDateTime = p.getEnum(JsonConfig.DateTime.class, "jsonDateTime", jsonDateTime);
jsonDate = p.getEnum(JsonConfig.Date.class, "jsonDate", jsonDate);
jsonMutationDetection = p.getEnum(MutationDetection.class, "jsonMutationDetection", jsonMutationDetection);
skipDataSourceCheck = p.getBoolean("skipDataSourceCheck", skipDataSourceCheck);
runMigration = p.getBoolean("migration.run", runMigration);
ddlGenerate = p.getBoolean("ddl.generate", ddlGenerate);
ddlRun = p.getBoolean("ddl.run", ddlRun);
ddlExtra = p.getBoolean("ddl.extra", ddlExtra);
ddlCreateOnly = p.getBoolean("ddl.createOnly", ddlCreateOnly);
ddlInitSql = p.get("ddl.initSql", ddlInitSql);
ddlSeedSql = p.get("ddl.seedSql", ddlSeedSql);
ddlStrictMode = p.getBoolean("ddl.strictMode", ddlStrictMode);
ddlPlaceholders = p.get("ddl.placeholders", ddlPlaceholders);
ddlHeader = p.get("ddl.header", ddlHeader);
// read tenant-configuration from config:
// tenant.mode = NONE | DB | SCHEMA | CATALOG | PARTITION
@@ -2986,20 +3083,21 @@ public class DatabaseConfig {
/**
* Returns if we use javax.validation.constraints.NotNull
*/
public boolean isUseJavaxValidationNotNull() {
return useJavaxValidationNotNull;
public boolean isUseValidationNotNull() {
return useValidationNotNull;
}
/**
* Controls if Ebean should ignore <code>&x64;javax.validation.contstraints.NotNull</code>
* Controls if Ebean should ignore <code>&x64;javax.validation.contstraints.NotNull</code> or
* <code>&x64;jakarta.validation.contstraints.NotNull</code>
* with respect to generating a <code>NOT NULL</code> column.
* <p>
* Normally when Ebean sees javax NotNull annotation it means that column is defined as NOT NULL.
* Set this to <code>false</code> and the javax NotNull annotation is effectively ignored (and
* we instead use Ebean's own NotNull annotation or JPA Column(nullable=false) annotation.
*/
public void setUseJavaxValidationNotNull(boolean useJavaxValidationNotNull) {
this.useJavaxValidationNotNull = useJavaxValidationNotNull;
public void setUseValidationNotNull(boolean useValidationNotNull) {
this.useValidationNotNull = useValidationNotNull;
}
/**
@@ -3021,30 +3119,22 @@ public class DatabaseConfig {
}
/**
* Return the query plan time to live.
* Return the time to live for ebean's internal query plan.
*/
public int getQueryPlanTTLSeconds() {
return queryPlanTTLSeconds;
}
/**
* Set the query plan time to live.
* Set the time to live for ebean's internal query plan.
* <p>
* This is the plan that knows how to execute the query, read the result
* and collects execution metrics. By default this is set to 5 mins.
*/
public void setQueryPlanTTLSeconds(int queryPlanTTLSeconds) {
this.queryPlanTTLSeconds = queryPlanTTLSeconds;
}
/**
* Run the DB migration against the DataSource.
*/
public DataSource runDbMigration(DataSource dataSource) {
if (migrationConfig.isRunMigration()) {
MigrationRunner runner = migrationConfig.createRunner(getClassLoadConfig().getClassLoader(), properties);
runner.run(dataSource);
}
return dataSource;
}
/**
* Create a new PlatformConfig based of the one held but with overridden properties by reading
* properties with the given path and prefix.
@@ -3112,29 +3202,110 @@ public class DatabaseConfig {
/**
* Return true if query plan capture is enabled.
*/
public boolean isCollectQueryPlans() {
return collectQueryPlans;
public boolean isQueryPlanEnable() {
return queryPlanEnable;
}
/**
* Set to true to enable query plan capture.
*/
public void setCollectQueryPlans(boolean collectQueryPlans) {
this.collectQueryPlans = collectQueryPlans;
public void setQueryPlanEnable(boolean queryPlanEnable) {
this.queryPlanEnable = queryPlanEnable;
}
/**
* Return the query plan collection threshold in microseconds.
*/
public long getCollectQueryPlanThresholdMicros() {
return collectQueryPlanThresholdMicros;
public long getQueryPlanThresholdMicros() {
return queryPlanThresholdMicros;
}
/**
* Set the query plan collection threshold in microseconds.
* <p>
* Queries executing slower than this will have bind values captured such that later
* the query plan can be captured and reported.
*/
public void setCollectQueryPlanThresholdMicros(long collectQueryPlanThresholdMicros) {
this.collectQueryPlanThresholdMicros = collectQueryPlanThresholdMicros;
public void setQueryPlanThresholdMicros(long queryPlanThresholdMicros) {
this.queryPlanThresholdMicros = queryPlanThresholdMicros;
}
/**
* Return true if periodic capture of query plans is enabled.
*/
public boolean isQueryPlanCapture() {
return queryPlanCapture;
}
/**
* Set to true to turn on periodic capture of query plans.
*/
public void setQueryPlanCapture(boolean queryPlanCapture) {
this.queryPlanCapture = queryPlanCapture;
}
/**
* Return the frequency to capture query plans.
*/
public long getQueryPlanCapturePeriodSecs() {
return queryPlanCapturePeriodSecs;
}
/**
* Set the frequency in seconds to capture query plans.
*/
public void setQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs) {
this.queryPlanCapturePeriodSecs = queryPlanCapturePeriodSecs;
}
/**
* Return the time after which a capture query plans request will
* stop capturing more query plans.
* <p>
* Effectively this controls the amount of load/time we want to
* allow for query plan capture.
*/
public long getQueryPlanCaptureMaxTimeMillis() {
return queryPlanCaptureMaxTimeMillis;
}
/**
* Set the time after which a capture query plans request will
* stop capturing more query plans.
* <p>
* Effectively this controls the amount of load/time we want to
* allow for query plan capture.
*/
public void setQueryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis) {
this.queryPlanCaptureMaxTimeMillis = queryPlanCaptureMaxTimeMillis;
}
/**
* Return the max number of query plans captured per request.
*/
public int getQueryPlanCaptureMaxCount() {
return queryPlanCaptureMaxCount;
}
/**
* Set the max number of query plans captured per request.
*/
public void setQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount) {
this.queryPlanCaptureMaxCount = queryPlanCaptureMaxCount;
}
/**
* Return the listener used to process captured query plans.
*/
public QueryPlanListener getQueryPlanListener() {
return queryPlanListener;
}
/**
* Set the listener used to process captured query plans.
*/
public void setQueryPlanListener(QueryPlanListener queryPlanListener) {
this.queryPlanListener = queryPlanListener;
}
/**
@@ -15,7 +15,7 @@ package io.ebean.config;
*
* public class EbeanConfigProvider implements DatabaseConfigProvider {
*
* Override
* @Override
* public void apply(DatabaseConfig config) {
*
* // register the entity bean classes explicitly
@@ -1,509 +0,0 @@
package io.ebean.config;
import io.ebean.EbeanVersion;
import io.ebean.annotation.Platform;
import io.ebean.migration.MigrationConfig;
import io.ebean.migration.MigrationRunner;
import io.ebean.util.StringHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
import java.util.Properties;
import static io.ebean.util.StringHelper.replace;
/**
* Configuration for the DB migration processing.
*/
public class DbMigrationConfig {
protected static final Logger logger = LoggerFactory.getLogger(DbMigrationConfig.class);
protected MigrationConfig runnerConfig = new MigrationConfig();
/**
* The database platform to generate migration DDL for.
*/
protected Platform platform;
/**
* Resource path for the migration xml and sql.
*/
protected String migrationPath = "dbmigration";
protected String migrationInitPath = "dbinit";
/**
* Subdirectory the model xml files go into.
*/
protected String modelPath = "model";
protected String applySuffix = ".sql";
/**
* Set this to "V" to be compatible with FlywayDB.
*/
protected String applyPrefix = "";
protected String modelSuffix = ".model.xml";
/**
* For running migration the DB table that holds migration execution status.
*/
protected String metaTable = "db_migration";
/**
* Flag set to true means to run any outstanding migrations on startup.
*/
protected boolean runMigration;
/**
* Comma and equals delimited key/value placeholders to replace in DDL scripts.
*/
protected String runPlaceholders;
/**
* Map of key/value placeholders to replace in DDL scripts.
*/
protected Map<String, String> runPlaceholderMap;
/**
* DB schema used for the migration (and testing).
*/
protected String dbSchema;
/**
* Set to true if we consider this the 'default schema' (Postgres schema that matches DB username)
*/
protected boolean defaultDbSchema;
/**
* DB user used to run the DB migration.
*/
protected String dbUsername;
/**
* DB password used to run the DB migration.
*/
protected String dbPassword;
protected String patchInsertOn;
protected String patchResetChecksumOn;
/**
* Mode used to check non-null columns added via migration have a default value specified etc.
*/
protected boolean strictMode = true;
/**
* Contains the DDL-header information.
*/
protected String ddlHeader;
/**
* Return the DB platform to generate migration DDL for.
* <p>
* We typically need to explicitly specify this as migration can often be generated
* when running against H2.
*/
public Platform getPlatform() {
return platform;
}
/**
* Set the DB platform to generate migration DDL for.
*/
public void setPlatform(Platform platform) {
this.platform = platform;
}
/**
* Return the path for normal migrations or dbinit migrations.
*
* @param dbinitMigration When true return the path for dbinit migrations.
*/
public String getMigrationPath(boolean dbinitMigration) {
return dbinitMigration ? migrationInitPath : migrationPath;
}
/**
* Return the resource path for db migrations.
*/
public String getMigrationPath() {
return migrationPath;
}
/**
* Set the resource path for db migrations.
* <p>
* The default of "dbmigration" is reasonable in most cases. You may look to set this
* to be something like "dbmigration/myapp" where myapp gives it a unique resource path
* in the case there are multiple Database applications in the single classpath.
* </p>
*/
public void setMigrationPath(String migrationPath) {
this.migrationPath = migrationPath;
}
/**
* Return the relative path for the model files (defaults to model).
*/
public String getModelPath() {
return modelPath;
}
/**
* Set the relative path for the model files.
*/
public void setModelPath(String modelPath) {
this.modelPath = modelPath;
}
/**
* Return the model suffix (defaults to model.xml)
*/
public String getModelSuffix() {
return modelSuffix;
}
/**
* Set the model suffix.
*/
public void setModelSuffix(String modelSuffix) {
this.modelSuffix = modelSuffix;
}
/**
* Return the apply script suffix (defaults to sql).
*/
public String getApplySuffix() {
return applySuffix;
}
/**
* Set the apply script suffix (defaults to sql).
*/
public void setApplySuffix(String applySuffix) {
this.applySuffix = applySuffix;
}
/**
* Return the apply prefix.
*/
public String getApplyPrefix() {
return applyPrefix;
}
/**
* Set the apply prefix. This might be set to "V" for use with FlywayDB.
*/
public void setApplyPrefix(String applyPrefix) {
this.applyPrefix = applyPrefix;
}
/**
* Return the table name that holds the migration run details
* (used by DB Migration runner only).
*/
public String getMetaTable() {
return metaTable;
}
/**
* Set the table name that holds the migration run details
* (used by DB Migration runner only).
*/
public void setMetaTable(String metaTable) {
this.metaTable = metaTable;
}
/**
* Return a comma and equals delimited placeholders that are substituted in SQL scripts when running migration
* (used by DB Migration runner only).
*/
public String getRunPlaceholders() {
// environment properties take precedence
String placeholders = readEnvironment("ddl.migration.placeholders");
if (placeholders != null) {
return placeholders;
}
return runPlaceholders;
}
/**
* Set a comma and equals delimited placeholders that are substituted in SQL scripts when running migration
* (used by DB Migration runner only).
*/
public void setRunPlaceholders(String runPlaceholders) {
this.runPlaceholders = runPlaceholders;
}
/**
* Return a map of placeholder values that are substituted in SQL scripts when running migration
* (used by DB Migration runner only).
*/
public Map<String, String> getRunPlaceholderMap() {
return runPlaceholderMap;
}
/**
* Set a map of placeholder values that are substituted when running migration
* (used by DB Migration runner only).
*/
public void setRunPlaceholderMap(Map<String, String> runPlaceholderMap) {
this.runPlaceholderMap = runPlaceholderMap;
}
/**
* Return true if the DB migration should be run on startup.
*/
public boolean isRunMigration() {
// environment properties take precedence
String run = readEnvironment("ddl.migration.run");
if (run != null) {
return "true".equalsIgnoreCase(run.trim());
}
return runMigration;
}
/**
* Set to true to run the DB migration on startup.
*/
public void setRunMigration(boolean runMigration) {
this.runMigration = runMigration;
}
/**
* Return the DB username to use for running DB migrations.
*/
public String getDbUsername() {
// environment properties take precedence
String user = readEnvironment("ddl.migration.user");
if (user != null) {
return user;
}
return dbUsername;
}
/**
* Set the DB username to use for running DB migrations.
*/
public void setDbUsername(String dbUsername) {
this.dbUsername = dbUsername;
}
/**
* Return the DB password to use for running DB migrations.
*/
public String getDbPassword() {
String user = readEnvironment("ddl.migration.password");
if (user != null) {
return user;
}
return dbPassword;
}
/**
* Set the DB password to use for running DB migrations.
*/
public void setDbPassword(String dbPassword) {
this.dbPassword = dbPassword;
}
/**
* Return the DB schema to use (for migration, testing etc).
*/
public String getDbSchema() {
String schema = readEnvironment("ddl.migration.schema");
if (schema != null) {
return schema;
}
return dbSchema;
}
/**
* Set the Db schema to use.
*/
public void setDbSchema(String dbSchema) {
this.dbSchema = dbSchema;
}
/**
* Set the Db schema if it hasn't already been defined.
*/
public void setDefaultDbSchema(String dbSchema) {
this.defaultDbSchema = true;
this.dbSchema = dbSchema;
}
/**
* Return true if this is considered the default DB schema (Postgres schema matching DB username).
*/
public boolean isDefaultDbSchema() {
return defaultDbSchema;
}
/**
* Return migration versions that should be added to history without running.
*/
public String getPatchInsertOn() {
return patchInsertOn;
}
/**
* Set migration versions that should be added to history without running.
* <p>
* Value can be a string containing comma delimited list of version numbers.
* </p>
*/
public void setPatchInsertOn(String patchInsertOn) {
this.patchInsertOn = patchInsertOn;
}
/**
* Return migration versions that should have their checksum reset and not run.
*/
public String getPatchResetChecksumOn() {
return patchResetChecksumOn;
}
/**
* Returns a DDL header prepend for each DDL. E.g. for copyright headers
* You can use placeholders like ${version} or ${timestamp} in properties file.
*/
public String getDdlHeader() {
if (ddlHeader != null && !ddlHeader.isEmpty()) {
ddlHeader = replace(ddlHeader, "${version}", EbeanVersion.getVersion());
ddlHeader = replace(ddlHeader, "${timestamp}", ZonedDateTime.now().format( DateTimeFormatter.ISO_INSTANT ));
}
return ddlHeader;
}
/**
* Set the header prepended to the DDL.
*/
public void setDdlHeader(String ddlHeader) {
this.ddlHeader = ddlHeader;
}
/**
* Set migration versions that should have their checksum reset and not run.
* <p>
* Value can be a string containing comma delimited list of version numbers.
* </p>
*/
public void setPatchResetChecksumOn(String patchResetChecksumOn) {
this.patchResetChecksumOn = patchResetChecksumOn;
}
/**
* Return true if strict mode is used which includes a check that non-null columns have a default value.
*/
public boolean isStrictMode() {
String envValue = readEnvironment("ddl.migration.strictMode");
if (!isEmpty(envValue)) {
return Boolean.parseBoolean(envValue.trim());
}
return strictMode;
}
/**
* Set to false to turn off strict mode allowing non-null columns to not have a default value.
*/
public void setStrictMode(boolean strictMode) {
this.strictMode = strictMode;
}
/**
* Return the underlying migration runner configuration allowing for more advanced settings.
*/
public MigrationConfig getRunnerConfig() {
return runnerConfig;
}
/**
* Load the settings from the PropertiesWrapper.
*/
public void loadSettings(PropertiesWrapper properties, String serverName) {
migrationPath = properties.get("migration.migrationPath", migrationPath);
migrationInitPath = properties.get("migration.migrationInitPath", migrationInitPath);
modelPath = properties.get("migration.modelPath", modelPath);
applyPrefix = properties.get("migration.applyPrefix", applyPrefix);
applySuffix = properties.get("migration.applySuffix", applySuffix);
modelSuffix = properties.get("migration.modelSuffix", modelSuffix);
platform = properties.getEnum(Platform.class, "migration.platform", platform);
patchInsertOn = properties.get("migration.patchInsertOn", patchInsertOn);
patchResetChecksumOn = properties.get("migration.patchResetChecksumOn", patchResetChecksumOn);
runMigration = properties.getBoolean("migration.run", runMigration);
metaTable = properties.get("migration.metaTable", metaTable);
runPlaceholders = properties.get("migration.placeholders", runPlaceholders);
dbSchema = properties.get("migration.dbSchema", dbSchema);
//Do not set user and pass from "datasource.db.username"
//There is a null test in MigrationRunner::getConnection to handle this
//String adminUser = properties.get("datasource." + serverName + ".username", dbUsername);
String adminUser = properties.get("datasource." + serverName + ".adminusername", dbUsername);
dbUsername = properties.get("migration.dbusername", adminUser);
//String adminPwd = properties.get("datasource." + serverName + ".password", dbPassword);
String adminPwd = properties.get("datasource." + serverName + ".adminpassword", dbPassword);
dbPassword = properties.get("migration.dbpassword", adminPwd);
ddlHeader = properties.get("ddl.header", ddlHeader);
}
/**
* Return the system or environment property.
*/
protected String readEnvironment(String key) {
String val = System.getProperty(key);
if (val == null) {
val = System.getenv(key);
}
return val;
}
/**
* Return true if the string is null or empty.
*/
protected boolean isEmpty(String val) {
return val == null || val.trim().isEmpty();
}
/**
* Create the MigrationRunner to run migrations if necessary.
*/
public MigrationRunner createRunner(ClassLoader classLoader, Properties properties) {
runnerConfig.setMetaTable(metaTable);
runnerConfig.setApplySuffix(applySuffix);
runnerConfig.setMigrationPath(migrationPath);
runnerConfig.setMigrationInitPath(migrationInitPath);
runnerConfig.setRunPlaceholderMap(runPlaceholderMap);
runnerConfig.setRunPlaceholders(runPlaceholders);
runnerConfig.setDbUsername(getDbUsername());
runnerConfig.setDbPassword(getDbPassword());
runnerConfig.setDbSchema(getDbSchema());
if (defaultDbSchema) {
runnerConfig.setSetCurrentSchema(false);
}
runnerConfig.setClassLoader(classLoader);
if (patchInsertOn != null) {
runnerConfig.setPatchInsertOn(patchInsertOn);
}
if (patchResetChecksumOn != null) {
runnerConfig.setPatchResetChecksumOn(patchResetChecksumOn);
}
if (properties != null) {
runnerConfig.load(properties);
}
return new MigrationRunner(runnerConfig);
}
}
@@ -39,11 +39,6 @@ public class MatchingNamingConvention extends AbstractNamingConvention {
return new TableName(quoteIdentifiers(getCatalog()), quoteIdentifiers(getSchema()), quoteIdentifiers(beanClass.getSimpleName()));
}
@Override
public String getPropertyFromColumn(Class<?> beanClass, String dbColumnName) {
return dbColumnName;
}
@Override
public String getForeignKey(String prefix, String fkProperty) {
prefix = databasePlatform.unQuote(prefix);
@@ -7,13 +7,8 @@ import java.util.List;
*/
public interface ModuleInfoLoader {
/**
* Return the entity classes to register with the default DB.
*/
List<Class<?>> entityClasses();
/**
* Return entity classes to register for a named DB (not default DB).
*/
List<Class<?>> entityClassesFor(String dbName);
List<Class<?>> classesFor(String dbName, boolean defaultServer);
}
@@ -53,6 +53,16 @@ public interface NamingConvention {
*/
TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable);
/**
* Derive a DB Column from a FK table and column.
*/
String deriveM2MColumn(String tableName, String dbColumn);
/**
* Return the full table name taking into account quoted identifiers.
*/
String getTableName(String catalog, String schema, String name);
/**
* Return the column name given the property name.
*
@@ -60,18 +70,6 @@ public interface NamingConvention {
*/
String getColumnFromProperty(Class<?> beanClass, String propertyName);
/**
* Return the property name from the column name.
* <p>
* This is used to help mapping of raw SQL queries onto bean properties.
* </p>
*
* @param beanClass the bean class
* @param dbColumnName the db column name
* @return the property name from the column name
*/
String getPropertyFromColumn(Class<?> beanClass, String dbColumnName);
/**
* Return the sequence name given the table name (for DB's that use sequences).
* <p>
@@ -17,6 +17,11 @@ public class PlatformConfig {
private boolean allQuotedIdentifiers;
/**
* Set this to true for Postgres FOR UPDATE to use NO KEY option.
*/
private boolean forUpdateNoKey;
private DbConstraintNaming constraintNaming;
/**
@@ -77,6 +82,7 @@ public class PlatformConfig {
* Construct based on given config - typically for DbMigration generation with many platforms.
*/
public PlatformConfig(PlatformConfig platformConfig) {
this.forUpdateNoKey = platformConfig.forUpdateNoKey;
this.databaseBooleanFalse = platformConfig.databaseBooleanFalse;
this.databaseBooleanTrue = platformConfig.databaseBooleanTrue;
this.databaseSequenceBatchSize = platformConfig.databaseSequenceBatchSize;
@@ -133,14 +139,26 @@ public class PlatformConfig {
this.caseSensitiveCollation = caseSensitiveCollation;
}
/**
* Return true if Postgres FOR UPDATE should use the NO KEY option.
*/
public boolean isForUpdateNoKey() {
return forUpdateNoKey;
}
/**
* Set to true such that Postgres FOR UPDATE should use the NO KEY option.
*/
public void setForUpdateNoKey(boolean forUpdateNoKey) {
this.forUpdateNoKey = forUpdateNoKey;
}
/**
* Return a value used to represent TRUE in the database.
* <p>
* This is used for databases that do not support boolean natively.
* </p>
* <p>
* The value returned is either a Integer or a String (e.g. "1", or "T").
* </p>
*/
public String getDatabaseBooleanTrue() {
return databaseBooleanTrue;
@@ -150,10 +168,8 @@ public class PlatformConfig {
* Set the value to represent TRUE in the database.
* <p>
* This is used for databases that do not support boolean natively.
* </p>
* <p>
* The value set is either a Integer or a String (e.g. "1", or "T").
* </p>
*/
public void setDatabaseBooleanTrue(String databaseBooleanTrue) {
this.databaseBooleanTrue = databaseBooleanTrue;
@@ -245,7 +261,6 @@ public class PlatformConfig {
/**
* Add a custom type mapping.
* <p>
* <pre>{@code
*
* // set the default mapping for BigDecimal.class/decimal
@@ -266,7 +281,6 @@ public class PlatformConfig {
/**
* Add a custom type mapping that applies to all platforms.
* <p>
* <pre>{@code
*
* // set the default mapping for BigDecimal/decimal
@@ -294,6 +308,7 @@ public class PlatformConfig {
public void loadSettings(PropertiesWrapper p) {
idType = p.getEnum(IdType.class, "idType", idType);
forUpdateNoKey = p.getBoolean("forUpdateNoKey", forUpdateNoKey);
databaseSequenceBatchSize = p.getInt("databaseSequenceBatchSize", databaseSequenceBatchSize);
databaseBooleanTrue = p.get("databaseBooleanTrue", databaseBooleanTrue);
databaseBooleanFalse = p.get("databaseBooleanFalse", databaseBooleanFalse);
@@ -334,7 +349,6 @@ public class PlatformConfig {
*/
public enum DbUuid {
/**
* Store using native UUID in H2 and Postgres and otherwise fallback to VARCHAR(40).
*/
@@ -0,0 +1,50 @@
package io.ebean.config;
import io.ebean.Database;
import io.ebean.meta.MetaQueryPlan;
import java.util.List;
/**
* The captured query plans.
*/
public class QueryPlanCapture {
private final Database database;
private final List<MetaQueryPlan> plans;
public QueryPlanCapture(Database database, List<MetaQueryPlan> plans) {
this.database = database;
this.plans = plans;
}
/**
* Return the database the plans were captured for.
*/
public Database database() {
return database;
}
/**
* Deprecated migrate to database().
*/
@Deprecated
public Database getDatabase() {
return database;
}
/**
* Return the captured query plans.
*/
public List<MetaQueryPlan> plans() {
return plans;
}
/**
* Deprecated migrate to plans().
*/
@Deprecated
public List<MetaQueryPlan> getPlans() {
return plans;
}
}
@@ -0,0 +1,13 @@
package io.ebean.config;
/**
* EXPERIMENTAL: Listener for captured query plans.
*/
@FunctionalInterface
public interface QueryPlanListener {
/**
* Process the captured query plans.
*/
void process(QueryPlanCapture capture);
}
@@ -1,47 +1,6 @@
package io.ebean.config;
import com.fasterxml.jackson.core.JsonFactory;
import io.avaje.config.Config;
import io.ebean.DatabaseFactory;
import io.ebean.PersistenceContextScope;
import io.ebean.Query;
import io.ebean.Transaction;
import io.ebean.annotation.Encrypted;
import io.ebean.annotation.PersistBatch;
import io.ebean.annotation.Platform;
import io.ebean.cache.ServerCachePlugin;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.config.dbplatform.DbEncrypt;
import io.ebean.config.dbplatform.DbType;
import io.ebean.config.dbplatform.IdType;
import io.ebean.datasource.DataSourceConfig;
import io.ebean.event.BeanFindController;
import io.ebean.event.BeanPersistController;
import io.ebean.event.BeanPersistListener;
import io.ebean.event.BeanPostConstructListener;
import io.ebean.event.BeanPostLoad;
import io.ebean.event.BeanQueryAdapter;
import io.ebean.event.BulkTableEventListener;
import io.ebean.event.ServerConfigStartup;
import io.ebean.event.changelog.ChangeLogListener;
import io.ebean.event.changelog.ChangeLogPrepare;
import io.ebean.event.changelog.ChangeLogRegister;
import io.ebean.event.readaudit.ReadAuditLogger;
import io.ebean.event.readaudit.ReadAuditPrepare;
import io.ebean.migration.MigrationRunner;
import io.ebean.util.StringHelper;
import javax.persistence.EnumType;
import javax.sql.DataSource;
import java.time.Clock;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.ServiceLoader;
/**
* Deprecated - please migrate to <code>io.ebean.DatabaseConfig</code>.
@@ -16,7 +16,7 @@ package io.ebean.config;
*
* public class EbeanConfigProvider implements ServerConfigProvider {
*
* Override
* @Override
* public void apply(ServerConfig config) {
*
* // register the entity bean classes explicitly
@@ -20,7 +20,7 @@ public final class TableName {
/**
* The name.
*/
private String name;
private final String name;
/**
* Construct with the given catalog schema and table name.
@@ -29,7 +29,6 @@ public final class TableName {
* </p>
*/
public TableName(String catalog, String schema, String name) {
super();
this.catalog = catalog != null ? catalog.trim() : null;
this.schema = schema != null ? schema.trim() : null;
this.name = name != null ? name.trim() : null;
@@ -110,14 +109,11 @@ public final class TableName {
* @return the qualified name
*/
public String getQualifiedName() {
StringBuilder buffer = new StringBuilder();
// Add catalog
if (catalog != null) {
buffer.append(catalog);
}
// Add schema
if (schema != null) {
if (buffer.length() > 0) {
@@ -125,31 +121,27 @@ public final class TableName {
}
buffer.append(schema);
}
if (buffer.length() > 0) {
buffer.append(".");
}
buffer.append(name);
return buffer.toString();
return buffer.append(name).toString();
}
/**
* Append a catalog and schema prefix if they exist to the string builder.
*/
public void appendCatalogAndSchema(StringBuilder buffer) {
if (catalog != null) {
buffer.append(catalog).append(".");
}
public String withCatalogAndSchema(String name) {
if (schema != null) {
buffer.append(schema).append(".");
name = schema + "." + name;
}
if (catalog != null) {
name = catalog + "." + name;
}
return name;
}
/**
* Checks if is table name is valid i.e. it has at least a name.
*
* @return true, if is valid
*/
public boolean isValid() {
return name != null && !name.isEmpty();
@@ -60,18 +60,6 @@ public class UnderscoreNamingConvention extends AbstractNamingConvention {
return toUnderscoreFromCamel(propertyName);
}
/**
* Converts underscore based column name to Camel case property name.
*
* @param beanClass the bean class
* @param dbColumnName the db column name
* @return the property from column
*/
@Override
public String getPropertyFromColumn(Class<?> beanClass, String dbColumnName) {
return toCamelFromUnderscore(dbColumnName);
}
/**
* Return true if the result will be upper case.
* <p>
@@ -9,9 +9,6 @@ import java.sql.Types;
* functions for varchar, date and timestamp. If they are left null then that is
* treated as though that data type can not be encrypted in the DB and will
* instead use java client encryption.
* </p>
*
* @author rbygrave
*/
public abstract class AbstractDbEncrypt implements DbEncrypt {
@@ -47,13 +44,10 @@ public abstract class AbstractDbEncrypt implements DbEncrypt {
case Types.CHAR:
case Types.LONGVARCHAR:
return varcharEncryptFunction;
case Types.DATE:
return dateEncryptFunction;
case Types.TIMESTAMP:
return timestampEncryptFunction;
default:
return null;
}
@@ -25,7 +25,7 @@ import java.sql.Types;
*/
public class DatabasePlatform {
private static final Logger logger = LoggerFactory.getLogger(DatabasePlatform.class);
private static final Logger log = LoggerFactory.getLogger("io.ebean");
/**
* Behavior used when ending a query only transaction (at read committed isolation level).
@@ -640,7 +640,7 @@ public class DatabasePlatform {
if (dbName.charAt(dbName.length() - 1) == BACK_TICK) {
return openQuote + dbName.substring(1, dbName.length() - 1) + closeQuote;
} else {
logger.error("Missing backquote on [" + dbName + "]");
log.error("Missing backquote on [" + dbName + "]");
}
} else if (allQuotedIdentifiers) {
return openQuote + dbName + closeQuote;
@@ -679,23 +679,22 @@ public class DatabasePlatform {
public String completeSql(String sql, Query<?> query) {
if (query.isForUpdate()) {
sql = withForUpdate(sql, query.getForUpdateMode());
sql = withForUpdate(sql, query.getForUpdateLockWait(), query.getForUpdateLockType());
}
return sql;
}
/**
* For update hint on the FROM clause (SQL server only).
*/
public String fromForUpdate(Query.ForUpdate forUpdateMode) {
public String fromForUpdate(Query.LockWait lockWait) {
// return null except for sql server
return null;
}
protected String withForUpdate(String sql, Query.ForUpdate forUpdateMode) {
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
// silently assume the database does not support the "for update" clause.
logger.info("it seems your database does not support the 'for update' clause");
log.info("it seems your database does not support the 'for update' clause");
return sql;
}
@@ -729,7 +728,7 @@ public class DatabasePlatform {
if (!schemaExists(dbSchema, connection)) {
Statement query = connection.createStatement();
try {
logger.info("create schema:{}", dbSchema);
log.debug("create schema:{}", dbSchema);
query.executeUpdate("create schema " + dbSchema);
} finally {
JdbcClose.close(query);
@@ -759,7 +758,6 @@ public class DatabasePlatform {
* Return true if the table exists.
*/
public boolean tableExists(Connection connection, String catalog, String schema, String table) throws SQLException {
DatabaseMetaData metaData = connection.getMetaData();
ResultSet tables = metaData.getTables(catalog, schema, table, null);
try {
@@ -79,7 +79,7 @@ public class DbDefaultValue {
}
/**
* This method checks & convert the {@link DbDefault#value()} to a valid SQL literal.
* This method checks and converts the {@link DbDefault#value()} to a valid SQL literal.
*
* This is mainly to quote string literals and verify integer/dates for correctness.
* <p>
@@ -70,7 +70,6 @@ public class DbPlatformTypeMapping {
* Load the standard types. These can be overridden by DB specific platform.
*/
private void loadDefaults(boolean logicalTypes) {
put(DbType.BOOLEAN, BOOLEAN_LOGICAL);
put(DbType.BIT);
put(DbType.INTEGER);
@@ -88,7 +87,6 @@ public class DbPlatformTypeMapping {
put(DbType.LONGVARCHAR);
// most commonly real maps to db float
put(DbType.REAL, new DbPlatformType("float"));
put(DbType.POINT, POINT);
put(DbType.POLYGON, POLYGON);
put(DbType.LINESTRING, LINESTRING);
@@ -103,7 +101,7 @@ public class DbPlatformTypeMapping {
put(DbType.VARBINARY, new DbPlatformType("varbinary"));
put(DbType.BINARY, new DbPlatformType("binary"));
put(DbType.CHAR, new DbPlatformType("char"));
put(DbType.LOCALDATETIME, new DbPlatformType("localdatetime", false));
put(DbType.HSTORE, new DbPlatformType("hstore", false));
put(DbType.JSON, new DbPlatformType("json", false));
put(DbType.JSONB, new DbPlatformType("jsonb", false));
@@ -120,7 +118,7 @@ public class DbPlatformTypeMapping {
put(DbType.VARBINARY, new DbPlatformType("varbinary", 255));
put(DbType.BINARY, new DbPlatformType("binary", 255));
put(DbType.CHAR, new DbPlatformType("char", 1));
put(DbType.LOCALDATETIME, DbType.TIMESTAMP.createPlatformType());
put(DbType.JSON, JSON_CLOB_PLACEHOLDER); // Postgres maps this to JSON
put(DbType.JSONB, JSON_CLOB_PLACEHOLDER); // Postgres maps this to JSONB
put(DbType.JSONCLOB, JSON_CLOB_PLACEHOLDER);
@@ -137,7 +135,6 @@ public class DbPlatformTypeMapping {
* Lookup the platform specific DbType given the standard sql type name.
*/
public DbPlatformType lookup(String name, boolean withScale) {
DbType type = lookup.byName(name);
if (type == null) {
throw new IllegalArgumentException("Unknown type [" + name + "] - not standard sql type");
@@ -160,7 +157,6 @@ public class DbPlatformTypeMapping {
}
private DbPlatformType getJsonType(DbType type, boolean withScale) {
DbPlatformType dbType = get(type);
if (dbType == JSON_CLOB_PLACEHOLDER) {
// if we have scale that implies this maps to varchar
@@ -34,6 +34,7 @@ public enum DbType {
ARRAY(Types.ARRAY),
LOCALDATETIME(ExtraDbTypes.LOCALDATETIME),
UUID(ExtraDbTypes.UUID),
INET(ExtraDbTypes.INET),
CIDR(ExtraDbTypes.CIDR),
@@ -5,11 +5,6 @@ package io.ebean.config.dbplatform;
*/
public interface ExtraDbTypes {
/**
* DB native UUID type (H2 and Postgres).
*/
int UUID = 5010;
/**
* Type to map Map content to Postgres HSTORE.
*/
@@ -40,6 +35,12 @@ public interface ExtraDbTypes {
*/
int JSONBlob = 5005;
int LOCALDATETIME = 5009;
/**
* DB native UUID type (H2 and Postgres).
*/
int UUID = 5010;
int INET = 5020;
int CIDR = 5021;
@@ -16,6 +16,7 @@ import java.util.Collections;
import java.util.List;
import java.util.NavigableSet;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantLock;
/**
@@ -23,26 +24,15 @@ import java.util.concurrent.locks.ReentrantLock;
*/
public abstract class SequenceIdGenerator implements PlatformIdGenerator {
protected static final Logger logger = LoggerFactory.getLogger("io.ebean.SEQ");
protected static final Logger log = LoggerFactory.getLogger("io.ebean.SEQ");
private final ReentrantLock lock = new ReentrantLock(false);
private final ReentrantLock loadLock = new ReentrantLock(false);
/**
* The actual sequence name.
*/
private final ReentrantLock lock = new ReentrantLock();
protected final String seqName;
protected final DataSource dataSource;
protected final BackgroundExecutor backgroundExecutor;
protected final NavigableSet<Long> idList = new TreeSet<>();
protected final int allocationSize;
protected boolean currentlyBackgroundLoading;
protected AtomicBoolean currentlyBackgroundLoading = new AtomicBoolean(false);
/**
* Construct given a dataSource and sql to return the next sequence value.
@@ -128,27 +118,16 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
* Load another batch of Id's using a background thread.
*/
protected void loadInBackground(final int requestSize) {
// single threaded processing...
loadLock.lock();
try {
if (currentlyBackgroundLoading) {
// skip as already background loading
logger.debug("... skip background sequence load (another load in progress)");
return;
}
currentlyBackgroundLoading = true;
backgroundExecutor.execute(() -> {
loadMore(requestSize);
loadLock.lock();
try {
currentlyBackgroundLoading = false;
} finally {
loadLock.unlock();
}
});
} finally {
loadLock.lock();
if (currentlyBackgroundLoading.get()) {
// skip as already background loading
log.debug("... skip background sequence load (another load in progress)");
return;
}
currentlyBackgroundLoading.set(true);
backgroundExecutor.execute(() -> {
loadMore(requestSize);
currentlyBackgroundLoading.set(false);
});
}
/**
@@ -173,8 +152,8 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
resultSet = statement.executeQuery();
List<Long> newIds = readIds(resultSet, requestSize);
if (logger.isTraceEnabled()) {
logger.trace("seq:{} loaded:{} sql:{}", seqName, newIds.size(), sql);
if (log.isTraceEnabled()) {
log.trace("seq:{} loaded:{} sql:{}", seqName, newIds.size(), sql);
}
if (newIds.isEmpty()) {
throw new PersistenceException("Always expecting more than 1 row from " + sql);
@@ -185,7 +164,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
} catch (SQLException e) {
if (e.getMessage().contains("Database is already closed")) {
String msg = "Error getting SEQ when DB shutting down " + e.getMessage();
logger.error(msg);
log.error(msg);
System.out.println(msg);
return Collections.emptyList();
} else {
@@ -2,8 +2,6 @@ package io.ebean.config.dbplatform;
import io.ebean.Transaction;
import io.ebean.util.JdbcClose;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.persistence.PersistenceException;
import javax.sql.DataSource;
@@ -20,12 +18,8 @@ import java.sql.SQLException;
*/
public class SimpleSequenceIdGenerator implements PlatformIdGenerator {
private static final Logger logger = LoggerFactory.getLogger(SimpleSequenceIdGenerator.class);
private final String sql;
private final DataSource dataSource;
private final String seqName;
/**
@@ -61,7 +55,7 @@ public class SimpleSequenceIdGenerator implements PlatformIdGenerator {
PreparedStatement pstmt = null;
ResultSet rset = null;
try {
c = useTxnConnection ? t.getConnection() : dataSource.getConnection();
c = useTxnConnection ? t.connection() : dataSource.getConnection();
pstmt = c.prepareStatement(sql);
rset = pstmt.executeQuery();
if (rset.next()) {
@@ -26,7 +26,6 @@ public class ClickHousePlatform extends DatabasePlatform {
this.booleanDbType = Types.INTEGER;
dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("UInt8"));
// using unsigned as default types ...
dbTypeMap.put(DbType.TINYINT, new DbPlatformType("UInt8", false));
dbTypeMap.put(DbType.SMALLINT, new DbPlatformType("UInt16", false));
@@ -34,15 +33,13 @@ public class ClickHousePlatform extends DatabasePlatform {
dbTypeMap.put(DbType.BIGINT, new DbPlatformType("UInt64", false));
dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("Decimal", 16, 3));
dbTypeMap.put(DbType.DOUBLE, new DbPlatformType("Float64", false));
dbTypeMap.put(DbType.DATE, new DbPlatformType("Date", false));
dbTypeMap.put(DbType.TIMESTAMP, new DbPlatformType("DateTime", false));
dbTypeMap.put(DbType.LOCALDATETIME, new DbPlatformType("DateTime", false));
dbTypeMap.put(DbType.VARCHAR, new DbPlatformType("String", false));
dbTypeMap.put(DbType.LONGVARCHAR, new DbPlatformType("String", false));
dbTypeMap.put(DbType.CLOB, new DbPlatformType("String", false));
dbTypeMap.put(DbType.JSONVARCHAR, new DbPlatformType("String", false));
dbTypeMap.put(DbType.UUID, new DbPlatformType("UUID", false));
dbTypeMap.put(DbType.INET, new DbPlatformType("String", false));
dbTypeMap.put(DbType.CIDR, new DbPlatformType("String", false));
@@ -5,8 +5,6 @@ import io.ebean.config.dbplatform.DbEncryptFunction;
/**
* H2 encryption support via encrypt decrypt function.
*
* @author rbygrave
*/
public class H2DbEncrypt extends AbstractDbEncrypt {
@@ -4,11 +4,7 @@ import org.h2.api.Trigger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.*;
import java.util.Arrays;
/**
@@ -16,7 +12,7 @@ import java.util.Arrays;
*/
public class H2HistoryTrigger implements Trigger {
private static final Logger logger = LoggerFactory.getLogger(H2HistoryTrigger.class);
private static final Logger log = LoggerFactory.getLogger(H2HistoryTrigger.class);
/**
* Hardcoding the column and history table suffix for now. Not sure how to get that
@@ -43,7 +39,6 @@ public class H2HistoryTrigger implements Trigger {
@Override
public void init(Connection conn, String schemaName, String triggerName, String tableName, boolean before, int type) throws SQLException {
// get the columns for the table
ResultSet rs = conn.getMetaData().getColumns(null, schemaName, tableName, null);
@@ -74,12 +69,11 @@ public class H2HistoryTrigger implements Trigger {
insertSql.append(");");
this.insertHistorySql = insertSql.toString();
logger.debug("History table insert sql: {}", insertHistorySql);
log.debug("History table insert sql: {}", insertHistorySql);
}
@Override
public void fire(Connection connection, Object[] oldRow, Object[] newRow) throws SQLException {
if (oldRow != null) {
// a delete or update event
Timestamp now = new Timestamp(System.currentTimeMillis());
@@ -88,8 +82,8 @@ public class H2HistoryTrigger implements Trigger {
// update event. Set the effective start timestamp to now.
newRow[effectStartPosition] = now;
}
if (logger.isDebugEnabled()) {
logger.debug("History insert: {}", Arrays.toString(oldRow));
if (log.isTraceEnabled()) {
log.trace("History insert: {}", Arrays.toString(oldRow));
}
insertIntoHistory(connection, oldRow);
}
@@ -99,7 +93,6 @@ public class H2HistoryTrigger implements Trigger {
* Insert the data into the history table.
*/
private void insertIntoHistory(Connection connection, Object[] oldRow) throws SQLException {
try (PreparedStatement stmt = connection.prepareStatement(insertHistorySql)) {
for (int i = 0; i < oldRow.length; i++) {
stmt.setObject(i + 1, oldRow[i]);
@@ -110,11 +103,11 @@ public class H2HistoryTrigger implements Trigger {
@Override
public void close() throws SQLException {
// do nothing
}
@Override
public void remove() throws SQLException {
// do nothing
}
}
@@ -51,7 +51,7 @@ public class H2Platform extends DatabasePlatform {
}
@Override
protected String withForUpdate(String sql, Query.ForUpdate forUpdateMode) {
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
// NOWAIT and SKIP LOCKED currently not supported with H2
return sql + " for update";
}
@@ -1,6 +1,7 @@
package io.ebean.config.dbplatform.hana;
import io.ebean.Query.ForUpdate;
import io.ebean.Query;
import io.ebean.Query.LockWait;
import io.ebean.annotation.PersistBatch;
import io.ebean.annotation.Platform;
import io.ebean.config.PlatformConfig;
@@ -68,16 +69,16 @@ public class HanaPlatform extends DatabasePlatform {
}
@Override
protected String withForUpdate(String sql, ForUpdate forUpdateMode) {
switch (forUpdateMode) {
case BASE:
protected String withForUpdate(String sql, LockWait lockWait, Query.LockType lockType) {
switch (lockWait) {
case WAIT:
return sql + " for update";
case NOWAIT:
return sql + " for update nowait";
case SKIPLOCKED:
return sql + " for update ignore locked";
default:
throw new IllegalArgumentException("Unknown update mode: " + forUpdateMode.name());
throw new IllegalArgumentException("Unknown update mode: " + lockWait);
}
}
@@ -51,6 +51,7 @@ public abstract class BaseMySqlPlatform extends DatabasePlatform {
dbTypeMap.put(DbType.BIT, new DbPlatformType("tinyint(1)"));
dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("tinyint(1)"));
dbTypeMap.put(DbType.TIMESTAMP, new DbPlatformType("datetime(6)"));
dbTypeMap.put(DbType.LOCALDATETIME, new DbPlatformType("datetime(6)"));
dbTypeMap.put(DbType.CLOB, new MySqlClob());
dbTypeMap.put(DbType.BLOB, new MySqlBlob());
dbTypeMap.put(DbType.BINARY, new DbPlatformType("binary", 255));
@@ -60,7 +61,7 @@ public abstract class BaseMySqlPlatform extends DatabasePlatform {
}
@Override
protected String withForUpdate(String sql, Query.ForUpdate forUpdateMode) {
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
// NOWAIT and SKIP LOCKED currently not supported with MySQL
return sql + " for update";
}
@@ -10,5 +10,6 @@ public class MySql55Platform extends BaseMySqlPlatform {
super();
this.platform = Platform.MYSQL55;
dbTypeMap.put(DbType.TIMESTAMP, new DbPlatformType("datetime"));
dbTypeMap.put(DbType.LOCALDATETIME, new DbPlatformType("datetime"));
}
}
@@ -5,8 +5,6 @@ import io.ebean.config.dbplatform.DbEncryptFunction;
/**
* MySql aes_encrypt aes_decrypt based encryption support.
*
* @author rbygrave
*/
public class MySqlDbEncrypt extends AbstractDbEncrypt {
@@ -48,8 +48,8 @@ public class NuoDbPlatform extends DatabasePlatform {
}
@Override
protected String withForUpdate(String sql, Query.ForUpdate forUpdateMode) {
switch (forUpdateMode) {
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
switch (lockWait) {
case NOWAIT:
return sql + " for update nowait";
case SKIPLOCKED:
@@ -11,8 +11,8 @@ public class Oracle11Platform extends OraclePlatform {
public Oracle11Platform() {
super();
this.platform = Platform.ORACLE11;
this.columnAliasPrefix = "c";
this.sqlLimiter = new OracleRownumSqlLimiter();
this.basicSqlLimiter = new OracleRownumBasicLimiter();
dbIdentity.setIdType(IdType.SEQUENCE);
}
}
@@ -60,7 +60,6 @@ public class OracleDbEncrypt extends AbstractDbEncrypt {
* @param decryptFunction the decrypt stored procedure
*/
public OracleDbEncrypt(String encryptFunction, String decryptFunction) {
this.varcharEncryptFunction = new OraVarcharFunction(encryptFunction, decryptFunction);
this.dateEncryptFunction = new OraDateFunction(encryptFunction, decryptFunction);
}
@@ -22,6 +22,7 @@ public class OraclePlatform extends DatabasePlatform {
public OraclePlatform() {
super();
this.platform = Platform.ORACLE;
this.columnAliasPrefix = "c";
this.supportsDeleteTableAlias = true;
this.maxTableNameLength = 30;
this.maxConstraintNameLength = 30;
@@ -79,8 +80,8 @@ public class OraclePlatform extends DatabasePlatform {
}
@Override
protected String withForUpdate(String sql, Query.ForUpdate forUpdateMode) {
switch (forUpdateMode) {
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
switch (lockWait) {
case SKIPLOCKED:
return sql + " for update skip locked";
case NOWAIT:
@@ -0,0 +1,35 @@
package io.ebean.config.dbplatform.oracle;
import io.ebean.config.dbplatform.BasicSqlLimiter;
/**
* Row limiter for Oracle 9,10,11 using rownum.
*/
public class OracleRownumBasicLimiter implements BasicSqlLimiter {
@Override
public String limit(String dbSql, int firstRow, int maxRows) {
if (firstRow < 1 && maxRows < 1) {
return dbSql;
}
StringBuilder sb = new StringBuilder(60 + dbSql.length());
int lastRow = maxRows;
if (lastRow > 0) {
lastRow += firstRow;
}
sb.append("select * from (select ");
if (maxRows > 0) {
sb.append("/*+ FIRST_ROWS(").append(maxRows).append(") */ ");
}
sb.append("a.*, rownum rn_ from (");
sb.append(dbSql).append(") a ");
if (lastRow > 0) {
sb.append(" where rownum <= ").append(lastRow);
}
sb.append(") ");
if (firstRow > 0) {
sb.append(" where rn_ > ").append(firstRow);
}
return sb.toString();
}
}
@@ -4,6 +4,7 @@ import io.ebean.BackgroundExecutor;
import io.ebean.Query;
import io.ebean.annotation.PartitionMode;
import io.ebean.annotation.Platform;
import io.ebean.config.PlatformConfig;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.config.dbplatform.DbPlatformType;
import io.ebean.config.dbplatform.DbType;
@@ -25,6 +26,15 @@ import java.sql.Types;
*/
public class PostgresPlatform extends DatabasePlatform {
private static final String SKIP_LOCKED = " skip locked";
private static final String NO_WAIT = " nowait";
private static final String FOR_UPDATE = " for update";
private static final String FOR_NO_KEY_UPDATE = " for no key update";
private static final String FOR_SHARE = " for share";
private static final String FOR_KEY_SHARE = " for key share";
private boolean forUpdateNoKey;
public PostgresPlatform() {
super();
this.platform = Platform.POSTGRES;
@@ -59,28 +69,31 @@ public class PostgresPlatform extends DatabasePlatform {
DbPlatformType dbTypeText = new DbPlatformType("text", false);
DbPlatformType dbBytea = new DbPlatformType("bytea", false);
dbTypeMap.put(DbType.UUID, new DbPlatformType("uuid", false));
dbTypeMap.put(DbType.INET, new DbPlatformType("inet", false));
dbTypeMap.put(DbType.CIDR, new DbPlatformType("cidr", false));
dbTypeMap.put(DbType.HSTORE, new DbPlatformType("hstore", false));
dbTypeMap.put(DbType.JSON, new DbPlatformType("json", false));
dbTypeMap.put(DbType.JSONB, new DbPlatformType("jsonb", false));
dbTypeMap.put(DbType.INTEGER, new DbPlatformType("integer", false));
dbTypeMap.put(DbType.DOUBLE, new DbPlatformType("float"));
dbTypeMap.put(DbType.TINYINT, new DbPlatformType("smallint"));
dbTypeMap.put(DbType.TIMESTAMP, new DbPlatformType("timestamptz"));
dbTypeMap.put(DbType.LOCALDATETIME, new DbPlatformType("timestamp"));
dbTypeMap.put(DbType.BINARY, dbBytea);
dbTypeMap.put(DbType.VARBINARY, dbBytea);
dbTypeMap.put(DbType.BLOB, dbBytea);
dbTypeMap.put(DbType.CLOB, dbTypeText);
dbTypeMap.put(DbType.LONGVARBINARY, dbBytea);
dbTypeMap.put(DbType.LONGVARCHAR, dbTypeText);
}
@Override
public void configure(PlatformConfig config) {
super.configure(config);
forUpdateNoKey = config.isForUpdateNoKey();
}
@Override
protected void addGeoTypes(int srid) {
dbTypeMap.put(DbType.POINT, geoType("point", srid));
@@ -108,22 +121,32 @@ public class PostgresPlatform extends DatabasePlatform {
*/
@Override
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) {
return new PostgresSequenceIdGenerator(be, ds, seqName, sequenceBatchSize);
}
@Override
protected String withForUpdate(String sql, Query.ForUpdate forUpdateMode) {
switch (forUpdateMode) {
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
switch (lockWait) {
case SKIPLOCKED:
return sql + " for update skip locked";
return sql + lock(lockType) + SKIP_LOCKED;
case NOWAIT:
return sql + " for update nowait";
return sql + lock(lockType) + NO_WAIT;
default:
return sql + " for update";
return sql + lock(lockType);
}
}
private String lock(Query.LockType lockType) {
switch (lockType) {
case UPDATE: return FOR_UPDATE;
case NO_KEY_UPDATE: return FOR_NO_KEY_UPDATE;
case SHARE: return FOR_SHARE;
case KEY_SHARE: return FOR_KEY_SHARE;
case DEFAULT: return forUpdateNoKey ? FOR_NO_KEY_UPDATE : FOR_UPDATE;
}
return FOR_UPDATE;
}
@Override
public boolean tablePartitionsExist(Connection connection, String table) throws SQLException {
try (PreparedStatement statement = connection.prepareStatement("select count(*) from pg_inherits i WHERE i.inhparent = ?::regclass")) {

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