Compare commits

...
210 Commits
Author SHA1 Message Date
Rob Bygrave 1d413b03dd Fix for #3381 - Empty OneToMany when overflowing LazyLoadBatchSize and mixed queries
14.0.0 via #3295 introduced this bug.

 #3295 introduced a behaviour where bulk updates clear the persistence context. Now the lazy loading of a BeanCollection works with an assumption that the "parent bean" is in the persistence context (and this assumption is broken with that change for this test case). That is, the bulk update is clearing the persistence context - removing the parent bean BEFORE the lazy loading is invoked ... and that doesn't then work because the parent bean isn't in the persistence context.

 This fix means that when lazy loading many's, the parent beans are putIfAbsent into the persistence context.
2024-04-04 20:23:10 +13:00
Rob Bygrave ab45ad34e0 Version 14.0.2 2024-03-21 22:07:12 +13:00
Rob Bygrave 24b514f851 Bump ebean-agent, no effective change 2024-03-21 21:55:02 +13:00
Rob BygraveandGitHub 582fec7ce4 For #3363 disable flushOnQuery before BeanPersistAdapter post-processors (#3367) 2024-03-21 21:51:10 +13:00
Rob BygraveandGitHub 0b11c541c8 fix: #3142 Cascading a OneToMany, set the relationship when the child isn't new or dirty (#3366)
That is, previously the relationship back from the child to the parent was being updated when the child bean was new or dirty BUT NOT in the case when the child bean was loaded and unchanged.

This fix includes that case updating the ManyToOne side of the relationship on the child when the save is cascaded.
2024-03-21 00:14:54 +13:00
Rob BygraveandGitHub 540ceab96f feat: Add query.setHint() to support sql hint as inline comment in select queries (#3365)
* feat: Add query.setHint() to support sql hint as inline comment in select queries

This is for ORM queries only.

An ORM query like:

    new QCustomer()
      .setHint("FirstRows")
      .select(QCustomer.Alias.id, QCustomer.Alias.name)
      .findList();

Produces SQL that includes the hint as an inline comment like:

  select /*+ FirstRows */ t0.id, t0.name
  from customer t0

* Fix test QOrderTest
2024-03-20 21:48:43 +13:00
Rob BygraveandGitHub 8b858a073a feat: Add includeLabelInSql configuration option to include query label as inline comment in generated sql select (#3362)
* feat: Add includeLabelInSql configuration option to include query label as inline comment in generated sql select

The generated select queries can look like:

select /* MyInnerTest.insert_and_find */ t0.id, ...

Using either query.setLabel() or profile location (which all query beans get by default). This means that tooling looking at sql in the database can more easily relate that sql back to application code.

* More tests for labels with includeLabelInSql=true

* Remove trim when using profileLocation label
2024-03-18 07:38:30 +13:00
Rob BygraveandGitHub 02dafc9838 Merge pull request #3360 from ebean-orm/feature/refactor-DbExpressionRequest
Refactor extract DbExpressionRequest interface for db platform specific expressions
2024-03-08 00:53:56 +13:00
Rob Bygrave 0816810d3b Refactor extract DbExpressionRequest interface for db platform specific expressions
This provides a simpler DbExpressionRequest interface for db platform specific expression adapters (rather than the SpiExpressionRequest which has more features that we don't wish to expose to those expression adapters.
2024-03-07 22:45:21 +13:00
Rob Bygrave 1f6e2ee844 No effective change - update test only ClusterTest, increase wait to 200ms 2024-03-07 20:59:41 +13:00
Rob Bygrave dc00765a98 Merge branch 'fix-for-db2' 2024-03-07 20:45:57 +13:00
Rob Bygrave a48b2f4ebe #3354 Use 4000 for DB Lob detection with distinct query
- Use 4000 to match the DB2 logic for considering a column a lob (for distinct etc)
- Rename distinctNoLobs -> platformDistinctNoLobs
- Rename  isDbLob() -> isLobForPlatform()
- Rename unselectLobs() -> unselectLobsForPlatform()
2024-03-07 20:45:40 +13:00
Rob BygraveandGitHub 837563544f Merge pull request #3357 from ebean-orm/feature/avaje-config-dependency-ContainerConfig
Modify ContainerConfig to remove the avaje-config dependency
2024-03-07 20:23:36 +13:00
Rob Bygrave fd199f406b Modify ContainerConfig to remove the avaje-config dependency
This actually reverts a change that was made in commit:
https://github.com/ebean-orm/ebean/commit/803f1d86428ce3b653276d72207e5a0009b57d16
2024-03-05 21:18:27 +13:00
Roland Praml a48e96c7e9 FIX broken test for DB2 2024-03-04 10:02:05 +01:00
Rob Bygrave 7ba6e5f67d Add howto-deploy-to-central.md 2024-03-03 22:08:47 +13:00
Rob Bygrave 6ce42b1ca3 Version 14.0.1 2024-03-03 20:24:26 +13:00
Rob BygraveandGitHub 89617cefbe Merge pull request #3353 from ebean-orm/feature/bump-migration-14
dep: Bump ebean-migration to 14.0.0, no effective change
2024-03-03 20:19:40 +13:00
Rob Bygrave dd377621a4 dep: Bump ebean-migration to 14.0.0, no effective change
No effective change in that ebean-migration 14.0.0 has no change, it was released to align version numbers with 14.x
2024-03-03 20:19:17 +13:00
Rob Bygrave d844855462 Bump ebean-agent to 14.0.1 2024-03-03 18:32:14 +13:00
Rob BygraveandGitHub f68c25d5f3 Merge pull request #3352 from ebean-orm/feature/dep-common-components
dep: Update the common components to 14.0.0 ebean-joda-types, ebean-jackson-jsonnode
2024-03-03 18:29:15 +13:00
Rob Bygrave 61cfc7a979 dep: Update the common components to 14.0.0 ebean-joda-types, ebean-jackson-jsonnode 2024-03-03 17:01:36 +13:00
Rob BygraveandGitHub 3c98ee7f1b Merge pull request #3351 from ebean-orm/dep/bump-config
Bump test dependencies only - logback and ebean-test-containers
2024-03-03 16:54:56 +13:00
Rob Bygrave 0738316f15 Bump test dependencies only - logback and ebean-test-containers 2024-03-03 16:54:22 +13:00
Rob BygraveandGitHub ceb83befa3 Merge pull request #3350 from ebean-orm/dep/bump-config
dep: Bump avaje-config to 3.12 - supports AWS AppConfig & Dynamic Logback
2024-03-03 15:42:59 +13:00
Rob Bygrave a0b04cceda dep: Bump avaje-config to 3.12 - supports AWS AppConfig & Dynamic Logback
This version of avaje-config supports using AWS AppConfig as a configuration source (via avaje-aws-appconfig). It also supports dynamic changing Logback logging levels (via avaje-dynamic-logback).
2024-03-03 15:38:14 +13:00
Rob Bygrave 03edfb5454 git workflow trigger on push to master and pull_request 2024-03-03 15:33:39 +13:00
Rob BygraveandGitHub 62015451df Merge pull request #3349 from ebean-orm/feature/dep-ebean-datasource
dep: Bump ebean-datasource to 8.12
2024-03-03 15:32:36 +13:00
Rob Bygrave ed9113efe6 dep: Bump ebean-datasource to 8.12
This adds the option to register a JVM shutdown hook (which we generally will not use with ebean as the ebean io.ebean.Database shutdown wants to shutdown the DataSource after any background tasks have completed).

This also adds an experimental feature for use with AWS Lambda to check for old idle connections due to lambda suspension.
2024-03-03 15:24:44 +13:00
Rob Bygrave 334793667e Add deployment error message for ManyToMany with one of the related beans missing an @Id property 2024-03-03 14:14:23 +13:00
Rob BygraveandGitHub 351a1c4739 Merge pull request #3348 from ebean-orm/feature/3313-fetchGroup-with-config
#3313 Ability to configure fetch batch size when using FetchGroups and query beans
2024-03-03 13:53:52 +13:00
Rob Bygrave b2de333dcc #3313 Ability to configure fetch batch size when using FetchGroups and query beans
We can do this currently using string paths and properties, this adds support for doing this when using query beans and strong types
2024-03-03 13:47:49 +13:00
Rob Bygrave 6091f7b683 No effective change - tidy test TestJsonImplicitLoaded 2024-03-03 12:25:25 +13:00
Rob BygraveandGitHub 43fb84cbc0 Merge pull request #3345 from FOCONIS/jsonwrite-loaded-props
NEW: Allow control of jsonwrite-loadedprops
2024-03-03 12:23:17 +13:00
Rob BygraveandGitHub 52a4e9e19b Merge pull request #3347 from ebean-orm/feature/3337-querybean-imports
#3337 Fix querybean-generation to not import the entity bean type
2024-03-03 12:17:42 +13:00
Rob Bygrave a2cdea24ed #3337 Fix querybean-generation to not import the entity bean type
Use the full canonical name of the entity bean in the generated code.
2024-03-03 12:13:49 +13:00
Rob Bygrave cd780208e5 Javadoc format only for io.ebean.Database 2024-03-03 11:45:36 +13:00
Rob BygraveandGitHub 9ce0e923d7 Merge pull request #3346 from ebean-orm/feature/lengthCheck-postgres
#3341 String length validation with Postgres PGobject (JSON/JSONB)
2024-03-02 10:26:52 +13:00
Rob Bygrave 9e461e4708 #3341 String length validation with Postgres PGobject (JSON/JSONB) 2024-03-02 10:06:22 +13:00
Rob Bygrave 5fa09a6f90 #3341 String length validation with Postgres PGobject (JSON/JSONB) 2024-03-02 09:52:04 +13:00
Rob Bygrave 6babb2e6f5 Add ebean.lengthCheck for mariadb test run 2024-03-02 09:39:25 +13:00
Rob Bygrave 26abe27e42 Add ebean.lengthCheck for sqlserver17 test run 2024-03-02 09:38:33 +13:00
Rob Bygrave 9b18d46b78 Add ebean.lengthCheck for mysql test run 2024-03-02 09:27:05 +13:00
Roland Praml eed487ad26 NEW: Allow control of jsonwrite-loadedprops 2024-02-29 13:26:22 +01:00
Rob BygraveandGitHub c10865dfaf Merge pull request #3344 from ebean-orm/feature/bump-avaje-config-311
Bump avaje-config to 3.11
2024-02-27 21:22:38 +13:00
Rob Bygrave 2352df309c Bump avaje-config to 3.11 2024-02-27 21:21:58 +13:00
Rob Bygrave feb2bd1e15 String length validation tidy up 2024-02-27 21:04:19 +13:00
Rob Bygrave 11c9bdfc6f Squashed commit of the following:
commit 20152e16891582f8ff466a93ec2cf01871824d6d
Author: Rob Bygrave <robin.bygrave@gmail.com>
Date:   Tue Feb 27 20:59:51 2024 +1300

    #3341 Update DatabaseConfig for fluid style + javadoc

commit 1c495a7384
Author: Roland Praml <roland.praml@foconis.de>
Date:   Mon Feb 26 10:25:42 2024 +0100

    Fix: Compile errors

commit 574876b758
Merge: df7b04877 77634fc3e
Author: Roland Praml <roland.praml@foconis.de>
Date:   Fri Feb 23 16:16:39 2024 +0100

    Merge branch 'master-rob' into FOCONIS-string-length-validation

commit df7b04877d
Author: Rob Bygrave <robin.bygrave@gmail.com>
Date:   Mon Jun 26 21:16:32 2023 +1200

    #3121 BindMaxLength validation

    At deploy time derive a BindMaxLength property to use
    per BeanProperty

commit 4683877e0b
Merge: 9a4b9d4be d0020ab8c
Author: Rob Bygrave <robin.bygrave@gmail.com>
Date:   Fri Jun 23 16:51:34 2023 +1200

    Merge branch 'string-length-validation' of github.com:FOCONIS/ebean into FOCONIS-string-length-validation

commit d0020ab8ce
Author: Roland Praml <roland.praml@foconis.de>
Date:   Tue Jun 20 14:47:20 2023 +0200

    Length validation less invasive

commit 9b3b8ad46a
Author: Roland Praml <roland.praml@foconis.de>
Date:   Tue Jun 20 13:03:04 2023 +0200

    extended DataBind, so that it could return the last bound object

commit ca3c02bc1c
Author: Roland Praml <roland.praml@foconis.de>
Date:   Mon Jun 19 09:52:52 2023 +0200

    Failing test for SqlServer
2024-02-27 21:04:06 +13:00
Rob BygraveandGitHub 4a6fc98395 Merge pull request #3339 from ebean-orm/fix/3338
Fix for #3338 Potential shutdown hang with SpringContextShutdownHook …
2024-02-26 21:58:39 +13:00
Rob Bygrave 7322030e90 Fix for #3338 Potential shutdown hang with SpringContextShutdownHook and ebean ShutdownHook 2024-02-26 08:32:44 +13:00
Rob BygraveandGitHub 77634fc3eb Merge pull request #3336 from ebean-orm/feature/bump-postgresql-4272
Bump postgresql dependency to 42.7.2
2024-02-21 16:11:24 +13:00
robin.bygrave ed8d4b5fc4 Bump postgresql dependency to 42.7.2 2024-02-21 16:05:13 +13:00
Rob BygraveandGitHub 187cc0903d Merge pull request #3329 from ebean-orm/feature/bump-test-dependencies
Bump test dependencies for assertj and bytebuddy
2024-02-19 22:04:56 +13:00
Rob Bygrave 1d7a14c8f4 Bump test dependencies for assertj and bytebuddy 2024-02-19 21:51:38 +13:00
Rob Bygrave c58b7d3da3 Test ebean.properties config values 2024-02-15 22:51:26 +13:00
Rob Bygrave 6b2cdc14aa Version 14.0.0 2024-02-15 22:48:38 +13:00
Rob Bygrave 6d712a92a0 Bump ebean-agent to 14.0.0, no functional change 2024-02-15 22:21:09 +13:00
Rob BygraveandGitHub ea11b0c3b6 Merge pull request #3289 from FOCONIS/fix-nested-user-objects
Change semantic of userObjects in nested transaction
2024-02-15 22:10:45 +13:00
Rob BygraveandGitHub 08e8402d05 Merge pull request #3301 from ebean-orm/feature/3295-PC-clear-on-bulk-update
#3295 Clear PersistenceContext on execution of bulk updates or deletes
2024-02-15 22:09:16 +13:00
Rob BygraveandGitHub 006ad79379 Merge branch 'master' into feature/3295-PC-clear-on-bulk-update 2024-02-15 22:09:03 +13:00
Rob BygraveandGitHub 0e063549cd Merge pull request #3327 from ebean-orm/feature/remove-deprecated-commitTransaction
Remove deprecated database.commitTransaction(), migrate to transaction.commit()
2024-02-15 22:07:32 +13:00
Rob BygraveandGitHub 4f0d2cabfb Merge pull request #3325 from ebean-orm/feature/default-batchSize-100
Change default persistBatchSize from 20 to 100 (as a better default value)
2024-02-15 22:07:14 +13:00
Rob Bygrave 80b2d9f983 Remove deprecated database.commitTransaction(), migrate to transaction.commit()
Remove the deprecated methods:
- DB.commitTransaction()
- DB.rollbackTransaction()
- DB.endTransaction()
- database.commitTransaction()
- database.rollbackTransaction()
- database.endTransaction()

Migrate to using try-with-resources and transaction.commit(), transaction.rollback()
2024-02-15 21:56:57 +13:00
Rob Bygrave 287d0c467d #3326 Update the test example of Postgres DML with RETURNING clause to use explicit transactions and transaction.addModification() 2024-02-11 14:25:01 +13:00
Rob Bygrave a8835379e7 #3326 Add test as example of Postgres DML with RETURNING clause 2024-02-11 13:18:19 +13:00
Rob Bygrave e4df20b9dc Update test TestPersistCascade with default batch size 100 2024-02-10 13:28:04 +13:00
Rob Bygrave 261b13ef4b Version 13.26.1 2024-02-10 12:40:30 +13:00
Rob Bygrave 7639034d7c Bump ebean-agent to 13.26.1 (no functional change here) 2024-02-10 12:17:47 +13:00
Rob Bygrave e6e53e0d93 Change default persistBatchSize from 20 to 100 (as a better default value)
This is the batch size used with PreparedStatement executeBatch() with
batched inserts, updates and deletes. 20 is really on the low side and
bumping this default to 100 seems good and right.
2024-02-10 12:15:50 +13:00
Rob BygraveandGitHub c71971eb5c Merge pull request #3322 from ebean-orm/fix/3319
(fix) Future queries do not trigger flush on BatchedPstmtHolder for #3319
2024-02-10 12:12:47 +13:00
Rob BygraveandGitHub 357af58db4 Merge pull request #3324 from ebean-orm/feature/postgres_insertOnConflict
Add support for Postgres INSERT ON CONFLICT update | nothing
2024-02-10 12:08:44 +13:00
Rob BygraveandGitHub 0abdb1550a Merge pull request #3310 from Ichtil/one_to_many_list_clear_test
Previous entities are not deleted when replacing OneToMany collection with a new one
2024-02-10 12:03:16 +13:00
Rob Bygrave c32fc814f6 Add support for insert/insertAll with both options and explicit transaction 2024-02-10 12:00:32 +13:00
Rob Bygrave 8e035939dc Add support for Postgres INSERT ON CONFLICT update | nothing
Adds InsertOptions with ability to control the options used
for insert with Postgres around ON CONFLICT.
2024-02-10 01:07:44 +13:00
Rob Bygrave edf98ee250 Fix test OneToManyListMarkAsDirtyTest with some wait time 2024-02-09 15:46:34 +13:00
Rob Bygrave 5f0a75a130 No effective change, update test renaming internal variables 2024-02-09 15:26:28 +13:00
Rob Bygrave d2f16cbf6a #3310 Fix for orphanRemoval with updated parent and 'vanilla collection'
The issue fixed here is a timing one where the parent bean is being updated.
The updated parent bean has its internal state reset before the cascade down
to the SaveManyBeans where for this case it needs to identify is the 'vanilla'
collection has set (via setChildren(new ArrayList()).

This fix is a change that for updated beans the dirtyProperties is always obtained
and then use this for the isChangedProperty() check.
2024-02-09 15:24:47 +13:00
Rob Bygrave 04ba81d12f #3310 Update test only, reuse existing entity beans
- Reuse the existing OmBeanListParent and child
- Simplify the test setup code
- Rename test methods to maybe better reflect what I think is failing

Noting that markAsDirty doesn't specifically have anything to do with this bug but it's more on whether the parent bean is dirty or dirty (markAsDirty is just a way to make the parent bean dirty).
2024-02-09 08:30:42 +13:00
Rob Bygrave f63e7ed5af Add test only for orphan removal to TestOrphanRemovalOverwrite
Using clear() and add() when the same id value is used
2024-02-08 00:14:22 +13:00
Rob Bygrave 66940c0f14 Update tests only for BeanList BeanSet BeanMap
Use Product entity with equals/hashCode implementation added via ebean enhancement
2024-02-07 22:29:05 +13:00
Rob Bygrave 1f48b3a6b3 (fix) Future queries do not trigger flush on BatchedPstmtHolder for #3319
This change is that findFutureCount, findFutureList, findFutureIds do not trigger a flush on BatchedPstmtHolder.

This is to address the possible ConcurrentModificationException that could occur at BatchedPstmtHolder.closeStatements(BatchedPstmtHolder.java:153)
2024-02-03 08:20:58 +13:00
Rob BygraveandGitHub 7d368097e9 Merge pull request #3321 from ebean-orm/feature/tidy-OrmQueryRequest-readOnly
Tidy OrmQueryRequest isReadOnly, just use query.isReadOnly instead
2024-02-02 14:44:06 +13:00
Rob Bygrave c849e29316 Tidy OrmQueryRequest isReadOnly, just use query.isReadOnly instead 2024-02-02 14:43:31 +13:00
Rob BygraveandGitHub c78a3dd6c4 Merge pull request #3318 from FOCONIS/fix-db2-test
Exclude test for DB2
2024-01-31 22:57:49 +13:00
Noemi Praml a4455ddbf2 Exclude test for DB2 2024-01-31 10:17:16 +01:00
Rob BygraveandGitHub 9787af77e4 Merge pull request #3315 from FOCONIS/db2-select-for-update
ADD: DB2 supports select .. for update queries
2024-01-30 22:53:19 +13:00
Noemi Praml 3786fb09a5 ADD: DB2 supports select .. for update queries 2024-01-29 15:12:21 +01:00
Rob Bygrave f34e7b6003 Version 13.26.0 2024-01-20 22:01:30 +13:00
Rob BygraveandGitHub 089dd8e364 Merge pull request #3311 from ebean-orm/feature/findSingleAttributeOrEmpty
enh: Add findSingleAttributeOrEmpty() returning Optional
2024-01-19 15:23:27 +13:00
Rob Bygrave 44770382fb enh: Add findSingleAttributeOrEmpty() returning Optional 2024-01-19 10:41:54 +13:00
Rob Bygrave 6645e5b9ec Update the test comments in TestPersistenceContextQueryScope
To reflect the behaviour with #3295
2024-01-19 08:58:19 +13:00
Rob BygraveandGitHub 2a62d413cc Merge pull request #3308 from Incanus3/fix/querybean_or_with_exists
fix TQRootBean.exists() when used with .or()
2024-01-19 08:29:29 +13:00
Rob Bygrave 0046d983cb Adjust test such that table alias does not clash
The .raw("contact.customer_id = customer.id") clashes as "customer.id" is
a logical path from contact
2024-01-19 08:14:58 +13:00
Jan Klička 006e33cb3e One to many replacing collection failing test cases 2024-01-18 17:29:24 +01:00
Jan Klička e80e8e027a One to many replacing collection failing test cases 2024-01-18 16:49:04 +01:00
Jakub Kaláb 2e1b52d7d4 WIP: fix TQRootBean.exists() when used with .or() 2024-01-18 11:32:34 +01:00
Rob BygraveandGitHub 09d5163396 Merge pull request #3307 from ebean-orm/feature/bump-avaje-config-310
Bump avaje-config to version 3.10
2024-01-18 22:30:42 +13:00
Rob Bygrave a6a38b9a92 Bump avaje-config to version 3.10 2024-01-18 22:30:09 +13:00
Rob BygraveandGitHub bd4521b240 Merge pull request #3306 from ebean-orm/feature/querybean-deprecated
Add forRemoval=true for existing Deprecated methods in query beans
2024-01-18 22:28:23 +13:00
Rob Bygrave 8a7379879b Add forRemoval=true for existing Deprecated methods in query beans 2024-01-18 20:15:57 +13:00
Rob BygraveandGitHub b78dd6f79a Merge pull request #3304 from ebean-orm/feature/3296-querybean-copy
#3296 Add copy() method to query beans
2024-01-15 22:38:30 +13:00
Rob Bygrave 4ebb5fd112 #3296 Add copy() method to query beans 2024-01-15 22:30:17 +13:00
Rob Bygrave 487368976f Tidy SimpleQueryBeanWriter internals 2024-01-15 22:03:17 +13:00
Rob Bygrave c6defceec9 Add additional test for filterMany() with fetch() 2024-01-15 21:02:47 +13:00
Rob Bygrave 3576aafffc #3295 When isAutoPersistUpdates is used do NOT clear the PersistenceContext
Also make improvements to the test asserts in TestPersistenceContextQueryScope
2024-01-10 23:23:47 +13:00
Rob Bygrave 66234249c6 #3295 Clear PersistenceContext on execution of bulk updates or deletes
Using SqlUpdate or an ORM Update query clear the appropriate part of
the PersistenceContext. The effect is that ORM queries executed after
a bulk update will effectively load a fresh copy of the data from the
database and will not reuse an instance from the persistence context
if the bean in question had already been loaded.
2024-01-09 07:44:27 +13:00
Rob BygraveandGitHub 8ed3b765ec Merge pull request #3299 from ebean-orm/feature/3294-warnings
#3294 Suppress compiler warnings on generated query bean `filterMany()`
2023-12-22 08:33:31 +13:00
Rob BygraveandGitHub fcbcc53e27 Merge pull request #3298 from ebean-orm/feature/add-usingConnection-dtoQuery
Add usingConnection() to DtoQuery and SqlQuery
2023-12-22 08:25:48 +13:00
Rob Bygrave b377e1a618 #3294 Suppress compiler warnings on generated query bean filterMany() 2023-12-22 08:24:54 +13:00
Rob Bygrave a0f612ed71 Add usingConnection() to DtoQuery and SqlQuery
For the case where we have a java.sql.Connection and wish
to execute a DtoQuery or SqlQuery using that connection.
2023-12-21 21:24:02 +13:00
Roland Praml 6f64821584 Change semantic of userObjects in nested transaction 2023-12-08 14:50:30 +01:00
Rob Bygrave 47e97a77a8 Version 13.25.2 2023-12-07 20:18:40 +13:00
Rob Bygrave e8d3f50bb4 Bump ebean-agent to 13.25.2 2023-12-07 19:57:55 +13:00
Rob BygraveandGitHub 716cfaf938 Merge pull request #3286 from ebean-orm/feature/dbarray-instant-and-localdate
Add support for LocalDate and Instant with DbArray
2023-12-07 08:57:40 +13:00
robin.bygrave 7cd9e5ee03 Add support for LocalDate and Instant with DbArray 2023-12-06 14:54:30 +13:00
Rob Bygrave f9c9bea623 Follow up for #3248 - add betweenProperties on query bean 2023-12-06 00:40:57 +13:00
Rob Bygrave 720832122c Follow up for #3248 - add betweenProperties on query bean 2023-12-05 23:32:16 +13:00
Rob BygraveandGitHub 7b635acf56 Merge pull request #3284 from raphaelNguyen/master
Expose betweenProperties on query bean
2023-12-05 23:21:26 +13:00
Raphael Nguyen 6b7efe65d7 Expose betweenProperties on query bean 2023-12-05 15:08:16 +11:00
Rob BygraveandGitHub 03cd4000f0 Merge pull request #3282 from ebean-orm/dependabot/maven/ch.qos.logback-logback-classic-1.3.12
Bump ch.qos.logback:logback-classic from 1.2.11 to 1.3.12
2023-11-30 13:59:21 +13:00
Rob BygraveandGitHub dfd6434b59 Merge pull request #3281 from ebean-orm/dependabot/maven/tests/test-java16/ch.qos.logback-logback-classic-1.3.12
Bump ch.qos.logback:logback-classic from 1.2.11 to 1.3.12 in /tests/test-java16
2023-11-30 13:59:08 +13:00
Rob BygraveandGitHub 4e7480237b Merge pull request #3283 from ebean-orm/dependabot/maven/tests/test-kotlin/ch.qos.logback-logback-classic-1.3.12
Bump ch.qos.logback:logback-classic from 1.2.11 to 1.3.12 in /tests/test-kotlin
2023-11-30 13:58:52 +13:00
dependabot[bot]andGitHub 9bfcf07486 Bump ch.qos.logback:logback-classic in /tests/test-kotlin
Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.2.11 to 1.3.12.
- [Commits](https://github.com/qos-ch/logback/compare/v_1.2.11...v_1.3.12)

---
updated-dependencies:
- dependency-name: ch.qos.logback:logback-classic
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-29 22:15:53 +00:00
dependabot[bot]andGitHub b1f1344057 Bump ch.qos.logback:logback-classic from 1.2.11 to 1.3.12
Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.2.11 to 1.3.12.
- [Commits](https://github.com/qos-ch/logback/compare/v_1.2.11...v_1.3.12)

---
updated-dependencies:
- dependency-name: ch.qos.logback:logback-classic
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-29 22:13:26 +00:00
dependabot[bot]andGitHub 07201c1519 Bump ch.qos.logback:logback-classic in /tests/test-java16
Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.2.11 to 1.3.12.
- [Commits](https://github.com/qos-ch/logback/compare/v_1.2.11...v_1.3.12)

---
updated-dependencies:
- dependency-name: ch.qos.logback:logback-classic
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-29 22:13:04 +00:00
Rob BygraveandGitHub 455a9fdffc Merge pull request #3280 from ebean-orm/feature/typequery-imports-tqrootbean
QueryBean generation - use full class names for TQRootBean, TQAssocBean
2023-11-29 01:21:00 +13:00
Rob Bygrave 3f67425727 QueryBean generation - conditionally fully qualify the property types
If there is an entity bean short name clash like PString, PLong, etc then
fully qualify all the property types in the generated code, otherwise use
imports for the property types.
2023-11-29 00:46:56 +13:00
Rob Bygrave 3fd9ae06db QueryBean generation - use fully qualify use of DB 2023-11-29 00:22:45 +13:00
Rob Bygrave a8ce726e47 QueryBean generation - use full class names for TQRootBean, TQAssocBean
Rather than imports, such that these are not possible name clashes with
beans of the exact same name.
2023-11-28 21:51:07 +13:00
Rob BygraveandGitHub 29cd1a143d Merge pull request #3277 from ebean-orm/feature/bump-datasource2
Bump ebean-datasource to 8.11 with support for Driver by class
2023-11-23 23:34:23 +13:00
Rob Bygrave 6a19c6a0ce Bump ebean-datasource to 8.11 with support for Driver by class
- Can specify explicit driver by class or instance
- Can use a DataSource as connection source
2023-11-23 23:31:29 +13:00
Rob BygraveandGitHub eaec515cc1 Merge pull request #3276 from ebean-orm/feature/skipCheckForReadOnly
skipDataSourceCheck() when using readOnlyDatabase
2023-11-23 23:27:21 +13:00
Rob Bygrave 97709d3493 skipDataSourceCheck() when using readOnlyDatabase
As we don't want the warning logged in this case:
DataSource [{0}] has autoCommit defaulting to true!
2023-11-23 23:23:53 +13:00
Rob Bygrave 87ad874621 Read the readOnlyDatabase property via loadSettings() 2023-11-23 23:15:58 +13:00
Rob Bygrave dfe95f6fc0 Version 13.25.1 2023-11-22 17:50:09 +13:00
Rob Bygrave 05feccfeb6 Bump ebean-agent 2023-11-22 17:46:54 +13:00
Rob BygraveandGitHub 196cb09c66 Merge pull request #3274 from ebean-orm/feature/3269
#3268 - @DbComment on @ManyToOne fields are ignored (ddl-generator)
2023-11-21 23:54:26 +13:00
Rob Bygrave 589e198301 #3268 - @DbComment on @ManyToOne fields are ignored (ddl-generator) 2023-11-21 23:53:29 +13:00
Rob BygraveandGitHub b2b81677e8 Merge pull request #3273 from ebean-orm/feature/3269
#3269 - @JoinColumns set ForeignKey is none in ddl , but is not work
2023-11-21 23:42:06 +13:00
Rob Bygrave f032aad22e #3269 - @JoinColumns set ForeignKey is none in ddl , but is not work 2023-11-21 23:40:21 +13:00
Rob Bygrave c48e5428c5 #3265 Fix for Update Query logging to trim large values in bind log 2023-11-21 22:32:35 +13:00
Rob Bygrave cbca940611 Merge branch 'FOCONIS-findsingleattribute-beanfindcontroller' 2023-11-21 22:05:12 +13:00
Rob Bygrave 0da3772ae9 #3270 Fix for use with BeanFindController and attribute queries
The existence of a BeanFindController should not break the use of
single attribute queries + still allow auto-tuning.
2023-11-21 22:04:47 +13:00
Rob Bygrave 496ef36b11 Merge branch 'findsingleattribute-beanfindcontroller' of github.com:FOCONIS/ebean into FOCONIS-findsingleattribute-beanfindcontroller 2023-11-21 21:40:09 +13:00
Rob BygraveandGitHub a4a2aba56f Merge pull request #3272 from ebean-orm/feature/readOnlyDatabase
Refactor tidy internals of DbPrimary, DatabaseFactory, ContainerConfi…
2023-11-21 21:20:35 +13:00
Rob Bygrave 803f1d8642 Refactor tidy internals of DbPrimary, DatabaseFactory, ContainerConfig, ClusterManager 2023-11-20 22:18:53 +13:00
Rob BygraveandGitHub ff1c73e20d Merge pull request #3266 from ebean-orm/feature/readOnlyDatabase
Add read only database configuration/builder option
2023-11-17 14:10:51 +13:00
Noemi Praml 7afd37cd98 Failing Tests with CustomerFindController 2023-11-14 17:05:42 +01:00
Rob Bygrave 24bb364d40 Add read only database configuration/builder option
When using DatabaseBuilder.readOnlyDatabase(true) then
ebean will:
- Set the DataSourceBuilder to use autoCommit=true and readOnly=true
- Use the same DataSource instance for both dataSource and readOnlyDataSource

This is to simplify the setup/configuration for creating a Database that
will only have read-only use.

Note that readOnly=true is a JDBC hint and for example H2 database effectively
ignores that hint where as Postgres will enforce the read-only true nature.
2023-11-13 23:12:05 +13:00
Rob Bygrave 5d54a238bd Bump ebean-agent to 13.25.0 2023-11-06 20:09:35 +13:00
Rob Bygrave b50ce5fc3f Version 13.25.0 2023-11-06 20:08:00 +13:00
Rob Bygrave 624e92840c Adjust "for testing purposes" log messages 2023-11-06 12:55:22 +13:00
Rob Bygrave b03adc412c Adjust "for testing purposes" log messages 2023-11-06 12:52:35 +13:00
Rob BygraveandGitHub e794f5e916 Merge pull request #3264 from ebean-orm/feature/DatabaseBuilder_Settings
Fix to return DataSourceBuilder.Settings for getDataSourceConfig() an…
2023-11-06 12:50:37 +13:00
Rob Bygrave a2551ce718 Bump ebean-datasource to 8.9 2023-11-06 12:50:14 +13:00
Rob Bygrave 5b0a3607f6 Fix to return DataSourceBuilder.Settings for getDataSourceConfig() and getReadOnlyDataSourceConfig()
That is, existing code using DataSourceConfig has access to the getter
methods of DataSourceConfig. The DataSourceBuilder interface only has
the setter methods and DataSourceBuilder.Settings has both getters and
setter methods.

That is, the refactor to extract the DataSourceBuilder interface also
split off the getter methods to the DataSourceBuilder.Settings interface
(because most of the time when using the builder we only need the
setter methods and effectively hiding the getter methods behind the settings()
is useful to simplify the API for users).
2023-11-06 12:14:27 +13:00
Rob Bygrave bcf7bd17be Version 13.14.0-jakarta 2023-11-05 22:21:20 +13:00
Rob BygraveandGitHub 102d8d5979 Merge pull request #3263 from ebean-orm/feature/DatabaseBuilder-take-2
DatabaseBuilder take 2
2023-11-05 22:11:26 +13:00
Rob Bygrave 3edc232003 Update test BeanDescriptor_registerTest with DatabaseBuilder use 2023-11-05 22:03:25 +13:00
Rob Bygrave 043dc5c51f Add setters without the set prefix to DatabaseBuilder with deprecation
So add `name(String name)` as preferred to `setName(String name)` etc
2023-11-05 22:01:02 +13:00
Rob Bygrave e2d666df35 Use fluid setters for DatabaseConfig and DatabaseBuilder 2023-11-04 13:05:22 +13:00
Rob Bygrave 314e0a14b8 Move the internal serviceObjectKey() methods back into DatabaseConfig
They were incorrectly extracted to the interface as default methods
2023-11-03 23:00:29 +13:00
Rob Bygrave 1f9cf1e4b7 Split DatabaseBuilder interface separating the setters n getters adding DatabaseBuilder.Settings
So DatabaseBuilder.Settings has all the getters for code looking to read
the configuration that has been set. So DatabaseBuilder now just has the
setter methods.

Use DatabaseBuilder.settings() to access the settings and read the config
that has been set.
2023-11-03 22:58:11 +13:00
Rob Bygrave 12029ed06e Refactor extract interface DatabaseBuilder from DatabaseConfig
First step in supporting the builder pattern for creating Database
2023-11-03 21:17:55 +13:00
Rob BygraveandGitHub 89741b9312 Merge pull request #3262 from ebean-orm/feature/improve-javadoc-deprecated
Improve the javadoc for deprecated methods (to assist IDE quick-fix actions)
2023-11-03 20:05:41 +13:00
Rob Bygrave ae962c2e08 Improve the javadoc for deprecated methods (to assist IDE quick-fix actions) 2023-11-03 20:04:25 +13:00
Rob BygraveandGitHub 4e3501972a Merge pull request #3260 from ebean-orm/feature/bump-migration2
Bump ebean-migration to 13.11.1 (with fastMode option and index file support)
2023-11-03 19:52:00 +13:00
Rob Bygrave a65ba41850 Bump ebean-migration to 13.11.1 (with fastMode option and index file support) 2023-11-03 18:33:02 +13:00
Rob Bygrave 3b11c1cb6b Merge branch 'master' of github.com:ebean-orm/ebean 2023-11-03 18:31:31 +13:00
Rob Bygrave 41185eeb5c Bump ebean-datasource to 8.8 with DataSourceBuilder
First step in migrating the ebean-datasource API to use builder pattern.
DataSourceConfig (concrete type) migrating to DataSourceBuilder (interface).

A followup step will deprecate the use of DataSourceConfig.
2023-11-03 18:31:11 +13:00
Rob BygraveandGitHub e97ff54ab2 Merge pull request #3259 from ebean-orm/feature/loadMode_safer
Change loadMode to be 'safer' (for Grafana etc). e.g. change "(+lazy) " to "__lazy"
2023-11-02 09:00:38 +13:00
robin.bygrave 97fae09c52 Tidy SpiQuery.setProfilePath() internal implementation 2023-11-01 15:48:27 +13:00
robin.bygrave 8b0f58b3c2 Change loadMode to be 'safer' (for Grafana etc). e.g. change "(+lazy)" to "__lazy"
The loadMode ends up as a suffix to some query metrics.

For example "foo.findIt_baz(+lazy)", and the (+lazy) part isn't safe/friendly to tools
like Grafana. So change to instead of (+lazy) use __lazy.
2023-11-01 15:20:18 +13:00
Rob Bygrave 70eb557929 Version 13.23.2-jakarta 2023-10-27 22:13:05 +13:00
Rob Bygrave fdb3a3759b Bump ebean-agent to 13.23.2 2023-10-27 22:10:40 +13:00
Rob BygraveandGitHub 7a5e8d0e17 Merge pull request #3256 from ebean-orm/feature/upgrade-antlr4-4_13_1
Upgrade ANTLR4 from version 4.8-1 to 4.13.1
2023-10-27 21:45:37 +13:00
robin.bygrave a0748f8139 Upgrade ANTLR4 from version 4.8-1 to 4.13.1 2023-10-26 13:52:44 +13:00
Rob BygraveandGitHub 9f65673f54 Merge pull request #3255 from ebean-orm/feature/bump-junit-bytebuddy
Bump io.avaje:junit and bytebuddy version to support JDK 22+
2023-10-25 22:12:49 +13:00
Rob Bygrave 8f6a3c59d1 Bump io.avaje:junit and bytebuddy version to support JDK 22+ 2023-10-25 21:58:19 +13:00
Rob BygraveandGitHub 05210ec411 Merge pull request #3254 from ebean-orm/feature/query-plan-capture-yuga
Use DIST with query plan capture for Yugabyte plus simplify
2023-10-25 08:23:01 +13:00
Rob Bygrave faffda8318 Use DIST with query plan capture for Yugabyte plus simplify
Change QueryPlanLoggerExplain to take the options for PG, Yugabyte and others
2023-10-25 08:22:25 +13:00
Rob BygraveandGitHub af3901ce01 Merge pull request #3253 from ebean-orm/feature/3251
#3251 - QueryBeans: Entities can not have same name as some Ebean API…
2023-10-25 08:11:40 +13:00
Rob Bygrave acd538207f #3251 - QueryBeans: Entities can not have same name as some Ebean API classes 2023-10-24 23:08:30 +13:00
Rob Bygrave 84f0ef9fce Use querybean-generator via provided scope rather than maven compiler plugin
This is because when releasing both jakarta and javax versions these
need to have their versions adjusted
2023-10-24 23:07:14 +13:00
Rob BygraveandGitHub 7ab447b21c Merge pull request #3252 from ebean-orm/feature/querybean-generator-provided
Use querybean-generator via provided scope rather than maven compiler plugin
2023-10-24 22:23:56 +13:00
Rob Bygrave 6f8805a6b3 Use querybean-generator via provided scope rather than maven compiler plugin
This is because when releasing both jakarta and javax versions these
need to have their versions adjusted
2023-10-24 22:17:28 +13:00
Rob Bygrave 0171c1afef Version 13.23.1 2023-10-18 15:47:04 +13:00
Rob Bygrave 31c106f604 Bump ebean-agent to 13.23.1 2023-10-18 15:16:20 +13:00
Rob BygraveandGitHub 20d2838be4 Merge pull request #3250 from ebean-orm/feature/bump-parent
Make Jackson a transitive dependency of ebean-jackson-mapper
2023-10-17 23:25:43 +13:00
Rob Bygrave 4238a951ca Make Jackson a transitive dependency of ebean-jackson-mapper
So jackson-core and jackson-databind are both transitive dependencies
of ebean-jackson-mapper.
2023-10-17 23:25:09 +13:00
Rob BygraveandGitHub b5d4bed615 Merge pull request #3249 from ebean-orm/feature/bump-parent
Support native-image via querybean-generator
2023-10-17 23:18:17 +13:00
Rob Bygrave 3ef715ef64 Support native-image via querybean-generator 2023-10-17 23:09:18 +13:00
Rob BygraveandGitHub aea39528ab Merge pull request #3248 from ebean-orm/feature/bump-parent
Bump dependency for avaje-config to 3.9
2023-10-17 22:39:04 +13:00
Rob Bygrave dd498409e0 Bump dependency for avaje-config to 3.9 2023-10-17 22:38:33 +13:00
Rob BygraveandGitHub bae33101df Merge pull request #3247 from ebean-orm/feature/bump-parent
Bump parent pom
2023-10-17 22:37:53 +13:00
Rob Bygrave e1972ac544 Bump parent pom 2023-10-17 22:37:20 +13:00
Rob Bygrave c7241ba3dc Fix test for java 16+ annotation processor version 2023-10-16 23:30:45 +13:00
Rob Bygrave 73416ed65a For testing java 16+ include JDK 17 and 21 only 2023-10-16 23:19:48 +13:00
Rob Bygrave cd70c178f1 For testing java 16+ include JDK 17 and 21 only 2023-10-16 23:17:25 +13:00
Rob Bygrave aa298235f3 For testing java 16+ include JDK 21 and 22 2023-10-16 23:15:32 +13:00
Rob BygraveandGitHub 8733fed14b Merge pull request #3246 from ebean-orm/feature/annotation-processing-jdk-22
Explicit annotation processors required with JDK 22
2023-10-16 22:06:20 +13:00
Rob Bygrave 169d170247 Explicit annotation processors required with JDK 22
JDK 22 changes such that annotation processors are not found by default on
the classpath. As such they either need to be explicitly registered with
the compiler (e.g. maven-compiler-plugin) or use -proc:full
2023-10-16 21:54:32 +13:00
Rob Bygrave d0ee42e0de Include <compilerArgument>-proc:full</compilerArgument> for JDK 22 EA build 2023-10-16 20:32:41 +13:00
Rob BygraveandGitHub 91ecc074a7 Merge pull request #3243 from ebean-orm/feature/postgis-dependency
Fix ebean-bom dependencies for ebean-test
2023-10-11 20:04:12 +13:00
Rob Bygrave c2b381af1e Fix ebean-bom dependencies for ebean-test
Fix by removing the scopes test and provided in the ebean-bom
2023-10-11 20:03:12 +13:00
Rob BygraveandGitHub eeb0a15617 Merge pull request #3242 from ebean-orm/feature/postgis-dependency
Add missing dependency for ebean-postgis-types to ebean-postgis
2023-10-11 19:59:48 +13:00
Rob Bygrave 6abed0dd73 Add missing dependency for ebean-postgis-types to ebean-postgis 2023-10-11 19:58:12 +13:00
Rob BygraveandGitHub 1318cd706f Merge pull request #3241 from ebean-orm/feature/StdOperators-dep
Remove the Deprecated(experimental) from StdOperators
2023-10-10 23:43:29 +13:00
Rob Bygrave 1e8c609dec Remove the Deprecated(experimental) from StdOperators 2023-10-10 23:42:47 +13:00
Rob Bygrave 4506596379 Tidy remove old stylesheet.css from source 2023-10-10 23:41:42 +13:00
375 changed files with 9179 additions and 4007 deletions
+4 -1
View File
@@ -1,7 +1,10 @@
name: Build
on: [push, pull_request]
on:
pull_request:
push:
branches: master
jobs:
build:
+2
View File
@@ -34,6 +34,8 @@ jobs:
path:
~/.m2
key: build-${{ env.cache-name }}
- name: Maven version
run: mvn --version
- name: Build with Maven
run: mvn package
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-clickhouse</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-db2</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-h2</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-hana</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-mariadb</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-mysql</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-nuodb</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-oracle</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+12 -6
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -14,7 +14,7 @@
<properties>
<postgis.jdbc.version>2.5.1</postgis.jdbc.version>
<postgres.jdbc.version>42.6.0</postgres.jdbc.version>
<postgres.jdbc.version>42.7.2</postgres.jdbc.version>
</properties>
<dependencies>
@@ -22,13 +22,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -47,13 +47,19 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgis-types</artifactId>
<version>14.0.2</version>
</dependency>
<dependency>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-sqlite</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-sqlserver</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+8 -8
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,31 +17,31 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-joda-time</artifactId>
<version>13.18.0</version>
<version>14.0.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-jackson-jsonnode</artifactId>
<version>13.18.0</version>
<version>14.0.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-jackson-mapper</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -60,13 +60,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-all</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+1 -1
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</parent>
<artifactId>composites</artifactId>
+2 -9
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</parent>
<name>ebean api</name>
@@ -39,7 +39,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-config</artifactId>
<version>3.8</version>
<version>3.12</version>
</dependency>
<dependency>
@@ -107,13 +107,6 @@
</dependency>
<!-- JAKARTA-DEPENDENCY-END -->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
-49
View File
@@ -266,55 +266,6 @@ public final class DB {
getDefault().register(transactionCallback);
}
/**
* Deprecated for removal migrate using try-with-resources and commit on the transaction itself.
* <p>
* Commit the current transaction.
*/
@Deprecated(forRemoval = true)
public static void commitTransaction() {
getDefault().commitTransaction();
}
/**
* Deprecated for removal migrate to using try-with-resources and rollback on the transaction itself.
* <p>
* Rollback the current transaction.
*/
@Deprecated(forRemoval = true)
public static void rollbackTransaction() {
getDefault().rollbackTransaction();
}
/**
* If the current transaction has already been committed do nothing otherwise
* rollback the transaction.
* <p>
* It is preferable to use <em>try with resources</em> rather than this.
* <p>
* Useful to put in a finally block to ensure the transaction is ended, rather
* than a rollbackTransaction() in each catch block.
* <p>
* Code example:
*
* <pre>{@code
* DB.beginTransaction();
* try {
* // do some fetching and or persisting
*
* // commit at the end
* DB.commitTransaction();
*
* } finally {
* // if commit didn't occur then rollback the transaction
* DB.endTransaction();
* }
* }</pre>
*/
public static void endTransaction() {
getDefault().endTransaction();
}
/**
* Mark the current transaction as rollback only.
*/
@@ -0,0 +1,104 @@
package io.ebean;
final class DInsertOptionsBuilder implements InsertOptions.Builder {
private Boolean getGeneratedKeys;
private boolean onConflictUpdate;
private boolean onConflictNothing;
private String constraint;
private String uniqueColumns;
private String updateSet;
@Override
public InsertOptions.Builder onConflictNothing() {
this.onConflictNothing = true;
return this;
}
@Override
public InsertOptions.Builder onConflictUpdate() {
this.onConflictUpdate = true;
return this;
}
@Override
public InsertOptions.Builder constraint(String constraint) {
this.constraint = constraint;
return this;
}
@Override
public InsertOptions.Builder uniqueColumns(String uniqueColumns) {
this.uniqueColumns = uniqueColumns;
return this;
}
@Override
public InsertOptions.Builder updateSet(String updateSet) {
this.updateSet = updateSet;
return this;
}
@Override
public InsertOptions.Builder getGeneratedKeys(boolean getGeneratedKeys) {
this.getGeneratedKeys = getGeneratedKeys;
return this;
}
@Override
public InsertOptions build() {
return new Options(constraint, uniqueColumns, updateSet, onConflictUpdate, onConflictNothing, getGeneratedKeys);
}
static final class Options implements InsertOptions {
private static final String UPDATE = "U";
private static final String NOTHING = "N";
private static final String NORMAL = "_";
private final String key;
private final Boolean getGeneratedKeys;
private final String constraint;
private final String uniqueColumns;
private final String updateSet;
Options(String constraint, String uniqueColumns, String updateSet, boolean onConflictUpdate, boolean onConflictNothing, Boolean getGeneratedKeys) {
this.constraint = constraint;
this.uniqueColumns = uniqueColumns;
this.updateSet = updateSet;
this.getGeneratedKeys = getGeneratedKeys;
this.key = (onConflictUpdate ? UPDATE : onConflictNothing ? NOTHING : NORMAL)
+ '+' + plus(constraint)
+ '+' + plus(uniqueColumns)
+ '+' + plus(updateSet);
}
private String plus(String val) {
return val == null ? "" : val;
}
@Override
public String key() {
return key;
}
@Override
public String constraint() {
return constraint;
}
@Override
public String uniqueColumns() {
return uniqueColumns;
}
@Override
public String updateSet() {
return updateSet;
}
@Override
public Boolean getGetGeneratedKeys() {
return getGeneratedKeys;
}
}
}
@@ -3,7 +3,7 @@ package io.ebean;
import jakarta.persistence.PersistenceException;
/**
* Thrown when a foreign key constraint is enforced.
* Thrown when a foreign key constraint is enforced or a field is too large.
*/
public class DataIntegrityException extends PersistenceException {
private static final long serialVersionUID = -6740171949170180970L;
@@ -14,4 +14,11 @@ public class DataIntegrityException extends PersistenceException {
public DataIntegrityException(String message, Throwable cause) {
super(message, cause);
}
/**
* Create with message only.
*/
public DataIntegrityException(String message) {
super(message);
}
}
+49 -44
View File
@@ -42,7 +42,7 @@ import java.util.concurrent.Callable;
* <h5>Constructing a Database</h5>
* <p>
* Databases are constructed by the DatabaseFactory. They can be created
* programmatically via {@link DatabaseFactory#create(DatabaseConfig)} or they
* programmatically via {@link DatabaseFactory#create(DatabaseBuilder)} or they
* can be automatically constructed on demand using configuration information in
* the application.properties file.
*
@@ -86,6 +86,23 @@ import java.util.concurrent.Callable;
@NonNullApi
public interface Database {
/**
* Return a new database builder.
* <pre>{@code
*
* // build the 'default' database using configuration
* // from application.properties / application.yaml
*
* Database db = Database.builder()
* .loadFromProperties()
* .build();
*
* }</pre>
*/
static DatabaseBuilder builder() {
return new DatabaseConfig();
}
/**
* Shutdown the Database instance.
*/
@@ -649,49 +666,6 @@ public interface Database {
*/
void flush();
/**
* Deprecated for removal migrate using try-with-resources and commit on the transaction itself.
* <p>
* Commit the current transaction.
*/
@Deprecated(forRemoval = true)
void commitTransaction();
/**
* Deprecated for removal migrate to using try-with-resources and rollback on the transaction itself.
* <p>
* Rollback the current transaction.
*/
@Deprecated(forRemoval = true)
void rollbackTransaction();
/**
* If the current transaction has already been committed do nothing otherwise
* rollback the transaction.
* <p>
* Useful to put in a finally block to ensure the transaction is ended, rather
* than a rollbackTransaction() in each catch block.
* <p>
* Code example:
* <p>
* <pre>{@code
*
* database.beginTransaction();
* try {
* // do some fetching and or persisting ...
*
* // commit at the end
* database.commitTransaction();
*
* } finally {
* // if commit didn't occur then rollback the transaction
* database.endTransaction();
* }
*
* }</pre>
*/
void endTransaction();
/**
* Refresh the values of a bean.
* <p>
@@ -1210,22 +1184,53 @@ public interface Database {
*/
void insert(Object bean);
/**
* Insert the bean with options (ON CONFLICT DO UPDATE | DO NOTHING).
* <p>
* Currently, this is limited to use with Postgres only,
* <p>
* When using this ebean will look to determine the unique columns by looking at
* the mapping like {@code @Column(unique=true} and {@code @Index(unique=true}.
*/
void insert(Object bean, InsertOptions insertOptions);
/**
* Insert the bean with a transaction.
*/
void insert(Object bean, Transaction transaction);
/**
* Insert the beans with options (ON CONFLICT DO UPDATE | DO NOTHING) and transaction.
* <p>
* Currently, this is limited to use with Postgres only,
*/
void insert(Object bean, InsertOptions insertOptions, Transaction transaction);
/**
* Insert a collection of beans. If there is no current transaction one is created and used to
* insert all the beans in the collection.
*/
void insertAll(Collection<?> beans);
/**
* Insert the beans with options - typically ON CONFLICT DO UPDATE | DO NOTHING.
* <p>
* Currently, this is limited to use with Postgres only,
*/
void insertAll(Collection<?> beans, InsertOptions options);
/**
* Insert a collection of beans with an explicit transaction.
*/
void insertAll(Collection<?> beans, Transaction transaction);
/**
* Insert the beans with options (ON CONFLICT DO UPDATE | DO NOTHING) and transaction.
* <p>
* Currently, this is limited to use with Postgres only,
*/
void insertAll(Collection<?> beans, InsertOptions options, Transaction transaction);
/**
* Execute explicitly passing a transaction.
*/
File diff suppressed because it is too large Load Diff
@@ -1,13 +1,11 @@
package io.ebean;
import io.ebean.config.ContainerConfig;
import io.ebean.config.DatabaseConfig;
import io.ebean.service.SpiContainer;
import io.ebean.service.SpiContainerFactory;
import jakarta.persistence.PersistenceException;
import java.util.Iterator;
import java.util.Properties;
import java.util.ServiceLoader;
import java.util.concurrent.locks.ReentrantLock;
@@ -76,9 +74,10 @@ public final class DatabaseFactory {
*
* }</pre>
*/
public static Database create(DatabaseConfig config) {
public static Database create(DatabaseBuilder builder) {
lock.lock();
try {
var config = builder.settings();
if (config.getName() == null) {
throw new PersistenceException("The name is null (it is required)");
}
@@ -102,7 +101,7 @@ public final class DatabaseFactory {
/**
* Create using the DatabaseConfig additionally specifying a classLoader to use as the context class loader.
*/
public static Database createWithContextClassLoader(DatabaseConfig config, ClassLoader classLoader) {
public static Database createWithContextClassLoader(DatabaseBuilder config, ClassLoader classLoader) {
lock.lock();
try {
ClassLoader currentContextLoader = Thread.currentThread().getContextClassLoader();
@@ -132,7 +131,7 @@ public final class DatabaseFactory {
}
}
private static Database createInternal(DatabaseConfig config) {
private static Database createInternal(DatabaseBuilder.Settings config) {
return container(config.getContainerConfig()).createServer(config);
}
@@ -146,12 +145,9 @@ public final class DatabaseFactory {
if (container != null) {
return container;
}
if (containerConfig == null) {
// effectively load configuration from ebean.properties
Properties properties = DbPrimary.getProperties();
containerConfig = new ContainerConfig();
containerConfig.loadFromProperties(properties);
}
container = createContainer(containerConfig);
return container;
@@ -160,7 +156,7 @@ public final class DatabaseFactory {
/**
* Create the container instance using the configuration.
*/
protected static SpiContainer createContainer(ContainerConfig containerConfig) {
private static SpiContainer createContainer(ContainerConfig containerConfig) {
Iterator<SpiContainerFactory> factories = ServiceLoader.load(SpiContainerFactory.class).iterator();
if (factories.hasNext()) {
return factories.next().create(containerConfig);
@@ -44,25 +44,12 @@ final class DbPrimary {
* Return the default database name.
*/
static String getDefaultServerName() {
lock.lock();
try {
getProperties();
return defaultServerName;
} finally {
lock.unlock();
}
}
/**
* Return the default configuration Properties.
*/
static Properties getProperties() {
lock.lock();
try {
if (defaultServerName == null) {
defaultServerName = determineDefaultServerName();
}
return Config.asProperties();
return defaultServerName;
} finally {
lock.unlock();
}
@@ -3,6 +3,8 @@ package io.ebean;
import io.avaje.lang.NonNullApi;
import io.avaje.lang.Nullable;
import javax.sql.DataSource;
import java.sql.Connection;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
@@ -206,14 +208,19 @@ public interface DtoQuery<T> extends CancelableQuery {
*/
DtoQuery<T> usingTransaction(Transaction transaction);
/**
* Execute the query using the given connection.
*/
DtoQuery<T> usingConnection(Connection connection);
/**
* Ensure that the master DataSource is used if there is a read only data source
* being used (that is using a read replica database potentially with replication lag).
* <p>
* When the database is configured with a read-only DataSource via
* say {@link io.ebean.config.DatabaseConfig#setReadOnlyDataSource(DataSource)} then
* say {@link io.ebean.DatabaseBuilder#readOnlyDataSource(DataSource)} then
* by default when a query is run without an active transaction, it uses the read-only data
* source. We we use {@code usingMaster()} to instead ensure that the query is executed
* source. We use {@code usingMaster()} to instead ensure that the query is executed
* against the master data source.
*/
DtoQuery<T> usingMaster();
@@ -54,7 +54,7 @@ public interface ExpressionList<T> {
Query<T> orderById(boolean orderById);
/**
* Deprecated migrate to {@link #orderBy(String)}
* @deprecated migrate to {@link #orderBy(String)}
*/
@Deprecated(since = "13.19", forRemoval = true)
default ExpressionList<T> order(String orderByClause) {
@@ -72,7 +72,7 @@ public interface ExpressionList<T> {
ExpressionList<T> orderBy(String orderBy);
/**
* Deprecated migrate to orderBy().
* @deprecated migrate to {@link #orderBy()}.
*/
@Deprecated(forRemoval = true)
default OrderBy<T> order() {
@@ -508,7 +508,7 @@ public interface ExpressionList<T> {
ExpressionList<T> filterMany(String manyProperty);
/**
* Deprecated for removal - migrate to filterManyRaw()
* @deprecated for removal - migrate to {@link #filterManyRaw(String, String, Object...)}.
* <p>
* Add filter expressions to the many property.
*
@@ -0,0 +1,119 @@
package io.ebean;
import io.avaje.lang.Nullable;
/**
* Options to be used with insert such as ON CONFLICT DO UPDATE | NOTHING.
*/
public interface InsertOptions {
/**
* Use ON CONFLICT UPDATE with automatic determination of the unique columns to conflict on.
* <p>
* Uses mapping to determine the unique columns - {@code @Column(unique=true)} and {@code @Index(unique=true)} .
*/
InsertOptions ON_CONFLICT_UPDATE = InsertOptions.builder()
.onConflictUpdate()
.build();
/**
* Use ON CONFLICT DO NOTHING with automatic determination of the unique columns to conflict on.
* <p>
* Uses mapping to determine the unique columns - {@code @Column(unique=true)} and {@code @Index(unique=true)} .
*/
InsertOptions ON_CONFLICT_NOTHING = InsertOptions.builder()
.onConflictNothing()
.build();
/**
* Return a builder for InsertOptions.
*/
static Builder builder() {
return new DInsertOptionsBuilder();
}
/**
* Return the constraint name that is used for ON CONFLICT.
*/
@Nullable
String constraint();
/**
* Return the unique columns that is used for ON CONFLICT.
* <p>
* When not explicitly set will use mapping like {@code @Column(unique=true)} to determine the
* non-unique columns.
*/
@Nullable
String uniqueColumns();
/**
* Return the ON CONFLICT UPDATE SET clause.
* <p>
* When not set will use the non-unique columns.
*/
@Nullable
String updateSet();
/**
* Return if GetGeneratedKeys should be used to fetch the generated keys after insert.
*/
@Nullable
Boolean getGetGeneratedKeys();
/**
* Return the key for these build options.
*/
String key();
/**
* The builder for InsertOptions.
*/
interface Builder {
/**
* Use a ON CONFLICT UPDATE automatically determining the unique columns.
*/
Builder onConflictUpdate();
/**
* Use a ON CONFLICT DO NOTHING automatically determining the unique columns.
*/
Builder onConflictNothing();
/**
* Specify an explicit conflict constraint name.
* <p>
* When this is used then unique columns will not be used.
*/
Builder constraint(String constraint);
/**
* Specify the unique columns for the conflict target.
* <p>
* When not specified and constraint is also not specified then
* it will automatically determine the unique columns
* based on mapping like {@code @Column(unique=true)} and
* {@code @Index(unique=true)} .
*/
Builder uniqueColumns(String uniqueColumns);
/**
* Specify the ON CONFLICT DO UPDATE SET clause.
* <p>
* When not specified ebean will include all the non-unique columns.
*/
Builder updateSet(String updateSet);
/**
* Specify if GetGeneratedKeys should be used to return generated keys.
*/
Builder getGeneratedKeys(boolean getGeneratedKeys);
/**
* Build and return the insert options.
*/
InsertOptions build();
}
}
+32 -5
View File
@@ -702,9 +702,9 @@ public interface Query<T> extends CancelableQuery {
* being used (that is using a read replica database potentially with replication lag).
* <p>
* When the database is configured with a read-only DataSource via
* say {@link io.ebean.config.DatabaseConfig#setReadOnlyDataSource(DataSource)} then
* say {@link io.ebean.DatabaseBuilder#readOnlyDataSource(DataSource)} then
* by default when a query is run without an active transaction, it uses the read-only data
* source. We we use {@code usingMaster()} to instead ensure that the query is executed
* source. We use {@code usingMaster()} to instead ensure that the query is executed
* against the master data source.
*/
Query<T> usingMaster();
@@ -970,6 +970,25 @@ public interface Query<T> extends CancelableQuery {
@Nullable
<A> A findSingleAttribute();
/**
* Execute the query returning a single optional attribute value.
* <p>
* <h3>Example</h3>
* <pre>{@code
*
* Optional<String> maybeName =
* new QCustomer()
* .select(name)
* .id.eq(42)
* .status.eq(NEW)
* .findSingleAttributeOrEmpty();
*
* }</pre>
*
* @return an optional value for the selected property
*/
<A> Optional<A> findSingleAttributeOrEmpty();
/**
* Return true if this is countDistinct query.
*/
@@ -1396,7 +1415,7 @@ public interface Query<T> extends CancelableQuery {
Query<T> orderBy(String orderByClause);
/**
* Deprecated migrate to orderBy().
* @deprecated migrate to {@link #orderBy()}.
*/
@Deprecated(since = "13.19", forRemoval = true)
default Query<T> order(String orderByClause) {
@@ -1415,7 +1434,7 @@ public interface Query<T> extends CancelableQuery {
OrderBy<T> orderBy();
/**
* Deprecated migrate to orderBy().
* @deprecated migrate to {@link #orderBy()}.
*/
@Deprecated(since = "13.19", forRemoval = true)
default OrderBy<T> order() {
@@ -1428,7 +1447,7 @@ public interface Query<T> extends CancelableQuery {
Query<T> setOrderBy(OrderBy<T> orderBy);
/**
* Deprecated migrate to setOrderBy().
* @deprecated migrate to {@link #setOrderBy(OrderBy)}.
*/
@Deprecated(since = "13.19", forRemoval = true)
default Query<T> setOrder(OrderBy<T> orderBy) {
@@ -1582,6 +1601,14 @@ public interface Query<T> extends CancelableQuery {
*/
Query<T> setLabel(String label);
/**
* Set a SQL query hint.
* <p>
* This results in an inline comment that immediately follows
* after the select keyword in the form: {@code /*+ hint *\/ }
*/
Query<T> setHint(String hint);
/**
* Set to true if this query should execute against the doc store.
* <p>
@@ -3,7 +3,9 @@ package io.ebean;
import io.avaje.lang.NonNullApi;
import io.avaje.lang.Nullable;
import javax.sql.DataSource;
import java.io.Serializable;
import java.sql.Connection;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
@@ -45,14 +47,19 @@ public interface SqlQuery extends Serializable, CancelableQuery {
*/
SqlQuery usingTransaction(Transaction transaction);
/**
* Execute the query using the given connection.
*/
SqlQuery usingConnection(Connection connection);
/**
* Ensure that the master DataSource is used if there is a read only data source
* being used (that is using a read replica database potentially with replication lag).
* <p>
* When the database is configured with a read-only DataSource via
* say {@link io.ebean.config.DatabaseConfig#setReadOnlyDataSource(DataSource)} then
* say {@link io.ebean.DatabaseBuilder#readOnlyDataSource(DataSource)}then
* by default when a query is run without an active transaction, it uses the read-only data
* source. We we use {@code usingMaster()} to instead ensure that the query is executed
* source. We use {@code usingMaster()} to instead ensure that the query is executed
* against the master data source.
*/
SqlQuery usingMaster();
@@ -9,7 +9,6 @@ import java.util.Collection;
* <p>
* This is currently deemed to be experimental and subject to change.
*/
@Deprecated(since = "experimental")
public final class StdOperators {
// ---- Functions ---- //
@@ -1,6 +1,6 @@
package io.ebean.cache;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
/**
* Plugin that provides a ServerCacheNotify implementation.
@@ -12,5 +12,5 @@ public interface ServerCacheNotifyPlugin {
/**
* Create a ServerCacheNotify implementation given the server configuration.
*/
ServerCacheNotify create(DatabaseConfig config);
ServerCacheNotify create(DatabaseBuilder config);
}
@@ -1,7 +1,7 @@
package io.ebean.cache;
import io.ebean.BackgroundExecutor;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
/**
* The plugin interface that creates a ServerCacheFactory.
@@ -11,5 +11,5 @@ public interface ServerCachePlugin {
/**
* Create the ServerCacheFactory given the server config and background executor service.
*/
ServerCacheFactory create(DatabaseConfig config, BackgroundExecutor executor);
ServerCacheFactory create(DatabaseBuilder config, BackgroundExecutor executor);
}
@@ -1,5 +1,7 @@
package io.ebean.config;
import io.ebean.DatabaseBuilder;
/**
* Used to provide some automatic configuration early in the creation of a Database.
*/
@@ -8,11 +10,11 @@ public interface AutoConfigure {
/**
* Perform configuration for the DatabaseConfig prior to properties load.
*/
void preConfigure(DatabaseConfig config);
void preConfigure(DatabaseBuilder config);
/**
* Provide some configuration the DatabaseConfig prior to server creation but after properties have been applied.
*/
void postConfigure(DatabaseConfig config);
void postConfigure(DatabaseBuilder config);
}
@@ -15,7 +15,6 @@ public class ContainerConfig {
private String namespace;
private String podName;
private int port;
private Properties properties;
/**
@@ -123,5 +122,4 @@ public class ContainerConfig {
protected boolean getProperty(Properties properties, String key, boolean defaultValue) {
return "true".equalsIgnoreCase(properties.getProperty(key, Boolean.toString(defaultValue)));
}
}
File diff suppressed because it is too large Load Diff
@@ -1,5 +1,7 @@
package io.ebean.config;
import io.ebean.DatabaseBuilder;
/**
* Provides a ServiceLoader based mechanism to configure a DatabaseConfig.
* <p>
@@ -35,5 +37,5 @@ public interface DatabaseConfigProvider {
* Typically we explicitly register entity bean classes and thus avoid classpath scanning.
* </p>
*/
void apply(DatabaseConfig config);
void apply(DatabaseBuilder config);
}
@@ -0,0 +1,22 @@
package io.ebean.config;
/**
* Defines the length-check mode.
*
* @author Roland Praml, FOCONIS AG
*/
public enum LengthCheck {
/**
* By default, length checking is off. This means, strings/jsons and files are passed to the DB and the DB might or might not check the length.
* The DB has to check the data length. Note this is not possible for certain datatypes (e.g. clob without size)
*/
OFF,
/**
* When enabling length check, ebean validates strings/json strings and files before saving them to DB.
*/
ON,
/**
* Same as "ON", but take the UTF8-bytelength for validation. This may be useful, if you have an UTF8 based charset (default for DB2)
*/
UTF8
}
@@ -769,4 +769,15 @@ public class DatabasePlatform {
public boolean supportsNativeJavaTime() {
return supportsNativeJavaTime;
}
public String inlineSqlComment(String label) {
if (label == null) {
return "";
}
return "/* " + label + " */ ";
}
public String inlineSqlHint(String hint) {
return "/*+ " + hint + " */ ";
}
}
@@ -1,6 +1,6 @@
package io.ebean.event;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
/**
* Used to configure the server on startup.
@@ -13,6 +13,6 @@ public interface ServerConfigStartup {
/**
* On starting configure the DatabaseConfig.
*/
void onStart(DatabaseConfig config);
void onStart(DatabaseBuilder config);
}
@@ -8,6 +8,7 @@ import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
@@ -23,7 +24,7 @@ public final class ShutdownManager {
private static final System.Logger log = EbeanVersion.log;
private static final ReentrantLock lock = new ReentrantLock();
private static final List<Database> databases = new ArrayList<>();
private static final List<Database> databases = Collections.synchronizedList(new ArrayList<>());
private static final ShutdownHook shutdownHook = new ShutdownHook();
private static boolean stopping;
@@ -177,12 +178,7 @@ public final class ShutdownManager {
* Register an ebeanServer to be shutdown when the JVM is shutdown.
*/
public static void registerDatabase(Database server) {
lock.lock();
try {
databases.add(server);
} finally {
lock.unlock();
}
databases.add(server);
}
/**
@@ -192,12 +188,7 @@ public final class ShutdownManager {
* </p>
*/
public static void unregisterDatabase(Database server) {
lock.lock();
try {
databases.remove(server);
} finally {
lock.unlock();
}
databases.remove(server);
}
private static class ShutdownHook extends Thread {
@@ -3,7 +3,7 @@ package io.ebean.plugin;
import io.ebean.Database;
import io.ebean.bean.BeanLoader;
import io.ebean.bean.EntityBeanIntercept;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
import io.ebean.config.dbplatform.DatabasePlatform;
import java.util.List;
@@ -16,7 +16,7 @@ public interface SpiServer extends Database {
/**
* Return the DatabaseConfig.
*/
DatabaseConfig config();
DatabaseBuilder.Settings config();
/**
* Return the DatabasePlatform for this database.
@@ -1,7 +1,7 @@
package io.ebean.service;
import io.ebean.Database;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
/**
* Creates the Database implementations. This is used internally by the EbeanServerFactory and is not currently
@@ -14,7 +14,7 @@ public interface SpiContainer {
*
* @param configuration The configuration information for this database.
*/
Database createServer(DatabaseConfig configuration);
Database createServer(DatabaseBuilder configuration);
/**
* Create an EbeanServer just using the name.
@@ -1,91 +0,0 @@
/* Javadoc style sheet */
/* Define colors, fonts and other style attributes here to override the defaults */
/* Page background color */
body {
background-color: #FFFFFF;
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
}
pre.code {
padding: 1em;
margin-left: 2em;
border: 1px solid #ccc;
background-color: #eee;
}
/* Headings */
h1 {
font-size: 14pt
}
#overviewexamples h3 {
font-size: 10pt
}
/* Table colors */
.TableHeadingColor {
background: #CCCCFF
}
/* Dark mauve */
.TableSubHeadingColor {
background: #EEEEFF
}
/* Light mauve */
.TableRowColor {
background: #FFFFFF
}
/* White */
/* Font used in left-hand frame lists */
.FrameTitleFont {
font-size: 12pt;
font-family: Helvetica, Arial, sans-serif
}
.FrameHeadingFont {
font-size: 10pt;
font-family: Helvetica, Arial, sans-serif
}
.FrameItemFont {
font-size: 10pt;
font-family: Helvetica, Arial, sans-serif
}
/* Navigation bar fonts and colors */
.NavBarCell1 {
background-color: #EEEEFF;
}
/* Light mauve */
.NavBarCell1Rev {
background-color: #00008B;
}
/* Dark Blue */
.NavBarFont1 {
font-family: Arial, Helvetica, sans-serif;
color: #000000;
}
.NavBarFont1Rev {
font-family: Arial, Helvetica, sans-serif;
color: #FFFFFF;
}
.NavBarCell2 {
font-family: Arial, Helvetica, sans-serif;
background-color: #FFFFFF;
}
.NavBarCell3 {
font-family: Arial, Helvetica, sans-serif;
background-color: #FFFFFF;
}
@@ -22,6 +22,8 @@ public class JsonWriteOptions {
protected JsonConfig.Include include;
protected boolean includeLoadedImplicit = true;
protected Map<String, JsonWriteBeanVisitor<?>> visitorMap;
/**
@@ -73,6 +75,20 @@ public class JsonWriteOptions {
this.include = include;
}
/**
* Should loaded properties be included implicit, if no other fetch path is specified (default = true).
*/
public boolean isIncludeLoadedImplicit() {
return includeLoadedImplicit;
}
/**
* Set include loaded properties implicit (default = true).
*/
public void setIncludeLoadedImplicit(boolean includeLoadedImplicit) {
this.includeLoadedImplicit = includeLoadedImplicit;
}
/**
* Register a JsonWriteBeanVisitor for the root level.
*/
@@ -21,9 +21,4 @@ class DbPrimaryTest {
assertEquals("h2", DbPrimary.getDefaultServerName());
}
@Test
void testLoadProperties() {
Properties properties = DbPrimary.getProperties();
assertFalse(properties.isEmpty());
}
}
@@ -1,6 +1,7 @@
package io.ebean.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.ebean.DatabaseBuilder;
import io.ebean.annotation.MutationDetection;
import io.ebean.annotation.PersistBatch;
import io.ebean.config.dbplatform.IdType;
@@ -17,7 +18,7 @@ class DatabaseConfigTest {
@Test
void testLoadFromEbeanProperties() {
DatabaseConfig config = new DatabaseConfig();
var config = new DatabaseConfig().settings();
config.loadFromProperties();
assertEquals(PersistBatch.NONE, config.getPersistBatch());
@@ -32,7 +33,7 @@ class DatabaseConfigTest {
Properties props = new Properties();
props.setProperty("ddl.initSql", "${user.home}" + fileSeparator + "initSql");
DatabaseConfig config = new DatabaseConfig();
var config = new DatabaseConfig().settings();
config.loadFromProperties(props);
String ddlInitSql = config.getDdlInitSql();
@@ -41,7 +42,7 @@ class DatabaseConfigTest {
@Test
void testLoadWithProperties() {
DatabaseConfig config = new DatabaseConfig();
DatabaseBuilder config = new DatabaseConfig();
config.setPersistBatch(PersistBatch.NONE);
config.setPersistBatchOnCascade(PersistBatch.NONE);
config.setAutoReadOnlyDataSource(false);
@@ -73,6 +74,9 @@ class DatabaseConfigTest {
props.setProperty("forUpdateNoKey", "true");
props.setProperty("defaultServer", "false");
props.setProperty("skipDataSourceCheck", "true");
props.setProperty("readOnlyDatabase", "true");
props.setProperty("lengthCheck", "ON");
props.setProperty("includeLabelInSql", "true");
props.setProperty("queryPlan.enable", "true");
props.setProperty("queryPlan.thresholdMicros", "10000");
@@ -83,49 +87,56 @@ class DatabaseConfigTest {
config.loadFromProperties(props);
assertFalse(config.isDefaultServer());
assertTrue(config.isDisableL2Cache());
assertTrue(config.isNotifyL2CacheInForeground());
assertTrue(config.isDbOffline());
assertTrue(config.isAutoReadOnlyDataSource());
assertTrue(config.isAutoLoadModuleInfo());
assertTrue(config.isLoadModuleInfo());
assertTrue(config.skipDataSourceCheck());
var settings = config.settings();
assertFalse(settings.isDefaultServer());
assertTrue(settings.isDisableL2Cache());
assertTrue(settings.isNotifyL2CacheInForeground());
assertTrue(settings.isDbOffline());
assertTrue(settings.isAutoReadOnlyDataSource());
assertTrue(settings.isAutoLoadModuleInfo());
assertTrue(settings.isLoadModuleInfo());
assertTrue(settings.skipDataSourceCheck());
assertTrue(settings.readOnlyDatabase());
assertTrue(settings.isIncludeLabelInSql());
assertThat(settings.getLengthCheck()).isEqualTo(LengthCheck.ON);
assertTrue(config.isIdGeneratorAutomatic());
assertFalse(config.getPlatformConfig().isCaseSensitiveCollation());
assertTrue(config.getPlatformConfig().isForUpdateNoKey());
assertTrue(settings.isIdGeneratorAutomatic());
assertFalse(settings.getPlatformConfig().isCaseSensitiveCollation());
assertTrue(settings.getPlatformConfig().isForUpdateNoKey());
assertThat(config.getNamingConvention()).isInstanceOf(MatchingNamingConvention.class);
assertThat(settings.getNamingConvention()).isInstanceOf(MatchingNamingConvention.class);
assertEquals(MutationDetection.NONE, config.getJsonMutationDetection());
assertEquals(MutationDetection.NONE, settings.getJsonMutationDetection());
config.setJsonMutationDetection(MutationDetection.SOURCE);
assertEquals(MutationDetection.SOURCE, config.getJsonMutationDetection());
assertEquals(IdType.SEQUENCE, config.getIdType());
assertEquals(PersistBatch.ALL, config.getPersistBatch());
assertEquals(PersistBatch.ALL, config.getPersistBatchOnCascade());
Assertions.assertEquals(PlatformConfig.DbUuid.BINARY, config.getPlatformConfig().getDbUuid());
Assertions.assertEquals(JsonConfig.DateTime.MILLIS, config.getJsonDateTime());
assertEquals(JsonConfig.Date.MILLIS, config.getJsonDate());
assertEquals(MutationDetection.SOURCE, settings.getJsonMutationDetection());
assertEquals(IdType.SEQUENCE, settings.getIdType());
assertEquals(PersistBatch.ALL, settings.getPersistBatch());
assertEquals(PersistBatch.ALL, settings.getPersistBatchOnCascade());
Assertions.assertEquals(PlatformConfig.DbUuid.BINARY, settings.getPlatformConfig().getDbUuid());
Assertions.assertEquals(JsonConfig.DateTime.MILLIS, settings.getJsonDateTime());
assertEquals(JsonConfig.Date.MILLIS, settings.getJsonDate());
assertEquals("r0,users,orgs", config.getEnabledL2Regions());
assertEquals("r0,users,orgs", settings.getEnabledL2Regions());
assertEquals(42, config.getJdbcFetchSizeFindEach());
assertEquals(43, config.getJdbcFetchSizeFindList());
assertEquals(4, config.getBackgroundExecutorSchedulePoolSize());
assertEquals(98, config.getBackgroundExecutorShutdownSecs());
assertEquals(42, settings.getJdbcFetchSizeFindEach());
assertEquals(43, settings.getJdbcFetchSizeFindList());
assertEquals(4, settings.getBackgroundExecutorSchedulePoolSize());
assertEquals(98, settings.getBackgroundExecutorShutdownSecs());
assertTrue(config.isQueryPlanEnable());
assertEquals(10000, config.getQueryPlanThresholdMicros());
assertTrue(config.isQueryPlanCapture());
assertEquals(42, config.getQueryPlanCapturePeriodSecs());
assertEquals(560, config.getQueryPlanCaptureMaxTimeMillis());
assertEquals(7, config.getQueryPlanCaptureMaxCount());
assertTrue(settings.isQueryPlanEnable());
assertEquals(10000, settings.getQueryPlanThresholdMicros());
assertTrue(settings.isQueryPlanCapture());
assertEquals(42, settings.getQueryPlanCapturePeriodSecs());
assertEquals(560, settings.getQueryPlanCaptureMaxTimeMillis());
assertEquals(7, settings.getQueryPlanCaptureMaxCount());
assertThat(config.getMappingLocations()).containsExactly("classpath:/foo","bar");
assertThat(settings.getMappingLocations()).containsExactly("classpath:/foo","bar");
config.persistBatch(PersistBatch.NONE)
.persistBatchOnCascade(PersistBatch.NONE)
.lengthCheck(LengthCheck.ON)
.lengthCheck(LengthCheck.UTF8);
config.setPersistBatch(PersistBatch.NONE);
config.setPersistBatchOnCascade(PersistBatch.NONE);
Properties props1 = new Properties();
props1.setProperty("ebean.persistBatch", "ALL");
@@ -137,19 +148,20 @@ class DatabaseConfigTest {
props1.setProperty("ebean.notifyL2CacheInForeground", "false");
config.loadFromProperties(props1);
assertFalse(config.isDisableL2Cache());
assertFalse(config.isNotifyL2CacheInForeground());
assertFalse(settings.isDisableL2Cache());
assertFalse(settings.isNotifyL2CacheInForeground());
assertEquals(PersistBatch.ALL, config.getPersistBatch());
assertEquals(PersistBatch.ALL, config.getPersistBatchOnCascade());
assertEquals(PersistBatch.ALL, settings.getPersistBatch());
assertEquals(PersistBatch.ALL, settings.getPersistBatchOnCascade());
assertEquals(LengthCheck.UTF8, settings.getLengthCheck());
config.setEnabledL2Regions("r0,orgs");
assertEquals("r0,orgs", config.getEnabledL2Regions());
assertEquals("r0,orgs", settings.getEnabledL2Regions());
}
@Test
void test_defaults() {
DatabaseConfig config = new DatabaseConfig();
DatabaseBuilder.Settings config = new DatabaseConfig().settings();
assertTrue(config.isIdGeneratorAutomatic());
assertTrue(config.isDefaultServer());
assertFalse(config.isAutoPersistUpdates());
@@ -170,6 +182,8 @@ class DatabaseConfigTest {
assertEquals(600, config.getQueryPlanCapturePeriodSecs());
assertEquals(10000L, config.getQueryPlanCaptureMaxTimeMillis());
assertEquals(10, config.getQueryPlanCaptureMaxCount());
assertThat(config.getLengthCheck()).isEqualTo(LengthCheck.OFF);
assertFalse(config.isIncludeLabelInSql());
config.setLoadModuleInfo(false);
assertFalse(config.isAutoLoadModuleInfo());
@@ -184,7 +198,7 @@ class DatabaseConfigTest {
void test_putServiceObject() {
ObjectMapper objectMapper = new ObjectMapper();
DatabaseConfig config = new DatabaseConfig();
var config = new DatabaseConfig().settings();
config.putServiceObject(objectMapper);
ObjectMapper mapper0 = config.getServiceObject(ObjectMapper.class);
+31 -34
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</parent>
<name>ebean bom</name>
@@ -89,106 +89,103 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-joda-time</artifactId>
<version>13.18.0</version>
<version>14.0.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-jackson-jsonnode</artifactId>
<version>13.18.0</version>
<version>14.0.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-jackson-mapper</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>13.18.0</version>
<version>14.0.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-xml</artifactId>
<version>13.18.0</version>
<version>14.0.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-autotune</artifactId>
<version>13.18.0</version>
<version>14.0.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>13.23.0-jakarta</version>
<scope>provided</scope>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>kotlin-querybean-generator</artifactId>
<version>13.23.0-jakarta</version>
<scope>provided</scope>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>13.23.0-jakarta</version>
<scope>test</scope>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-redis</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-spring-txn</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<!-- platforms -->
@@ -196,79 +193,79 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-clickhouse</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-db2</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-h2</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-hana</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-mariadb</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-mysql</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-nuodb</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-oracle</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgres</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgis</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgis-types</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-sqlite</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-sqlserver</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
</dependencies>
+3 -10
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</parent>
<artifactId>ebean-core-type</artifactId>
@@ -16,7 +16,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -30,17 +30,10 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.6.0</version>
<version>42.7.2</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@@ -174,4 +174,9 @@ public interface DataBinder {
*/
String popJson();
/**
* Returns the last bound object (e.g. for BindValidation). Note for InputStreams you'll get an InputStreamInfo.
*/
Object popLastObject();
}
@@ -1,6 +1,6 @@
package io.ebean.core.type;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
import java.util.List;
@@ -12,5 +12,5 @@ public interface ExtraTypeFactory {
/**
* Provide extra types to Ebean.
*/
List<? extends ScalarType<?>> createTypes(DatabaseConfig config, Object objectMapper);
List<? extends ScalarType<?>> createTypes(DatabaseBuilder.Settings config, Object objectMapper);
}
@@ -0,0 +1,27 @@
package io.ebean.core.type;
import java.io.InputStream;
/**
* Helper to transports length info of DataBind.setBinaryStream(stream, length) to BindValidation
*
* @author Roland Praml, FOCONIS AG
*/
public final class InputStreamInfo {
private final InputStream stream;
private final long length;
public InputStreamInfo(InputStream stream, long length) {
this.stream = stream;
this.length = length;
}
public InputStream stream() {
return stream;
}
public long length() {
return length;
}
}
@@ -1,7 +1,7 @@
package io.ebean.core.type;
import io.avaje.lang.Nullable;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
/**
* Factory to create ScalarTypeSet.
@@ -12,6 +12,6 @@ public interface ScalarTypeSetFactory {
* Create the ScalarTypeSet given the config and optional objectMapper.
*/
@Nullable
ScalarTypeSet<?> createTypeSet(DatabaseConfig config, @Nullable Object objectMapper);
ScalarTypeSet<?> createTypeSet(DatabaseBuilder.Settings config, @Nullable Object objectMapper);
}
+9 -16
View File
@@ -3,7 +3,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</parent>
<artifactId>ebean-core</artifactId>
@@ -22,7 +22,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
@@ -46,19 +46,19 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>13.18.0</version>
<version>14.0.0</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.8-1</version>
<version>4.13.1</version>
</dependency>
<!--
@@ -151,7 +151,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.6.0</version>
<version>42.7.2</version>
<optional>true</optional>
</dependency>
@@ -159,21 +159,21 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-h2</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-sqlserver</artifactId>
<version>13.23.0-jakarta</version>
<version>14.0.2</version>
<scope>test</scope>
</dependency>
@@ -184,13 +184,6 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@@ -1,6 +1,6 @@
package io.ebeaninternal.api;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
import io.ebeaninternal.server.type.GeoTypeBinder;
/**
@@ -11,5 +11,5 @@ public interface GeoTypeProvider {
/**
* Create a binder for binding geometry types.
*/
GeoTypeBinder createBinder(DatabaseConfig config);
GeoTypeBinder createBinder(DatabaseBuilder.Settings config);
}
@@ -111,7 +111,7 @@ public final class LoadBeanRequest extends LoadRequest {
}
private String mode() {
return lazy ? "+lazy" : loadBuffer.isCache() ? "+cache" : "+query";
return lazy ? "lazy" : loadBuffer.isCache() ? "cache" : "query";
}
/**
@@ -3,6 +3,7 @@ package io.ebeaninternal.api;
import io.ebean.CacheMode;
import io.ebean.bean.BeanCollection;
import io.ebean.bean.EntityBean;
import io.ebean.bean.PersistenceContext;
import io.ebeaninternal.server.core.BindPadding;
import io.ebeaninternal.server.core.OrmQueryRequest;
import io.ebeaninternal.server.deploy.BeanDescriptor;
@@ -57,17 +58,22 @@ public final class LoadManyRequest extends LoadRequest {
return loadContext.fullPath();
}
private List<Object> parentIdList(SpiEbeanServer server) {
List<Object> idList = new ArrayList<>();
BeanPropertyAssocMany<?> many = many();
private List<Object> parentIdList(SpiEbeanServer server, BeanPropertyAssocMany<?> many, PersistenceContext pc) {
final var idList = new ArrayList<>(loadContext.size());
final var descriptor = many.descriptor();
for (int i = 0; i < loadContext.size(); i++) {
BeanCollection<?> bc = loadContext.get(i);
final BeanCollection<?> bc = loadContext.get(i);
if (bc != null) {
if (lazy && !originIncluded && bc == originCollection) {
originIncluded = true;
}
idList.add(many.parentId(bc.owner()));
final var parent = bc.owner();
final var parentId = descriptor.getId(parent);
idList.add(parentId);
bc.setLoader(server); // don't use the load buffer again
if (lazy) {
descriptor.contextPutIfAbsent(pc, parentId, parent);
if (!originIncluded && bc == originCollection) {
originIncluded = true;
}
}
}
}
if (originCollection != null && !originIncluded) {
@@ -75,7 +81,7 @@ public final class LoadManyRequest extends LoadRequest {
idList.add(many.parentId(originCollection.owner()));
originCollection.setLoader(server); // don't use the load buffer again
}
if (many.targetDescriptor().isPadInExpression()) {
if (descriptor.isPadInExpression()) {
BindPadding.padIds(idList);
}
return idList;
@@ -99,9 +105,10 @@ public final class LoadManyRequest extends LoadRequest {
query.where().raw(extraWhere.replace("${ta}", "t0").replace("${mta}", "int_"));
}
query.setLazyLoadForParents(many);
many.addWhereParentIdIn(query, parentIdList(server), loadContext.isUseDocStore());
query.setPersistenceContext(loadContext.persistenceContext());
query.setLoadDescription(lazy ? "+lazy" : "+query", description());
final var pc = loadContext.persistenceContext();
many.addWhereParentIdIn(query, parentIdList(server, many, pc), loadContext.isUseDocStore());
query.setPersistenceContext(pc);
query.setLoadDescription(lazy ? "lazy" : "query", description());
if (lazy) {
query.setLazyLoadBatchSize(loadContext.batchSize());
} else {
@@ -3,6 +3,8 @@ package io.ebeaninternal.api;
import io.ebean.TxScope;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
* Used internally to handle the scoping of transactions for methods.
@@ -47,6 +49,11 @@ public final class ScopeTrans {
private boolean nestedCommit;
private boolean nestedUseSavepoint;
/**
* The UserObjects when using in nested transactions.
*/
private Map<String, Object> userObjects;
public ScopeTrans(boolean rollbackOnChecked, boolean created, SpiTransaction transaction, TxScope txScope) {
this.rollbackOnChecked = rollbackOnChecked;
this.created = created;
@@ -218,4 +225,17 @@ public final class ScopeTrans {
return e instanceof RuntimeException || rollbackOnChecked;
}
public void putUserObject(String name, Object value) {
if (userObjects == null) {
userObjects = new HashMap<>();
}
userObjects.put(name, value);
}
public Object getUserObject(String name) {
if (userObjects == null) {
return null;
}
return userObjects.get(name);
}
}
@@ -2,7 +2,6 @@ package io.ebeaninternal.api;
import io.ebeaninternal.server.transaction.TransactionScopeManager;
import io.ebeaninternal.server.util.ArrayStack;
import jakarta.persistence.PersistenceException;
/**
@@ -173,4 +172,31 @@ public final class ScopedTransaction extends SpiTransactionProxy {
return current.caughtThrowable(e);
}
/**
* New user objects are always written to the current ScopeTrans.
*/
@Override
public void putUserObject(String name, Object value) {
current.putUserObject(name, value);
}
/**
* Returns the userObject in the stack, Herew we search
* the stack and return the first found userObject
*/
@Override
public Object getUserObject(String name) {
Object obj = current.getUserObject(name);
if (obj != null) {
return obj;
}
for (ScopeTrans trans : stack) {
obj = trans.getUserObject(name);
if (obj != null) {
return obj;
}
}
return transaction.getUserObject(name);
}
}
@@ -86,6 +86,11 @@ public interface SpiEbeanServer extends SpiServer, ExtendedServer, BeanCollectio
*/
SpiTransactionManager transactionManager();
/**
* End the current transaction if it is active.
*/
void endTransaction();
/**
* Return all the descriptors.
*/
@@ -3,13 +3,14 @@ package io.ebeaninternal.api;
import io.ebeaninternal.server.core.SpiOrmQueryRequest;
import io.ebeaninternal.server.deploy.BeanDescriptor;
import io.ebeaninternal.server.expression.platform.DbExpressionHandler;
import io.ebeaninternal.server.expression.platform.DbExpressionRequest;
import java.util.List;
/**
* Request object used for gathering expression sql and bind values.
*/
public interface SpiExpressionRequest {
public interface SpiExpressionRequest extends DbExpressionRequest {
/**
* Return the DB specific handler for JSON and ARRAY expressions.
@@ -34,11 +35,13 @@ public interface SpiExpressionRequest {
/**
* Append to the expression sql without any parsing.
*/
@Override
SpiExpressionRequest append(String expression);
/**
* Append to the expression sql without any parsing.
*/
@Override
SpiExpressionRequest append(char c);
/**
@@ -47,6 +50,7 @@ public interface SpiExpressionRequest {
* This is a fast path case when expression is a bean property path and falls back to using parse()
* when that isn't the case.
*/
@Override
SpiExpressionRequest property(String expression);
/**
@@ -1,5 +1,6 @@
package io.ebeaninternal.api;
import io.avaje.lang.Nullable;
import io.ebean.CacheMode;
import io.ebean.CountDistinctOrder;
import io.ebean.ExpressionList;
@@ -225,6 +226,11 @@ public interface SpiQuery<T> extends Query<T>, SpiQueryFetch, TxnProfileEventCod
*/
ProfileLocation profileLocation();
/**
* Return the SQL hint to include in the query.
*/
String hint();
/**
* Return the label set on the query.
*/
@@ -339,7 +345,7 @@ public interface SpiQuery<T> extends Query<T>, SpiQueryFetch, TxnProfileEventCod
/**
* Set the on a secondary query given the label, relativePath and profile location of the parent query.
*/
void setProfilePath(String label, String relativePath, ProfileLocation profileLocation);
void setProfilePath(String label, String relativePath, @Nullable ProfileLocation profileLocation);
/**
* Set the query mode.
@@ -653,6 +659,16 @@ public interface SpiQuery<T> extends Query<T>, SpiQueryFetch, TxnProfileEventCod
*/
ObjectGraphNode parentNode();
/**
* Set that this is a future query that will execute in the background.
*/
void usingFuture();
/**
* Return true if this is a future query.
*/
boolean isUsingFuture();
/**
* Return false when this is a lazy load or refresh query for a bean.
* <p>
@@ -1,9 +1,9 @@
package io.ebeaninternal.server.autotune;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
import io.ebeaninternal.api.SpiEbeanServer;
public interface AutoTuneServiceProvider {
AutoTuneService create(SpiEbeanServer server, DatabaseConfig config);
AutoTuneService create(SpiEbeanServer server, DatabaseBuilder config);
}
@@ -1,10 +1,14 @@
package io.ebeaninternal.server.bind;
import io.ebean.core.type.DataBinder;
import io.ebean.core.type.InputStreamInfo;
import io.ebeaninternal.api.CoreLog;
import io.ebeaninternal.server.core.timezone.DataTimeZone;
import java.io.*;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.math.BigDecimal;
import java.sql.*;
import java.util.ArrayList;
@@ -23,6 +27,8 @@ public class DataBind implements DataBinder {
protected int pos;
private String json;
private Object lastObject = null;
public DataBind(DataTimeZone dataTimeZone, PreparedStatement pstmt, Connection connection) {
this.dataTimeZone = dataTimeZone;
this.pstmt = pstmt;
@@ -65,16 +71,19 @@ public class DataBind implements DataBinder {
@Override
public void setObject(Object value) throws SQLException {
pstmt.setObject(++pos, value);
lastObject = value;
}
@Override
public final void setObject(Object value, int sqlType) throws SQLException {
pstmt.setObject(++pos, value, sqlType);
lastObject = value;
}
@Override
public void setNull(int jdbcType) throws SQLException {
pstmt.setNull(++pos, jdbcType);
lastObject = null;
}
@Override
@@ -96,7 +105,7 @@ public class DataBind implements DataBinder {
}
}
private void closeInputStreams() {
public void closeInputStreams() {
if (inputStreams != null) {
for (InputStream inputStream : inputStreams) {
try {
@@ -117,36 +126,43 @@ public class DataBind implements DataBinder {
@Override
public void setString(String value) throws SQLException {
pstmt.setString(++pos, value);
lastObject = value;
}
@Override
public final void setInt(int value) throws SQLException {
pstmt.setInt(++pos, value);
lastObject = null;
}
@Override
public final void setLong(long value) throws SQLException {
pstmt.setLong(++pos, value);
lastObject = null;
}
@Override
public final void setShort(short value) throws SQLException {
pstmt.setShort(++pos, value);
lastObject = null;
}
@Override
public final void setFloat(float value) throws SQLException {
pstmt.setFloat(++pos, value);
lastObject = null;
}
@Override
public final void setDouble(double value) throws SQLException {
pstmt.setDouble(++pos, value);
lastObject = null;
}
@Override
public final void setBigDecimal(BigDecimal value) throws SQLException {
pstmt.setBigDecimal(++pos, value);
lastObject = null;
}
@Override
@@ -157,6 +173,7 @@ public class DataBind implements DataBinder {
} else {
pstmt.setDate(++pos, value);
}
lastObject = null;
}
@Override
@@ -167,6 +184,7 @@ public class DataBind implements DataBinder {
} else {
pstmt.setTimestamp(++pos, value);
}
lastObject = null;
}
@Override
@@ -177,26 +195,31 @@ public class DataBind implements DataBinder {
} else {
pstmt.setTime(++pos, value);
}
lastObject = null;
}
@Override
public void setBoolean(boolean value) throws SQLException {
pstmt.setBoolean(++pos, value);
lastObject = null;
}
@Override
public void setBytes(byte[] value) throws SQLException {
pstmt.setBytes(++pos, value);
lastObject = value;
}
@Override
public void setByte(byte value) throws SQLException {
pstmt.setByte(++pos, value);
lastObject = null;
}
@Override
public void setChar(char value) throws SQLException {
pstmt.setString(++pos, String.valueOf(value));
lastObject = null;
}
@Override
@@ -211,21 +234,31 @@ public class DataBind implements DataBinder {
}
inputStreams.add(inputStream);
pstmt.setBinaryStream(++pos, inputStream, length);
lastObject = new InputStreamInfo(inputStream, length);
}
@Override
public void setBlob(byte[] bytes) throws SQLException {
pstmt.setBinaryStream(++pos, new ByteArrayInputStream(bytes), bytes.length);
lastObject = bytes;
}
@Override
public void setClob(String content) throws SQLException {
pstmt.setCharacterStream(++pos, new StringReader(content), content.length());
lastObject = content;
}
@Override
public void setArray(String arrayType, Object[] elements) throws SQLException {
pstmt.setArray(++pos, connection.createArrayOf(arrayType, elements));
lastObject = null;
}
@Override
public Object popLastObject() {
Object ret = lastObject;
lastObject = null;
return ret;
}
}
@@ -4,7 +4,7 @@ import io.ebean.cache.QueryCacheEntryValidate;
import io.ebean.cache.ServerCacheFactory;
import io.ebean.cache.ServerCacheOptions;
import io.ebean.config.CurrentTenantProvider;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
import io.ebeaninternal.server.cluster.ClusterManager;
/**
@@ -13,7 +13,7 @@ import io.ebeaninternal.server.cluster.ClusterManager;
public final class CacheManagerOptions {
private final ClusterManager clusterManager;
private final DatabaseConfig databaseConfig;
private final DatabaseBuilder.Settings databaseBuilder;
private final boolean localL2Caching;
private CurrentTenantProvider currentTenantProvider;
private QueryCacheEntryValidate queryCacheEntryValidate;
@@ -24,15 +24,15 @@ public final class CacheManagerOptions {
CacheManagerOptions() {
this.localL2Caching = true;
this.clusterManager = null;
this.databaseConfig = null;
this.databaseBuilder = null;
this.cacheFactory = new DefaultServerCacheFactory();
this.beanDefault = new ServerCacheOptions();
this.queryDefault = new ServerCacheOptions();
}
public CacheManagerOptions(ClusterManager clusterManager, DatabaseConfig config, boolean localL2Caching) {
public CacheManagerOptions(ClusterManager clusterManager, DatabaseBuilder.Settings config, boolean localL2Caching) {
this.clusterManager = clusterManager;
this.databaseConfig = config;
this.databaseBuilder = config;
this.localL2Caching = localL2Caching;
this.currentTenantProvider = config.getCurrentTenantProvider();
}
@@ -55,7 +55,7 @@ public final class CacheManagerOptions {
}
public String getServerName() {
return (databaseConfig == null) ? "db" : databaseConfig.getName();
return (databaseBuilder == null) ? "db" : databaseBuilder.getName();
}
public boolean isLocalL2Caching() {
@@ -3,7 +3,7 @@ package io.ebeaninternal.server.cache;
import io.ebean.BackgroundExecutor;
import io.ebean.cache.ServerCacheFactory;
import io.ebean.cache.ServerCachePlugin;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
/**
* Default implementation of ServerCachePlugin.
@@ -14,7 +14,7 @@ public final class DefaultServerCachePlugin implements ServerCachePlugin {
* Creates the default ServerCacheFactory.
*/
@Override
public ServerCacheFactory create(DatabaseConfig config, BackgroundExecutor executor) {
public ServerCacheFactory create(DatabaseBuilder config, BackgroundExecutor executor) {
return new DefaultServerCacheFactory(executor);
}
}
@@ -5,7 +5,6 @@ import io.ebean.Database;
import io.ebean.config.ContainerConfig;
import io.ebeaninternal.server.transaction.RemoteTransactionEvent;
import java.util.Iterator;
import java.util.ServiceLoader;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
@@ -20,38 +19,22 @@ public class ClusterManager implements ServerLookup {
private static final System.Logger clusterLogger = AppLog.getLogger("io.ebean.Cluster");
private final ReentrantLock lock = new ReentrantLock();
private final ConcurrentHashMap<String, Database> serverMap = new ConcurrentHashMap<>();
private final Object monitor = new Object();
private final ClusterBroadcast broadcast;
private boolean started;
private boolean shutdown;
public ClusterManager(ContainerConfig config) {
ClusterBroadcastFactory factory = createFactory();
if (factory != null && config.isActive()) {
broadcast = factory.create(this, config);
if (config.isActive()) {
ClusterBroadcastFactory factory = createFactory();
broadcast = factory != null ? factory.create(this, config) : null;
} else {
broadcast = null;
}
}
/**
* Return the ClusterTransportFactory via ServiceLoader.
*/
private ClusterBroadcastFactory createFactory() {
ServiceLoader<ClusterBroadcastFactory> load = ServiceLoader.load(ClusterBroadcastFactory.class);
ClusterBroadcastFactory factory = null;
Iterator<ClusterBroadcastFactory> iterator = load.iterator();
if (iterator.hasNext()) {
factory = iterator.next();
}
return factory;
return ServiceLoader.load(ClusterBroadcastFactory.class).findFirst().orElse(null);
}
public void registerServer(Database server) {
@@ -2,7 +2,7 @@ package io.ebeaninternal.server.core;
import io.avaje.classpath.scanner.ClassPathScanner;
import io.avaje.classpath.scanner.ClassPathScannerFactory;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
import java.util.ArrayList;
import java.util.List;
@@ -16,7 +16,7 @@ public class ClassPathScanners {
/**
* Return the list of ClassPathScanner services using DatabaseConfig service loader.
*/
public static List<ClassPathScanner> find(DatabaseConfig config) {
public static List<ClassPathScanner> find(DatabaseBuilder.Settings config) {
List<ClassPathScanner> scanners = new ArrayList<>();
for (ClassPathScannerFactory factory : ServiceLoader.load(ClassPathScannerFactory.class)) {
scanners.add(factory.createScanner(config.getClassLoadConfig().getClassLoader()));
@@ -1,6 +1,6 @@
package io.ebeaninternal.server.core;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.config.dbplatform.DatabasePlatformProvider;
import io.ebeaninternal.api.CoreLog;
@@ -37,7 +37,7 @@ public class DatabasePlatformFactory {
/**
* Create the appropriate database specific platform.
*/
public DatabasePlatform create(DatabaseConfig config) {
public DatabasePlatform create(DatabaseBuilder.Settings config) {
try {
String offlinePlatform = DbOffline.getPlatform();
if (offlinePlatform != null) {
@@ -63,8 +63,8 @@ final class DefaultBeanLoader {
Object parentId = parentDesc.getId(parentBean);
if (pc == null) {
pc = new DefaultPersistenceContext();
parentDesc.contextPut(pc, parentId, parentBean);
}
parentDesc.contextPutIfAbsent(pc, parentId, parentBean);
boolean useManyIdCache = beanCollection != null && parentDesc.isManyPropCaching() && many.isUseCache();
if (useManyIdCache) {
Boolean readOnly = null;
@@ -82,9 +82,9 @@ final class DefaultBeanLoader {
// populate a new collection
BeanCollection<?> emptyCollection = many.createEmpty(parentBean);
many.setValue(parentBean, emptyCollection);
query.setLoadDescription("+refresh", null);
query.setLoadDescription("refresh", null);
} else {
query.setLoadDescription("+lazy", null);
query.setLoadDescription("lazy", null);
}
query.select(parentDesc.idBinder().idSelect());
@@ -1,5 +1,7 @@
package io.ebeaninternal.server.core;
import io.ebean.Database;
import io.ebean.DatabaseBuilder;
import io.ebean.config.*;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.event.ShutdownManager;
@@ -12,11 +14,13 @@ import io.ebeaninternal.server.cluster.ClusterManager;
import io.ebeaninternal.server.core.bootup.BootupClassPathSearch;
import io.ebeaninternal.server.core.bootup.BootupClasses;
import io.ebeaninternal.server.executor.DefaultBackgroundExecutor;
import jakarta.persistence.PersistenceException;
import java.net.URL;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
@@ -32,12 +36,22 @@ public final class DefaultContainer implements SpiContainer {
private final ReentrantLock lock = new ReentrantLock();
private final ClusterManager clusterManager;
private final List<EntityClassRegister> entityClassRegisters;
public DefaultContainer(ContainerConfig containerConfig) {
this.clusterManager = new ClusterManager(containerConfig);
// register so that we can shutdown any Ebean wide
// resources such as clustering
ShutdownManager.registerContainer(this);
entityClassRegisters = initEntityRegisters();
}
private List<EntityClassRegister> initEntityRegisters() {
var entityClassRegisters = new ArrayList<EntityClassRegister>();
for (EntityClassRegister entityClassRegister : ServiceLoader.load(EntityClassRegister.class)) {
entityClassRegisters.add(entityClassRegister);
}
return entityClassRegisters;
}
@Override
@@ -51,13 +65,12 @@ public final class DefaultContainer implements SpiContainer {
*/
@Override
public SpiEbeanServer createServer(String name) {
DatabaseConfig config = new DatabaseConfig();
config.setName(name);
config.loadFromProperties();
return createServer(config);
var builder = Database.builder().name(name).loadFromProperties();
return createServer(builder);
}
private SpiBackgroundExecutor createBackgroundExecutor(DatabaseConfig config) {
private SpiBackgroundExecutor createBackgroundExecutor(DatabaseBuilder builder) {
var config = builder.settings();
String namePrefix = "ebean-" + config.getName();
int schedulePoolSize = config.getBackgroundExecutorSchedulePoolSize();
int shutdownSecs = config.getBackgroundExecutorShutdownSecs();
@@ -69,9 +82,10 @@ public final class DefaultContainer implements SpiContainer {
* Create the implementation from the configuration.
*/
@Override
public SpiEbeanServer createServer(DatabaseConfig config) {
public SpiEbeanServer createServer(DatabaseBuilder builder) {
lock.lock();
try {
var config = builder.settings();
long start = System.currentTimeMillis();
applyConfigServices(config);
setNamingConvention(config);
@@ -79,7 +93,7 @@ public final class DefaultContainer implements SpiContainer {
boolean online = true;
if (config.isDocStoreOnly()) {
config.setDatabasePlatform(new DatabasePlatform());
config.databasePlatform(new DatabasePlatform());
} else {
TenantMode tenantMode = config.getTenantMode();
if (TenantMode.DB != tenantMode) {
@@ -115,7 +129,7 @@ public final class DefaultContainer implements SpiContainer {
}
}
private void applyConfigServices(DatabaseConfig config) {
private void applyConfigServices(DatabaseBuilder.Settings config) {
if (config.isDefaultServer()) {
for (DatabaseConfigProvider configProvider : ServiceLoader.load(DatabaseConfigProvider.class)) {
configProvider.apply(config);
@@ -123,12 +137,10 @@ public final class DefaultContainer implements SpiContainer {
}
if (config.isLoadModuleInfo()) {
// auto register entity classes
boolean found = false;
for (EntityClassRegister loader : ServiceLoader.load(EntityClassRegister.class)) {
for (EntityClassRegister loader : entityClassRegisters) {
config.addAll(loader.classesFor(config.getName(), config.isDefaultServer()));
found = true;
}
if (!found) {
if (entityClassRegisters.isEmpty()) {
checkMissingModulePathProvides();
}
}
@@ -158,7 +170,7 @@ public final class DefaultContainer implements SpiContainer {
* Get the entities, scalarTypes, Listeners etc combining the class registered
* ones with the already created instances.
*/
private BootupClasses bootupClasses(DatabaseConfig config) {
private BootupClasses bootupClasses(DatabaseBuilder.Settings config) {
BootupClasses bootup = bootupClasses1(config);
bootup.addServerConfigStartup(config.getServerConfigStartupListeners());
bootup.runServerConfigStartup(config);
@@ -176,7 +188,7 @@ public final class DefaultContainer implements SpiContainer {
/**
* Get the class based entities, scalarTypes, Listeners etc.
*/
private BootupClasses bootupClasses1(DatabaseConfig config) {
private BootupClasses bootupClasses1(DatabaseBuilder.Settings config) {
Set<Class<?>> classes = config.classes();
if (config.isDisableClasspathSearch() || (classes != null && !classes.isEmpty())) {
// use classes we explicitly added via configuration
@@ -188,16 +200,16 @@ public final class DefaultContainer implements SpiContainer {
/**
* Set the naming convention to underscore if it has not already been set.
*/
private void setNamingConvention(DatabaseConfig config) {
private void setNamingConvention(DatabaseBuilder.Settings config) {
if (config.getNamingConvention() == null) {
config.setNamingConvention(new UnderscoreNamingConvention());
config.namingConvention(new UnderscoreNamingConvention());
}
}
/**
* Set the DatabasePlatform if it has not already been set.
*/
private void setDatabasePlatform(DatabaseConfig config) {
private void setDatabasePlatform(DatabaseBuilder.Settings config) {
DatabasePlatform platform = config.getDatabasePlatform();
if (platform == null) {
if (config.getTenantMode().isDynamicDataSource()) {
@@ -205,7 +217,7 @@ public final class DefaultContainer implements SpiContainer {
}
// automatically determine the platform
platform = new DatabasePlatformFactory().create(config);
config.setDatabasePlatform(platform);
config.databasePlatform(platform);
}
platform.configure(config.getPlatformConfig());
}
@@ -213,7 +225,7 @@ public final class DefaultContainer implements SpiContainer {
/**
* Set the DataSource if it has not already been set.
*/
private void setDataSource(DatabaseConfig config) {
private void setDataSource(DatabaseBuilder.Settings config) {
if (isOfflineMode(config)) {
log.log(DEBUG, "... DbOffline using platform [{0}]", DbOffline.getPlatform());
} else {
@@ -221,7 +233,7 @@ public final class DefaultContainer implements SpiContainer {
}
}
private boolean isOfflineMode(DatabaseConfig config) {
private boolean isOfflineMode(DatabaseBuilder.Settings config) {
return config.isDbOffline() || DbOffline.isSet();
}
@@ -229,13 +241,11 @@ public final class DefaultContainer implements SpiContainer {
* Check the autoCommit and Transaction Isolation levels of the DataSource.
* <p>
* If autoCommit is true this could be a real problem.
* </p>
* <p>
* If the Isolation level is not READ_COMMITTED then optimistic concurrency
* checking may not work as expected.
* </p>
*/
private boolean checkDataSource(DatabaseConfig config) {
private boolean checkDataSource(DatabaseBuilder.Settings config) {
if (isOfflineMode(config)) {
return false;
}
@@ -76,7 +76,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
private static final System.Logger log = CoreLog.internal;
private final ReentrantLock lock = new ReentrantLock();
private final DatabaseConfig config;
private final DatabaseBuilder.Settings config;
private final String serverName;
private final DatabasePlatform databasePlatform;
private final TransactionManager transactionManager;
@@ -170,7 +170,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
/**
* Create the CallStackFactory depending if AutoTune is being used.
*/
private CallOriginFactory initCallStackFactory(DatabaseConfig config) {
private CallOriginFactory initCallStackFactory(DatabaseBuilder.Settings config) {
if (!config.getAutoTuneConfig().isActive()) {
// use a common CallStack for performance as we don't care with no AutoTune
return new NoopCallOriginFactory();
@@ -224,7 +224,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
@Override
public DatabaseConfig config() {
public DatabaseBuilder.Settings config() {
return config;
}
@@ -756,16 +756,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
currentTransaction().flush();
}
@Override
public void commitTransaction() {
currentTransaction().commit();
}
@Override
public void rollbackTransaction() {
currentTransaction().rollback();
}
@Override
public void endTransaction() {
Transaction transaction = transactionManager.inScope();
@@ -961,7 +951,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
if (!query.isRawSql()) {
query.setDefaultRawSqlIfRequired();
if (query.isAutoTunable() && !autoTuneService.tuneQuery(query)) {
if (!query.isAutoTunable() || !autoTuneService.tuneQuery(query)) {
// use deployment FetchType.LAZY/EAGER annotations
// to define the 'default' select clause
query.setDefaultSelectClause();
@@ -1273,6 +1263,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public <T> FutureRowCount<T> findFutureCount(SpiQuery<T> query) {
SpiQuery<T> copy = query.copy();
copy.usingFuture();
boolean createdTransaction = false;
SpiTransaction transaction = query.transaction();
if (transaction == null) {
@@ -1291,6 +1282,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public <T> FutureIds<T> findFutureIds(SpiQuery<T> query) {
SpiQuery<T> copy = query.copy();
copy.usingFuture();
boolean createdTransaction = false;
SpiTransaction transaction = query.transaction();
if (transaction == null) {
@@ -1309,6 +1301,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public <T> FutureList<T> findFutureList(SpiQuery<T> query) {
SpiQuery<T> spiQuery = query.copy();
spiQuery.usingFuture();
// FutureList query always run in it's own persistence content
spiQuery.setPersistenceContext(new DefaultPersistenceContext());
if (!spiQuery.isDisableReadAudit()) {
@@ -1651,41 +1644,50 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}, transaction);
}
/**
* Insert the bean.
*/
@Override
public void insert(Object bean) {
insert(bean, null);
persister.insert(checkEntityBean(bean), null, null);
}
@Override
public void insert(Object bean, @Nullable InsertOptions insertOptions) {
persister.insert(checkEntityBean(bean), insertOptions, null);
}
/**
* Insert the bean with a transaction.
*/
@Override
public void insert(Object bean, @Nullable Transaction transaction) {
persister.insert(checkEntityBean(bean), transaction);
persister.insert(checkEntityBean(bean), null, transaction);
}
@Override
public void insert(Object bean, InsertOptions insertOptions, Transaction transaction) {
persister.insert(checkEntityBean(bean), insertOptions, transaction);
}
/**
* Insert all beans in the collection.
*/
@Override
public void insertAll(Collection<?> beans) {
insertAll(beans, null);
insertAll(beans, null, null);
}
@Override
public void insertAll(Collection<?> beans, InsertOptions options) {
insertAll(beans, options, null);
}
/**
* Insert all beans in the collection with a transaction.
*/
@Override
public void insertAll(@Nullable Collection<?> beans, @Nullable Transaction transaction) {
insertAll(beans, null, transaction);
}
@Override
public void insertAll(@Nullable Collection<?> beans, InsertOptions options, @Nullable Transaction transaction) {
if (beans == null || beans.isEmpty()) {
return;
}
executeInTrans((txn) -> {
txn.checkBatchEscalationOnCollection();
for (Object bean : beans) {
persister.insert(checkEntityBean(bean), txn);
persister.insert(checkEntityBean(bean), options, txn);
}
return 0;
}, transaction);
@@ -1,11 +1,8 @@
package io.ebeaninternal.server.core;
import io.ebean.annotation.Platform;
import io.ebean.config.DatabaseConfig;
import io.ebean.datasource.DataSourceAlertFactory;
import io.ebean.datasource.DataSourceConfig;
import io.ebean.datasource.DataSourceFactory;
import io.ebean.datasource.DataSourcePoolListener;
import io.ebean.DatabaseBuilder;
import io.ebean.datasource.*;
import jakarta.persistence.PersistenceException;
import javax.sql.DataSource;
@@ -15,16 +12,16 @@ import javax.sql.DataSource;
*/
final class InitDataSource {
private final DatabaseConfig config;
private final DatabaseBuilder.Settings config;
/**
* Create and set the main DataSource and read-only DataSource.
*/
static void init(DatabaseConfig config) {
static void init(DatabaseBuilder.Settings config) {
new InitDataSource(config).initialise();
}
InitDataSource(DatabaseConfig config) {
InitDataSource(DatabaseBuilder.Settings config) {
this.config = config;
}
@@ -41,19 +38,23 @@ final class InitDataSource {
* Initialise the "main" read write DataSource from configuration.
*/
private DataSource initDataSource() {
return createFromConfig(config.getDataSourceConfig(), false);
return createFromConfig(config.getDataSourceConfig(), config.readOnlyDatabase(), false);
}
/**
* Initialise the "read only" DataSource from configuration.
*/
private DataSource initReadOnlyDataSource() {
DataSourceConfig roConfig = readOnlyConfig();
return roConfig == null ? null : createFromConfig(roConfig, true);
if (config.readOnlyDatabase()) {
// using the same DataSource instance
return config.getDataSource();
}
var roConfig = readOnlyConfig();
return roConfig == null ? null : createFromConfig(roConfig, false, true);
}
DataSourceConfig readOnlyConfig() {
DataSourceConfig roConfig = config.getReadOnlyDataSourceConfig();
DataSourceBuilder.Settings readOnlyConfig() {
var roConfig = config.getReadOnlyDataSourceConfig();
if (roConfig == null) {
// it has explicitly been set to null, not expected but ok
return null;
@@ -64,11 +65,11 @@ final class InitDataSource {
// convenient alternate place to set the read-only url
final String readOnlyUrl = config.getDataSourceConfig().getReadOnlyUrl();
if (urlSet(readOnlyUrl)) {
roConfig.setUrl(readOnlyUrl);
roConfig.url(readOnlyUrl);
return roConfig;
}
if (config.isAutoReadOnlyDataSource()) {
roConfig.setUrl(null); // blank out in case it is "none"
roConfig.url(null); // blank out in case it is "none"
return roConfig;
} else {
return null;
@@ -79,25 +80,27 @@ final class InitDataSource {
return url != null && !"none".equalsIgnoreCase(url) && !url.trim().isEmpty();
}
private DataSource createFromConfig(DataSourceConfig dsConfig, boolean readOnly) {
private DataSource createFromConfig(DataSourceBuilder.Settings dsConfig, boolean readOnlyDB, boolean readOnly) {
if (dsConfig == null) {
throw new PersistenceException("No DataSourceConfig defined for " + config.getName());
throw new PersistenceException("No DataSourceBuilder defined for " + config.getName());
}
if (dsConfig.isOffline()) {
if (config.getDatabasePlatformName() == null) {
throw new PersistenceException("You MUST specify a DatabasePlatformName on DatabaseConfig when offline");
}
if (dsConfig.isOffline() && config.getDatabasePlatformName() == null) {
throw new PersistenceException("You MUST specify a DatabasePlatformName on DatabaseConfig when offline");
}
attachAlert(dsConfig);
attachListener(dsConfig);
if (readOnly) {
if (readOnlyDB) {
dsConfig.autoCommit(true);
dsConfig.readOnly(true);
} else if (readOnly) {
// setup to use AutoCommit such that we skip explicit commit
dsConfig.setAutoCommit(true);
dsConfig.setReadOnly(true);
dsConfig.setDefaults(config.getDataSourceConfig());
dsConfig.setIsolationLevel(config.getDataSourceConfig().getIsolationLevel());
var mainSettings = config.getDataSourceConfig();
dsConfig.autoCommit(true);
dsConfig.readOnly(true);
dsConfig.setDefaults(mainSettings);
dsConfig.isolationLevel(mainSettings.getIsolationLevel());
} else if (isPostgresAllQuotedIdentifiers()) {
dsConfig.addProperty("quoteReturningIdentifiers", false);
}
@@ -108,32 +111,32 @@ final class InitDataSource {
return config.isAllQuotedIdentifiers() && Platform.POSTGRES == config.getDatabasePlatform().platform().base();
}
private DataSource create(DataSourceConfig dsConfig, boolean readOnly) {
private DataSource create(DataSourceBuilder dsConfig, boolean readOnly) {
String poolName = config.getName() + (readOnly ? "-ro" : "");
return DataSourceFactory.create(poolName, dsConfig);
return dsConfig.name(poolName).build();
}
/**
* Attach DataSourceAlert via service loader if present.
*/
private void attachAlert(DataSourceConfig dsConfig) {
private void attachAlert(DataSourceBuilder.Settings dsConfig) {
DataSourceAlertFactory alertFactory = config.getServiceObject(DataSourceAlertFactory.class);
if (alertFactory == null) {
alertFactory = ServiceUtil.service(DataSourceAlertFactory.class);
}
if (alertFactory != null) {
dsConfig.setAlert(alertFactory.createAlert());
dsConfig.alert(alertFactory.createAlert());
}
}
/**
* Create and attach a DataSourcePoolListener if it has been specified via properties and there is not one already attached.
*/
private void attachListener(DataSourceConfig dsConfig) {
private void attachListener(DataSourceBuilder.Settings dsConfig) {
if (dsConfig.getListener() == null) {
String poolListener = dsConfig.getPoolListener();
if (poolListener != null) {
dsConfig.setListener((DataSourcePoolListener) config.getClassLoadConfig().newInstance(poolListener));
dsConfig.listener((DataSourcePoolListener) config.getClassLoadConfig().newInstance(poolListener));
}
}
}
@@ -1,13 +1,11 @@
package io.ebeaninternal.server.core;
import com.fasterxml.jackson.core.JsonFactory;
import io.ebean.DatabaseBuilder;
import io.ebean.ExpressionFactory;
import io.ebean.annotation.Platform;
import io.ebean.cache.*;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.ExternalTransactionManager;
import io.ebean.config.ProfilingConfig;
import io.ebean.config.SlowQueryListener;
import io.ebean.config.*;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.config.dbplatform.DbHistorySupport;
import io.ebean.event.changelog.ChangeLogListener;
@@ -71,7 +69,7 @@ public final class InternalConfiguration {
private final TableModState tableModState;
private final boolean online;
private final DatabaseConfig config;
private final DatabaseBuilder.Settings config;
private final BootupClasses bootupClasses;
private final DatabasePlatform databasePlatform;
private final DeployInherit deployInherit;
@@ -100,12 +98,12 @@ public final class InternalConfiguration {
private boolean localL2Caching;
InternalConfiguration(boolean online, ClusterManager clusterManager, SpiBackgroundExecutor backgroundExecutor,
DatabaseConfig config, BootupClasses bootupClasses) {
DatabaseBuilder.Settings config, BootupClasses bootupClasses) {
this.online = online;
this.config = config;
this.jacksonCorePresent = config.getClassLoadConfig().isJacksonCorePresent();
this.clockService = new ClockService(config.getClock());
this.clockService = new ClockService(config.settings().getClock());
this.tableModState = new TableModState();
this.logManager = initLogManager();
this.docStoreFactory = initDocStoreFactory(service(DocStoreFactory.class));
@@ -175,7 +173,7 @@ public final class InternalConfiguration {
/**
* Create and return the ExpressionFactory based on configuration and database platform.
*/
private ExpressionFactory initExpressionFactory(DatabaseConfig config) {
private ExpressionFactory initExpressionFactory(DatabaseBuilder.Settings config) {
boolean nativeIlike = config.isExpressionNativeIlike() && databasePlatform.supportsNativeIlike();
return new DefaultExpressionFactory(config.isExpressionEqualsWithNullAsNoop(), nativeIlike);
}
@@ -333,7 +331,7 @@ public final class InternalConfiguration {
return config.getDatabasePlatform();
}
public DatabaseConfig getConfig() {
public DatabaseBuilder.Settings getConfig() {
return config;
}
@@ -590,14 +588,16 @@ public final class InternalConfiguration {
*/
QueryPlanLogger queryPlanLogger(Platform platform) {
switch (platform.base()) {
case POSTGRES:
return new QueryPlanLoggerPostgres();
case SQLSERVER:
return new QueryPlanLoggerSqlServer();
case ORACLE:
return new QueryPlanLoggerOracle();
case POSTGRES:
return new QueryPlanLoggerExplain("explain (analyze, buffers) ");
case YUGABYTE:
return new QueryPlanLoggerExplain("explain (analyze, buffers, dist) ");
default:
return new QueryPlanLoggerExplain();
return new QueryPlanLoggerExplain("explain ");
}
}
@@ -35,7 +35,6 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
private final OrmQueryEngine queryEngine;
private final SpiQuery<T> query;
private final BeanFindController finder;
private final Boolean readOnly;
private LoadContext loadContext;
private PersistenceContext persistenceContext;
private HashQuery cacheKey;
@@ -52,7 +51,6 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
this.finder = beanDescriptor.beanFinder();
this.queryEngine = queryEngine;
this.query = query;
this.readOnly = query.isReadOnly();
this.persistenceContext = query.persistenceContext();
}
@@ -135,13 +133,6 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
return loadContext.secondaryQueriesMinBatchSize();
}
/**
* Return the Normal, sharedInstance, ReadOnly state of this query.
*/
public Boolean isReadOnly() {
return readOnly;
}
/**
* Return the BeanDescriptor for the associated bean.
*/
@@ -782,4 +773,10 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
public int forwardOnlyFetchSize() {
return queryEngine.forwardOnlyFetchSize();
}
public void clearContext() {
if (!transaction.isAutoPersistUpdates()) {
beanDescriptor.contextClear(transaction.persistenceContext());
}
}
}
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.core;
import io.ebean.InsertOptions;
import io.ebean.ValuePair;
import io.ebean.annotation.DocStoreMode;
import io.ebean.bean.EntityBean;
@@ -124,6 +125,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
* Many-to-many intersection table changes that are held for later batch processing.
*/
private List<SaveMany> saveMany;
private InsertOptions insertOptions;
public PersistRequestBean(SpiEbeanServer server, T bean, Object parentBean, BeanManager<T> mgr, SpiTransaction t,
PersistExecute persistExecute, PersistRequest.Type type, int flags) {
@@ -380,6 +382,14 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
return intercept.dirtyPropertyNames();
}
public boolean isChangedProperty(int propertyIndex) {
if (dirtyProperties == null) {
return intercept.isChangedProperty(propertyIndex);
} else {
return dirtyProperties[propertyIndex];
}
}
/**
* Return the dirty properties on this request.
*/
@@ -865,8 +875,8 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
}
setNotifyCache();
boolean isChangeLog = beanDescriptor.isChangeLog();
if (type == Type.UPDATE && (isChangeLog || notifyCache || docStoreMode == DocStoreMode.UPDATE)) {
// get the dirty properties for update notification to the doc store
if (type == Type.UPDATE) {
// get the dirty properties for notify cache & orphanRemoval of vanilla collection detection
dirtyProperties = intercept.dirtyProperties();
}
if (isChangeLog) {
@@ -909,21 +919,27 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
}
private void controllerPost() {
switch (type) {
case INSERT:
controller.postInsert(this);
break;
case UPDATE:
controller.postUpdate(this);
break;
case DELETE_SOFT:
controller.postSoftDelete(this);
break;
case DELETE:
controller.postDelete(this);
break;
default:
break;
boolean old = transaction.isFlushOnQuery();
transaction.setFlushOnQuery(false);
try {
switch (type) {
case INSERT:
controller.postInsert(this);
break;
case UPDATE:
controller.postUpdate(this);
break;
case DELETE_SOFT:
controller.postSoftDelete(this);
break;
case DELETE:
controller.postDelete(this);
break;
default:
break;
}
} finally {
transaction.setFlushOnQuery(old);
}
}
@@ -1408,4 +1424,12 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
private void setGeneratedId() {
beanDescriptor.setGeneratedId(entityBean, transaction);
}
public void setInsertOptions(InsertOptions insertOptions) {
this.insertOptions = insertOptions;
}
public InsertOptions insertOptions() {
return insertOptions;
}
}
@@ -77,10 +77,13 @@ public final class PersistRequestOrmUpdate extends PersistRequest {
*/
@Override
public void postExecute() {
OrmUpdateType ormUpdateType = ormUpdate.ormUpdateType();
if (OrmUpdateType.INSERT != ormUpdateType && !transaction.isAutoPersistUpdates()) {
beanDescriptor.contextClear(transaction.persistenceContext());
}
if (startNanos > 0) {
persistExecute.collectOrmUpdate(label, startNanos);
}
OrmUpdateType ormUpdateType = ormUpdate.ormUpdateType();
String tableName = ormUpdate.baseTable();
if (transaction.isLogSummary()) {
transaction.logSummary("{0} table[{1}] rows[{2}] bind[{3}]", ormUpdateType, tableName, rowCount, bindLog);
@@ -3,10 +3,13 @@ package io.ebeaninternal.server.core;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.SpiSqlUpdate;
import io.ebeaninternal.api.SpiTransaction;
import io.ebeaninternal.server.deploy.BeanDescriptor;
import io.ebeaninternal.server.persist.BatchControl;
import io.ebeaninternal.server.persist.PersistExecute;
import io.ebeaninternal.server.persist.TrimLogSql;
import java.util.List;
/**
* Persist request specifically for CallableSql.
*/
@@ -156,6 +159,14 @@ public final class PersistRequestUpdateSql extends PersistRequest {
*/
@Override
public void postExecute() {
if (sqlType != SqlType.SQL_INSERT && !transaction.isAutoPersistUpdates()) {
List<BeanDescriptor<?>> descriptors = server.descriptors(tableName);
if (descriptors != null) {
for (BeanDescriptor<?> descriptor : descriptors) {
descriptor.contextClear(transaction.persistenceContext());
}
}
}
if (startNanos > 0) {
persistExecute.collectSqlUpdate(label, startNanos);
}
@@ -1,11 +1,7 @@
package io.ebeaninternal.server.core;
import io.ebean.CallableSql;
import io.ebean.MergeOptions;
import io.ebean.Query;
import io.ebean.SqlUpdate;
import io.ebean.Transaction;
import io.ebean.Update;
import io.avaje.lang.Nullable;
import io.ebean.*;
import io.ebean.bean.EntityBean;
import io.ebean.meta.MetricVisitor;
import io.ebeaninternal.api.SpiSqlUpdate;
@@ -31,9 +27,9 @@ public interface Persister {
void update(EntityBean entityBean, Transaction t);
/**
* Force an Insert using the given bean.
* Perform an Insert using the given bean.
*/
void insert(EntityBean entityBean, Transaction t);
void insert(EntityBean entityBean, @Nullable InsertOptions insertOptions, @Nullable Transaction t);
/**
* Insert or update the bean depending on its state.
@@ -44,7 +40,6 @@ public interface Persister {
* Delete a bean given it's type and id value.
* <p>
* This will also cascade delete one level of children.
* </p>
*/
int delete(Class<?> beanType, Object id, Transaction transaction, boolean permanent);
@@ -1,7 +1,7 @@
package io.ebeaninternal.server.core.bootup;
import io.avaje.classpath.scanner.ClassPathScanner;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
import io.ebeaninternal.api.CoreLog;
import io.ebeaninternal.server.core.ClassPathScanners;
@@ -24,11 +24,11 @@ public class BootupClassPathSearch {
* Search the classPath for the classes we are interested in returning
* them as BootupClasses.
*/
public static BootupClasses search(DatabaseConfig config) {
public static BootupClasses search(DatabaseBuilder.Settings config) {
return new BootupClassPathSearch(config).getBootupClasses();
}
private BootupClassPathSearch(DatabaseConfig config) {
private BootupClassPathSearch(DatabaseBuilder.Settings config) {
// find packages defined in ebean.mf resources
Set<String> mfPackages = ManifestReader.create(config.getClassLoadConfig().getClassLoader())
.read("META-INF/ebean.mf")
@@ -1,7 +1,7 @@
package io.ebeaninternal.server.core.bootup;
import io.ebean.annotation.DocStore;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
import io.ebean.config.IdGenerator;
import io.ebean.config.ScalarTypeConverter;
import io.ebean.core.type.ScalarType;
@@ -91,7 +91,7 @@ public class BootupClasses implements Predicate<Class<?>> {
/**
* Run any ServerConfigStartup listeners.
*/
public void runServerConfigStartup(DatabaseConfig config) {
public void runServerConfigStartup(DatabaseBuilder config) {
for (Class<?> cls : serverConfigStartupCandidates) {
try {
ServerConfigStartup newInstance = (ServerConfigStartup) cls.getDeclaredConstructor().newInstance();
@@ -172,7 +172,7 @@ public class BootupClasses implements Predicate<Class<?>> {
add(startupInstances, serverConfigStartupInstances, serverConfigStartupCandidates);
}
public void addChangeLogInstances(DatabaseConfig config) {
public void addChangeLogInstances(DatabaseBuilder.Settings config) {
readAuditPrepare = config.getReadAuditPrepare();
readAuditLogger = config.getReadAuditLogger();
changeLogPrepare = config.getChangeLogPrepare();
@@ -4,7 +4,7 @@ import io.ebean.*;
import io.ebean.annotation.DocStoreMode;
import io.ebean.bean.*;
import io.ebean.cache.QueryCacheEntry;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
import io.ebean.config.EncryptKey;
import io.ebean.config.dbplatform.IdType;
import io.ebean.config.dbplatform.PlatformIdGenerator;
@@ -237,7 +237,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
this.owner = owner;
this.multiValueSupported = owner.isMultiValueSupported();
this.entityType = deploy.getEntityType();
this.properties = deploy.getProperties();
this.properties = deploy.propertyNames();
this.name = InternString.intern(deploy.getName());
this.baseTableAlias = "t0";
this.fullName = InternString.intern(deploy.getFullName());
@@ -278,7 +278,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
this.partitionMeta = deploy.getPartitionMeta();
this.tablespaceMeta = deploy.getTablespaceMeta();
this.storageEngine = deploy.getStorageEngine();
this.autoTunable = beanFinder == null && (entityType == EntityType.ORM || entityType == EntityType.VIEW);
this.autoTunable = entityType == EntityType.ORM || entityType == EntityType.VIEW;
// helper object used to derive lists of properties
DeployBeanPropertyLists listHelper = new DeployBeanPropertyLists(owner, this, deploy);
this.softDeleteProperty = listHelper.getSoftDeleteProperty();
@@ -423,7 +423,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
/**
* Return the DatabaseConfig.
*/
public DatabaseConfig config() {
public DatabaseBuilder.Settings config() {
return owner.config();
}
@@ -2056,6 +2056,13 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
pc.clear(rootBeanType, idValue);
}
/**
* Clear a bean from the persistence context.
*/
public void contextClear(PersistenceContext pc) {
pc.clear(rootBeanType);
}
/**
* Delete a bean from the persistence context (such that we don't fetch it in the same transaction).
*/
@@ -1,6 +1,7 @@
package io.ebeaninternal.server.deploy;
import io.ebean.BackgroundExecutor;
import io.ebean.DatabaseBuilder;
import io.ebean.Model;
import io.ebean.RawSqlBuilder;
import io.ebean.annotation.ConstraintMode;
@@ -78,7 +79,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
private final NamingConvention namingConvention;
private final DeployCreateProperties createProperties;
private final BeanManagerFactory beanManagerFactory;
private final DatabaseConfig config;
private final DatabaseBuilder.Settings config;
private final ChangeLogListener changeLogListener;
private final ChangeLogRegister changeLogRegister;
private final ChangeLogPrepare changeLogPrepare;
@@ -105,6 +106,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
private final String asOfViewSuffix;
private final boolean jacksonCorePresent;
private final int queryPlanTTLSeconds;
private final BindMaxLength bindMaxLength;
private int entityBeanCount;
private List<BeanDescriptor<?>> immutableDescriptorList;
/**
@@ -159,6 +161,19 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
this.changeLogListener = config.changeLogListener(bootupClasses.getChangeLogListener());
this.changeLogRegister = config.changeLogRegister(bootupClasses.getChangeLogRegister());
this.jacksonCorePresent = config.isJacksonCorePresent();
this.bindMaxLength = initMaxLength();
}
BindMaxLength initMaxLength() {
LengthCheck lengthCheck = this.config.getLengthCheck();
switch (lengthCheck) {
case OFF:
return null;
case UTF8:
return BindMaxLength.ofUtf8();
default:
return BindMaxLength.ofStandard();
}
}
@Override
@@ -195,19 +210,19 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
/**
* Return the AsOfViewSuffix based on the DbHistorySupport.
*/
private String asOfViewSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) {
private String asOfViewSuffix(DatabasePlatform databasePlatform, DatabaseBuilder.Settings config) {
DbHistorySupport historySupport = databasePlatform.historySupport();
// with historySupport returns a simple view suffix or the sql2011 as of timestamp suffix
return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getAsOfViewSuffix(serverConfig.getAsOfViewSuffix());
return (historySupport == null) ? config.getAsOfViewSuffix() : historySupport.getAsOfViewSuffix(config.getAsOfViewSuffix());
}
/**
* Return the versions between timestamp suffix based on the DbHistorySupport.
*/
private String versionsBetweenSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) {
private String versionsBetweenSuffix(DatabasePlatform databasePlatform, DatabaseBuilder.Settings config) {
DbHistorySupport historySupport = databasePlatform.historySupport();
// with historySupport returns a simple view suffix or the sql2011 versions between timestamp suffix
return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getVersionsBetweenSuffix(serverConfig.getAsOfViewSuffix());
return (historySupport == null) ? config.getAsOfViewSuffix() : historySupport.getVersionsBetweenSuffix(config.getAsOfViewSuffix());
}
@Override
@@ -216,7 +231,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
}
@Override
public DatabaseConfig config() {
public DatabaseBuilder.Settings config() {
return config;
}
@@ -398,7 +413,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
* Return the BeanDescriptors mapped to the table.
*/
public List<BeanDescriptor<?>> descriptors(String tableName) {
return tableToDescMap.get(tableName.toLowerCase());
return tableName == null ? Collections.emptyList() : tableToDescMap.get(tableName.toLowerCase());
}
/**
@@ -443,11 +458,10 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
// build map of tables to view entities dependent on those tables
// for the purpose of invalidating appropriate query caches
String[] dependentTables = desc.dependentTables();
if (dependentTables != null && dependentTables.length > 0) {
if (dependentTables != null) {
for (String depTable : dependentTables) {
depTable = depTable.toLowerCase();
List<BeanDescriptor<?>> list = tableToViewDescMap.computeIfAbsent(depTable, k -> new ArrayList<>(1));
list.add(desc);
tableToViewDescMap.computeIfAbsent(depTable, k -> new ArrayList<>(1)).add(desc);
}
}
}
@@ -578,7 +592,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
}
}
private <T> String errNothingRegistered() {
private String errNothingRegistered() {
return "There are no registered entities. If using query beans, that generates EbeanEntityRegister.java into " +
"generated sources and is service loaded. If using module-info.java, then probably missing 'provides io.ebean.config.EntityClassRegister with EbeanEntityRegister' clause.";
}
@@ -1186,7 +1200,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
setConcurrencyMode(desc);
}
// generate the byte code
createByteCode(desc);
setAccessors(desc);
}
/**
@@ -1255,13 +1269,13 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
return databasePlatform.createSequenceIdGenerator(backgroundExecutor, dataSource, stepSize, seqName);
}
private void createByteCode(DeployBeanDescriptor<?> deploy) {
private void setAccessors(DeployBeanDescriptor<?> deploy) {
// check to see if the bean supports EntityBean interface
// generate a subclass if required
setEntityBeanClass(deploy);
confirmEnhanced(deploy);
// use Code generation or Standard reflection to support
// getter and setter methods
setBeanReflect(deploy);
setPropertyAccessors(deploy);
}
/**
@@ -1288,15 +1302,14 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
* and getting of properties. It is generally faster to use code generation
* rather than reflection to do this.
*/
private void setBeanReflect(DeployBeanDescriptor<?> desc) {
private void setPropertyAccessors(DeployBeanDescriptor<?> desc) {
// Set the BeanReflectGetter and BeanReflectSetter that typically
// use generated code. NB: Due to Bug 166 so now doing this for
// abstract classes as well.
BeanPropertiesReader reflectProps = new BeanPropertiesReader(desc.getBeanType());
desc.setProperties(reflectProps.getProperties());
BeanPropertiesReader reflectProps = new BeanPropertiesReader(desc.propertyNames());
for (DeployBeanProperty prop : desc.propertiesAll()) {
String propName = prop.getName();
Integer pos = reflectProps.getPropertyIndex(propName);
Integer pos = reflectProps.propertyIndex(propName);
if (pos == null) {
if (isPersistentField(prop)) {
throw new IllegalStateException(
@@ -1368,7 +1381,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
/**
* Test the bean type to see if it implements EntityBean interface already.
*/
private void setEntityBeanClass(DeployBeanDescriptor<?> desc) {
private void confirmEnhanced(DeployBeanDescriptor<?> desc) {
Class<?> beanClass = desc.getBeanType();
if (!hasEntityBeanInterface(beanClass)) {
String msg = "Bean " + beanClass + " is not enhanced? Check packages specified in ebean.mf. If you are running in IDEA or " +
@@ -1502,6 +1515,10 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
return list;
}
public BindMaxLength bindMaxLength() {
return bindMaxLength;
}
/**
* Comparator to sort the BeanDescriptors by name.
*/
@@ -1,6 +1,6 @@
package io.ebeaninternal.server.deploy;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
import io.ebean.config.EncryptKey;
import io.ebean.config.NamingConvention;
import io.ebean.core.type.ScalarType;
@@ -25,7 +25,7 @@ public interface BeanDescriptorMap {
/**
* Return the DatabaseConfig.
*/
DatabaseConfig config();
DatabaseBuilder.Settings config();
/**
* Return the Cache Manager.
@@ -2,7 +2,7 @@ package io.ebeaninternal.server.deploy;
import io.ebean.annotation.PostSoftDelete;
import io.ebean.annotation.PreSoftDelete;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
import io.ebean.event.BeanPersistAdapter;
import io.ebean.event.BeanPersistRequest;
import io.ebean.event.BeanPostConstructListener;
@@ -34,7 +34,7 @@ final class BeanLifecycleAdapterFactory {
private final boolean postConstructPresent;
BeanLifecycleAdapterFactory(DatabaseConfig config) {
BeanLifecycleAdapterFactory(DatabaseBuilder.Settings config) {
this.postConstructPresent = config.getClassLoadConfig().isJavaxPostConstructPresent();
}
@@ -1,6 +1,7 @@
package io.ebeaninternal.server.deploy;
import com.fasterxml.jackson.core.JsonToken;
import io.ebean.DataIntegrityException;
import io.ebean.ValuePair;
import io.ebean.bean.EntityBean;
import io.ebean.bean.EntityBeanIntercept;
@@ -40,8 +41,8 @@ import io.ebeanservice.docstore.api.mapping.DocMappingBuilder;
import io.ebeanservice.docstore.api.mapping.DocPropertyMapping;
import io.ebeanservice.docstore.api.mapping.DocPropertyOptions;
import io.ebeanservice.docstore.api.support.DocStructure;
import jakarta.persistence.PersistenceException;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
@@ -166,6 +167,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
*/
private final String dbComment;
private final DbEncryptFunction dbEncryptFunction;
private final BindMaxLength bindMaxLength;
private int deployOrder;
final boolean jsonSerialize;
final boolean jsonDeserialize;
@@ -258,6 +260,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
}
this.jsonSerialize = deploy.isJsonSerialize();
this.jsonDeserialize = deploy.isJsonDeserialize();
this.bindMaxLength = deploy.bindMaxLength();
}
private String tableAliasIntern(BeanDescriptor<?> descriptor, String s, boolean dbEncrypted, String dbColumn) {
@@ -345,6 +348,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
this.elPlaceHolderEncrypted = override.replace(source.elPlaceHolderEncrypted, source.dbColumn);
this.jsonSerialize = source.jsonSerialize;
this.jsonDeserialize = source.jsonDeserialize;
this.bindMaxLength = source.bindMaxLength;
}
/**
@@ -555,6 +559,18 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
@SuppressWarnings("unchecked")
public void bind(DataBind b, Object value) throws SQLException {
scalarType.bind(b, value);
if (bindMaxLength != null) {
Object obj = b.popLastObject();
long length = bindMaxLength.length(dbLength, obj);
if (length > dbLength) {
b.closeInputStreams();
String s = String.valueOf(value); // take original bind value here.
if (s.length() > 50) {
s = s.substring(0, 47) + "...";
}
throw new DataIntegrityException("Cannot bind value '" + s + "' (effective length=" + length + ") to column '" + dbColumn + "' (length=" + dbLength + ")");
}
}
}
@SuppressWarnings(value = "unchecked")
@@ -1166,14 +1182,14 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
* Returns true if this <code>isLob()</code> or the type will effectively map to a lob.
*/
@Override
public boolean isDbLob() {
public boolean isLobForPlatform() {
if (lob) {
return true;
}
switch (dbType) {
case DbPlatformType.JSON:
case DbPlatformType.JSONB:
return dbLength == 0; // must be analog to DbPlatformTypeMapping.lookup
return dbLength == 0 || dbLength > 4000; // must be analog to DbPlatformTypeMapping.lookup
case DbPlatformType.JSONBlob:
case DbPlatformType.JSONClob:
return true;
@@ -379,6 +379,9 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
for (ExportedProperty exportedProperty : exportedProperties) {
row.addColumn(exportedProperty.getForeignDbColumn());
}
if (importedId == null) {
throw new PersistenceException("Missing @Id property on bean related to ManyToMany " + fullName());
}
importedId.buildImport(row);
return row.build();
}
@@ -585,10 +588,9 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
}
/**
* Set the join properties from the parent bean to the child bean.
* This is only valid for OneToMany and NOT valid for ManyToMany.
* Set the parent bean to the child (update the relationship).
*/
public void setJoinValuesToChild(EntityBean parent, EntityBean child, Object mapKeyValue) {
public void setParentToChild(EntityBean parent, EntityBean child, Object mapKeyValue) {
if (mapKeyProperty != null) {
mapKeyProperty.setValue(child, mapKeyValue);
}
@@ -599,6 +601,31 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
}
}
/**
* Return true if the parent bean has been set to the child (updated the relationship).
*/
public boolean setParentToChild(EntityBean parent, EntityBean child, Object mapKeyValue, BeanDescriptor<?> parentDesc) {
if (manyToMany
|| childMasterProperty == null
|| !child._ebean_getIntercept().isLoadedProperty(childMasterProperty.propertyIndex())) {
return false;
}
Object currentParent = childMasterProperty.getValue(child);
if (currentParent != null) {
Object newId = parentDesc.getId(parent);
Object oldId = parentDesc.id(currentParent);
if (Objects.equals(newId, oldId)) {
return false;
}
}
childMasterProperty.setValueIntercept(child, parent);
if (mapKeyProperty != null) {
mapKeyProperty.setValue(child, mapKeyValue);
}
return true;
}
/**
* Return the order by clause used to order the fetching of the data for
* this list, set or map.
@@ -0,0 +1,90 @@
package io.ebeaninternal.server.deploy;
import io.ebean.core.type.InputStreamInfo;
import java.nio.charset.StandardCharsets;
/**
* The max length check on bind values.
*/
public interface BindMaxLength {
/**
* Return a UTF8 based implementation.
*/
static BindMaxLength ofUtf8() {
return new UTF8();
}
/**
* Return a standard implementation.
*/
static BindMaxLength ofStandard() {
return new Standard();
}
/**
* Return the length of the object.
*/
long length(int dbLength, Object obj);
/**
* Length check based on UTF8 bytes.
*/
final class UTF8 implements BindMaxLength {
@Override
public long length(int dbLength, Object obj) {
if (obj == null) {
return -1;
} else if (obj instanceof String) {
String s = (String) obj;
return utf8String(dbLength, s);
} else if (obj instanceof byte[]) {
return ((byte[]) obj).length;
} else if (obj instanceof InputStreamInfo) {
return ((InputStreamInfo) obj).length();
} else if ("org.postgresql.util.PGobject".equals(obj.getClass().getCanonicalName())) {
String value = ((org.postgresql.util.PGobject) obj).getValue();
return value == null ? -1 : utf8String(dbLength, value);
} else {
return -1;
}
}
private static int utf8String(int dbLength, String s) {
int stringLength = s.length();
if (stringLength > dbLength) {
return stringLength;
} else if (stringLength * 4 <= dbLength) {
return -1;
} else {
return s.getBytes(StandardCharsets.UTF_8).length;
}
}
}
/**
* Standard string length implementation.
*/
final class Standard implements BindMaxLength {
@Override
public long length(int dbLength, Object obj) {
if (obj == null) {
return -1;
} else if (obj instanceof String) {
return ((String) obj).length();
} else if (obj instanceof byte[]) {
return ((byte[]) obj).length;
} else if (obj instanceof InputStreamInfo) {
return ((InputStreamInfo) obj).length();
} else if ("org.postgresql.util.PGobject".equals(obj.getClass().getCanonicalName())) {
String value = ((org.postgresql.util.PGobject) obj).getValue();
return value == null ? -1 : value.length();
} else {
return -1;
}
}
}
}
@@ -63,7 +63,7 @@ class DynamicPropertyAggregationFormula extends DynamicPropertyBase {
}
@Override
public boolean isDbLob() {
public boolean isLobForPlatform() {
return false;
}
@@ -1,10 +1,8 @@
package io.ebeaninternal.server.deploy.generatedproperty;
import io.ebean.DatabaseBuilder;
import io.ebean.Transaction;
import io.ebean.config.ClassLoadConfig;
import io.ebean.config.CurrentUserProvider;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.IdGenerator;
import io.ebean.config.*;
import io.ebean.config.dbplatform.PlatformIdGenerator;
import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
@@ -29,7 +27,7 @@ public final class GeneratedPropertyFactory {
private final ClassLoadConfig classLoadConfig;
private final Map<String, PlatformIdGenerator> idGeneratorMap = new HashMap<>();
public GeneratedPropertyFactory(boolean offlineMode, DatabaseConfig config, List<IdGenerator> idGenerators) {
public GeneratedPropertyFactory(boolean offlineMode, DatabaseBuilder.Settings config, List<IdGenerator> idGenerators) {
this.classLoadConfig = config.getClassLoadConfig();
this.insertFactory = new InsertTimestampFactory(classLoadConfig);
this.updateFactory = new UpdateTimestampFactory(classLoadConfig);
@@ -1,10 +1,10 @@
package io.ebeaninternal.server.deploy.meta;
import io.ebean.DatabaseBuilder;
import io.ebean.annotation.Cache;
import io.ebean.annotation.DocStore;
import io.ebean.annotation.DocStoreMode;
import io.ebean.annotation.Identity;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.TableName;
import io.ebean.config.dbplatform.IdType;
import io.ebean.config.dbplatform.PlatformIdGenerator;
@@ -21,9 +21,10 @@ import io.ebeaninternal.server.idgen.UuidV1IdGenerator;
import io.ebeaninternal.server.idgen.UuidV1RndIdGenerator;
import io.ebeaninternal.server.idgen.UuidV4IdGenerator;
import io.ebeaninternal.server.rawsql.SpiRawSql;
import jakarta.persistence.Entity;
import jakarta.persistence.MappedSuperclass;
import java.lang.reflect.Field;
import java.util.*;
/**
@@ -45,9 +46,7 @@ public class DeployBeanDescriptor<T> {
private static final PropOrder PROP_ORDER = new PropOrder();
private static final String I_SCALAOBJECT = "scala.ScalaObject";
private final DatabaseConfig config;
private final DatabaseBuilder.Settings config;
private final BeanDescriptorManager manager;
/**
* Map of BeanProperty Linked so as to preserve order.
@@ -133,16 +132,40 @@ public class DeployBeanDescriptor<T> {
/**
* Construct the BeanDescriptor.
*/
public DeployBeanDescriptor(BeanDescriptorManager manager, Class<T> beanType, DatabaseConfig config) {
public DeployBeanDescriptor(BeanDescriptorManager manager, Class<T> beanType, DatabaseBuilder.Settings config) {
this.manager = manager;
this.config = config;
this.beanType = beanType;
}
public BindMaxLength bindMaxLength() {
return manager.bindMaxLength();
}
private String[] readPropertyNames() {
try {
Field field = beanType.getField("_ebean_props");
return (String[]) field.get(null);
} catch (Exception e) {
throw new IllegalStateException("Error getting _ebean_props field on type " + beanType, e);
}
}
public void setPropertyNames(String[] properties) {
this.properties = properties;
}
public String[] propertyNames() {
if (properties == null) {
properties = readPropertyNames();
}
return properties;
}
/**
* Set the IdClass to use.
*/
public void setIdClass(Class idClass) {
public void setIdClass(Class<?> idClass) {
this.idClass = idClass;
}
@@ -260,7 +283,6 @@ public class DeployBeanDescriptor<T> {
* Read the top level doc store deployment information.
*/
public void readDocStore(DocStore docStore) {
this.docStore = docStore;
docStoreMapped = true;
docStoreQueueId = docStore.queueId();
@@ -276,23 +298,10 @@ public class DeployBeanDescriptor<T> {
}
}
public boolean isScalaObject() {
Class<?>[] interfaces = beanType.getInterfaces();
for (Class<?> anInterface : interfaces) {
String iname = anInterface.getName();
if (I_SCALAOBJECT.equals(iname)) {
return true;
}
}
return false;
}
public DeployBeanTable createDeployBeanTable() {
DeployBeanTable beanTable = new DeployBeanTable(getBeanType());
beanTable.setBaseTable(baseTable);
beanTable.setIdProperty(idProperty());
return beanTable;
}
@@ -360,14 +369,6 @@ public class DeployBeanDescriptor<T> {
this.identityMode.setIdType(type);
}
public String[] getProperties() {
return properties;
}
public void setProperties(String[] props) {
this.properties = props;
}
/**
* Return the class type this BeanDescriptor describes.
*/
@@ -1,14 +1,17 @@
package io.ebeaninternal.server.deploy.meta;
import io.avaje.lang.Nullable;
import io.ebean.annotation.*;
import io.ebean.config.ScalarTypeConverter;
import io.ebean.config.dbplatform.DbDefaultValue;
import io.ebean.config.dbplatform.DbEncrypt;
import io.ebean.config.dbplatform.DbEncryptFunction;
import io.ebean.config.dbplatform.ExtraDbTypes;
import io.ebean.core.type.ScalarType;
import io.ebean.util.AnnotationUtil;
import io.ebeaninternal.server.core.InternString;
import io.ebeaninternal.server.deploy.BeanProperty;
import io.ebeaninternal.server.deploy.BindMaxLength;
import io.ebeaninternal.server.deploy.DbMigrationInfo;
import io.ebeaninternal.server.deploy.DeployDocPropertyOptions;
import io.ebeaninternal.server.deploy.generatedproperty.GeneratedProperty;
@@ -1133,4 +1136,20 @@ public class DeployBeanProperty {
boolean isJsonType() {
return mutationDetection != null;
}
@Nullable
public BindMaxLength bindMaxLength() {
if (dbLength == 0) {
return null;
}
switch (dbType) {
case Types.VARCHAR:
case Types.BLOB:
case ExtraDbTypes.JSON:
return desc.bindMaxLength();
default:
return null;
}
}
}
@@ -213,9 +213,9 @@ final class AnnotationAssocManys extends AnnotationAssoc {
int sortOrder = 0;
if (!prop.getManyType().isMap()) {
elementDescriptor.setProperties(new String[]{"value"});
elementDescriptor.setPropertyNames(new String[]{"value"});
} else {
elementDescriptor.setProperties(new String[]{"key", "value"});
elementDescriptor.setPropertyNames(new String[]{"key", "value"});
String dbKeyColumn = "mkey";
MapKeyColumn mapKeyColumn = get(prop, MapKeyColumn.class);
if (mapKeyColumn != null) {
@@ -99,6 +99,10 @@ final class AnnotationFields extends AnnotationParser {
if (formula != null) {
prop.setSqlFormula(processFormula(formula.select()), processFormula(formula.join()));
}
DbComment comment = get(prop, DbComment.class);
if (comment != null) {
prop.setDbComment(comment.value());
}
initWhoProperties(prop);
initDbMigration(prop);
}
@@ -1,13 +1,8 @@
package io.ebeaninternal.server.deploy.parse;
import io.ebean.DatabaseBuilder;
import io.ebean.annotation.*;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.EncryptDeploy;
import io.ebean.config.EncryptDeployManager;
import io.ebean.config.EncryptKeyManager;
import io.ebean.config.Encryptor;
import io.ebean.config.NamingConvention;
import io.ebean.config.TableName;
import io.ebean.config.*;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.config.dbplatform.DbPlatformType;
import io.ebean.core.type.ScalarType;
@@ -49,7 +44,7 @@ public final class DeployUtil {
private final Encryptor bytesEncryptor;
private final boolean useValidationNotNull;
public DeployUtil(TypeManager typeMgr, DatabaseConfig config) {
public DeployUtil(TypeManager typeMgr, DatabaseBuilder.Settings config) {
this.typeManager = typeMgr;
this.namingConvention = config.getNamingConvention();
this.dbPlatform = config.getDatabasePlatform();
@@ -4,7 +4,7 @@ import io.ebean.annotation.Aggregation;
import io.ebean.annotation.Formula;
import io.ebean.annotation.Where;
import io.ebean.config.ClassLoadConfig;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
import io.ebeaninternal.server.deploy.generatedproperty.GeneratedPropertyFactory;
import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
@@ -31,7 +31,7 @@ final class ReadAnnotationConfig {
private final ReadValidationAnnotations jakartaValidation;
private final Set<Class<?>> metaAnnotations = new HashSet<>();
ReadAnnotationConfig(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseConfig config) {
ReadAnnotationConfig(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseBuilder.Settings config) {
this.generatedPropFactory = generatedPropFactory;
this.asOfViewSuffix = asOfViewSuffix;
this.versionsBetweenSuffix = versionsBetweenSuffix;
@@ -1,6 +1,6 @@
package io.ebeaninternal.server.deploy.parse;
import io.ebean.config.DatabaseConfig;
import io.ebean.DatabaseBuilder;
import io.ebeaninternal.server.deploy.BeanDescriptorManager;
import io.ebeaninternal.server.deploy.generatedproperty.GeneratedPropertyFactory;
@@ -12,7 +12,7 @@ public final class ReadAnnotations {
private final ReadAnnotationConfig readConfig;
public ReadAnnotations(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseConfig config) {
public ReadAnnotations(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseBuilder.Settings config) {
this.readConfig = new ReadAnnotationConfig(generatedPropFactory, asOfViewSuffix, versionsBetweenSuffix, config);
}
@@ -81,7 +81,7 @@ final class BetweenPropertyExpression extends NonPrepareExpression {
@Override
public void addSql(SpiExpressionRequest request) {
request.append(" ?").append(BETWEEN).property(name(lowProperty)).append(" and ").property(name(highProperty));
request.append("?").append(BETWEEN).property(name(lowProperty)).append(" and ").property(name(highProperty));
}
@Override
@@ -1,6 +1,5 @@
package io.ebeaninternal.server.expression.platform;
import io.ebeaninternal.api.SpiExpressionRequest;
import io.ebeaninternal.server.expression.BitwiseOp;
/**
@@ -9,7 +8,7 @@ import io.ebeaninternal.server.expression.BitwiseOp;
abstract class BaseDbExpression implements DbExpressionHandler {
@Override
public void bitwise(SpiExpressionRequest request, String propName, BitwiseOp operator, long flags, String compare, long match) {
public void bitwise(DbExpressionRequest request, String propName, BitwiseOp operator, long flags, String compare, long match) {
final String bitOp = bitOp(operator);
request.append('(').property(propName).append(' ').append(bitOp).append(" ? ").append(compare).append(" ?)");
}
@@ -28,7 +27,7 @@ abstract class BaseDbExpression implements DbExpressionHandler {
/**
* Common alternative where the bitwise operation is a function (specifically bitand is used - H2 and Oracle).
*/
protected void bitwiseFunction(SpiExpressionRequest request, String propName, BitwiseOp operator, String compare) {
protected void bitwiseFunction(DbExpressionRequest request, String propName, BitwiseOp operator, String compare) {
final String funcName = functionName(operator);
request.append(funcName).append('(').property(propName).append(", ?) ").append(compare).append(" ?");
}

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