mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Compare commits
249
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04ff5e7995 | ||
|
|
f490116572 | ||
|
|
6e163b9f5c | ||
|
|
63336bafe5 | ||
|
|
97ca198b7c | ||
|
|
88fd59e164 | ||
|
|
5b9ef2daec | ||
|
|
514bba4130 | ||
|
|
d31aa2b24c | ||
|
|
d834817dc2 | ||
|
|
4cad515110 | ||
|
|
aa89df5f00 | ||
|
|
29f7375468 | ||
|
|
3e4d7c9b5a | ||
|
|
fa34c39d92 | ||
|
|
ffeb630e7e | ||
|
|
7666775d1a | ||
|
|
f95212eeb3 | ||
|
|
5c3b680c8a | ||
|
|
c8bb3c7b57 | ||
|
|
dcd3bfee4c | ||
|
|
b85bb5f459 | ||
|
|
426d314e63 | ||
|
|
e3e5414157 | ||
|
|
28088a5e54 | ||
|
|
2acdf2f4bf | ||
|
|
785a027dd6 | ||
|
|
88005dbe09 | ||
|
|
88acd8190a | ||
|
|
72963bc9fb | ||
|
|
6a552cd7d1 | ||
|
|
c40b9738d1 | ||
|
|
84a64f9640 | ||
|
|
e4c06432a0 | ||
|
|
f58d6038c7 | ||
|
|
f270c52c00 | ||
|
|
e6ea85a193 | ||
|
|
17f408681c | ||
|
|
fcf6f5f384 | ||
|
|
d98c49e266 | ||
|
|
79213e7194 | ||
|
|
bc1f7040da | ||
|
|
f157c2da7f | ||
|
|
33b18fb837 | ||
|
|
1f8a6b0668 | ||
|
|
85a971323a | ||
|
|
f1b626a182 | ||
|
|
cc043316ee | ||
|
|
c656436d09 | ||
|
|
250e66819b | ||
|
|
3e4cc3b3d6 | ||
|
|
f1950d479e | ||
|
|
00686fcccf | ||
|
|
4fe8ef2b23 | ||
|
|
baddc76961 | ||
|
|
de4140aaac | ||
|
|
66aa772f4a | ||
|
|
f745cfaab3 | ||
|
|
8640b4a1a0 | ||
|
|
5e87706055 | ||
|
|
0d765d6583 | ||
|
|
2a924d8d32 | ||
|
|
04d2a20945 | ||
|
|
4077d906d1 | ||
|
|
7e3fbbba62 | ||
|
|
3db9a17c6a | ||
|
|
327babbfa2 | ||
|
|
0a1acb3f9b | ||
|
|
a2e27b9e00 | ||
|
|
a8ad93823a | ||
|
|
5eb790e54d | ||
|
|
c44ae96e09 | ||
|
|
d540bf4d16 | ||
|
|
ab6f5daec3 | ||
|
|
d7a7ef097b | ||
|
|
8f746196ab | ||
|
|
eb1ed0bdd0 | ||
|
|
37ab71cb7c | ||
|
|
74720a840d | ||
|
|
923f83cafb | ||
|
|
2faaf5f186 | ||
|
|
ef8d9c7eb0 | ||
|
|
a464c763d0 | ||
|
|
d4d1e571d3 | ||
|
|
92e85e32a2 | ||
|
|
ff1b01e5ca | ||
|
|
327f25c568 | ||
|
|
00a1324c52 | ||
|
|
75b9df942c | ||
|
|
946b390037 | ||
|
|
3a1e1e23f5 | ||
|
|
d9ea465102 | ||
|
|
3bc7f061eb | ||
|
|
0bc07d38b2 | ||
|
|
79f6d6d0f0 | ||
|
|
782e41098d | ||
|
|
0225fddf6d | ||
|
|
be3e08018e | ||
|
|
c9204eed3f | ||
|
|
edb6a0ebe2 | ||
|
|
826b507b77 | ||
|
|
8ad8f47c6b | ||
|
|
5944777a13 | ||
|
|
05a1b0d64e | ||
|
|
4d62958645 | ||
|
|
610a8b2df6 | ||
|
|
5b8bb41598 | ||
|
|
9e16d955ae | ||
|
|
197bb0509a | ||
|
|
5536aeb829 | ||
|
|
d629fb2dbd | ||
|
|
10c01574d2 | ||
|
|
cfad20c8e1 | ||
|
|
0ea375b4fc | ||
|
|
71fce1b4c5 | ||
|
|
db60065389 | ||
|
|
d3a765a532 | ||
|
|
fd4be0ca59 | ||
|
|
267a81b792 | ||
|
|
1615beadd1 | ||
|
|
a3e5c3de72 | ||
|
|
267b1b7303 | ||
|
|
c902caed24 | ||
|
|
662666e1a4 | ||
|
|
394f245e33 | ||
|
|
89da952b15 | ||
|
|
d927b8c2c2 | ||
|
|
6867c4568c | ||
|
|
e0e572a8b4 | ||
|
|
3c7555de36 | ||
|
|
75662aac5c | ||
|
|
e4ddcbd40a | ||
|
|
a8f390c3b7 | ||
|
|
f1b196cf2e | ||
|
|
04675ea76b | ||
|
|
8e44ad71e8 | ||
|
|
febd56c9c0 | ||
|
|
0d3649853a | ||
|
|
beed67567a | ||
|
|
0fe0803374 | ||
|
|
5fd7aca3d9 | ||
|
|
348fecddf7 | ||
|
|
b333449d84 | ||
|
|
87a97c2889 | ||
|
|
790147e42d | ||
|
|
3a93abaa7f | ||
|
|
1049d951d9 | ||
|
|
c3bdac5271 | ||
|
|
9bcba0b80d | ||
|
|
1529a2f12b | ||
|
|
b41b6da40e | ||
|
|
4285cbaeb2 | ||
|
|
26fd7c5498 | ||
|
|
6ec4e4b965 | ||
|
|
e3a20a351d | ||
|
|
9b8f7be98f | ||
|
|
61f5442e3b | ||
|
|
c5acd31da4 | ||
|
|
49fde7654e | ||
|
|
05338531ed | ||
|
|
eb4d906814 | ||
|
|
2a96a59deb | ||
|
|
f571da5154 | ||
|
|
ffad9abeef | ||
|
|
e8df81d78a | ||
|
|
ed19a96801 | ||
|
|
6d27e30b88 | ||
|
|
52aa1a2d91 | ||
|
|
ddbd816f6d | ||
|
|
00940c2b31 | ||
|
|
708ec64893 | ||
|
|
d0dd2d8203 | ||
|
|
faa921ac27 | ||
|
|
f2a99c7b01 | ||
|
|
b6ea9df444 | ||
|
|
e6cde5862d | ||
|
|
dec927bf9a | ||
|
|
ae41471c74 | ||
|
|
843d9d2700 | ||
|
|
475fd38be5 | ||
|
|
b88e4a35f8 | ||
|
|
c82f3783f0 | ||
|
|
bf99f9d08d | ||
|
|
f30c3869b6 | ||
|
|
3b32e4c018 | ||
|
|
e0669e9a9f | ||
|
|
95b1488aed | ||
|
|
897a97d415 | ||
|
|
1d71f617c2 | ||
|
|
1ca5789112 | ||
|
|
70ec8a3891 | ||
|
|
2dfa9d2e77 | ||
|
|
29a5a13dd9 | ||
|
|
7a3494ebd9 | ||
|
|
915bf29eaf | ||
|
|
dad4837b50 | ||
|
|
8fa8c687e9 | ||
|
|
aff54f5cf7 | ||
|
|
fa0336a404 | ||
|
|
7ccea9ff7e | ||
|
|
c2e4f862bc | ||
|
|
36bda117a6 | ||
|
|
08838770e9 | ||
|
|
137a7950ff | ||
|
|
e3980a14a2 | ||
|
|
ca9f48d019 | ||
|
|
e83e6b0f8f | ||
|
|
7d18329c18 | ||
|
|
c6fa60f28c | ||
|
|
3ab7ebe5e6 | ||
|
|
48e875714b | ||
|
|
5ba93ed927 | ||
|
|
9974102f1a | ||
|
|
ba27e09179 | ||
|
|
90066eee0c | ||
|
|
53c8827a52 | ||
|
|
3bb6f0ca65 | ||
|
|
6e5eb6b963 | ||
|
|
7bea0d0eb2 | ||
|
|
5a07a54544 | ||
|
|
684508b7ea | ||
|
|
ab72fd97b9 | ||
|
|
8486415249 | ||
|
|
6a74b84b8c | ||
|
|
999be3e0a7 | ||
|
|
a656b55526 | ||
|
|
dabb1451e9 | ||
|
|
cde00650ca | ||
|
|
6b96bea480 | ||
|
|
a731bfdfaf | ||
|
|
0ee153d6bc | ||
|
|
cb89b903fd | ||
|
|
a93e2e05c5 | ||
|
|
05ad6da7e6 | ||
|
|
0d3ea9626c | ||
|
|
b8b83c2ec8 | ||
|
|
d05dfae1d7 | ||
|
|
d0fcd4a13a | ||
|
|
b02adeccc1 | ||
|
|
b3f110b7a5 | ||
|
|
daf0ba67a4 | ||
|
|
cf3499f0e4 | ||
|
|
a72cbaf243 | ||
|
|
9ea2811aa3 | ||
|
|
0abef7396f | ||
|
|
101d9e85ef | ||
|
|
7a3be45efd | ||
|
|
f4d92eed18 | ||
|
|
db6f2cba75 |
@@ -0,0 +1,41 @@
|
||||
|
||||
name: H2Database
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '10 1 * * *'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
java_version: [11]
|
||||
os: [ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: ${{ matrix.java_version }}
|
||||
distribution: 'zulu'
|
||||
- name: Maven cache
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: maven-cache
|
||||
with:
|
||||
path:
|
||||
~/.m2
|
||||
key: build-${{ env.cache-name }}
|
||||
- name: Maven version
|
||||
run: mvn --version
|
||||
- name: H2Database
|
||||
run: mvn clean package
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
name: ebean EA
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '39 6 * * 1,3,5'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
java_version: [17,18,19,loom,valhalla,metropolis,panama]
|
||||
os: [ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Java
|
||||
uses: oracle-actions/setup-java@v1
|
||||
with:
|
||||
website: jdk.java.net
|
||||
release: ${{ matrix.java_version }}
|
||||
- name: Maven cache
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: maven-cache
|
||||
with:
|
||||
path:
|
||||
~/.m2
|
||||
key: build-${{ env.cache-name }}
|
||||
- name: Build with Maven
|
||||
run: mvn package
|
||||
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
path:
|
||||
~/.m2
|
||||
key: build-${{ env.cache-name }}
|
||||
- name: h2
|
||||
- name: h2database
|
||||
run: mvn clean test
|
||||
- name: postgres
|
||||
run: mvn clean test -Dprops.file=testconfig/ebean-postgres.properties
|
||||
@@ -39,13 +39,11 @@ jobs:
|
||||
run: mvn clean test -Dprops.file=testconfig/ebean-mysql.properties
|
||||
- name: mariadb
|
||||
run: mvn clean test -Dprops.file=testconfig/ebean-mariadb.properties
|
||||
- name: mariadb
|
||||
run: mvn clean test -Dprops.file=testconfig/ebean-mariadb.properties
|
||||
- name: sqlserver
|
||||
run: mvn clean test -Dprops.file=testconfig/ebean-sqlserver17.properties
|
||||
- name: yugabyte
|
||||
run: mvn clean test -Dprops.file=testconfig/ebean-yugabyte.properties
|
||||
# - name: sqlserver 2019
|
||||
- name: sqlserver
|
||||
run: mvn clean test -Dprops.file=testconfig/ebean-sqlserver17.properties
|
||||
# - name: sqlserver19
|
||||
# run: mvn clean test -Dprops.file=testconfig/ebean-sqlserver19.properties
|
||||
# - name: db2
|
||||
# run: mvn clean test -Dprops.file=testconfig/ebean-db2.properties
|
||||
|
||||
@@ -34,7 +34,5 @@ jobs:
|
||||
path:
|
||||
~/.m2
|
||||
key: build-${{ env.cache-name }}
|
||||
# - name: sqlserver 2019 latest
|
||||
# run: mvn clean test -Dprops.file=testconfig/ebean-sqlserver.properties
|
||||
- name: sqlserver 2017 latest
|
||||
- name: sqlserver 2017
|
||||
run: mvn clean test -Dprops.file=testconfig/ebean-sqlserver17.properties
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2012 Authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
EbeanORM
|
||||
|
||||
Copyright 2012 Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -4,10 +4,21 @@
|
||||
[](https://github.com/ebean-orm/ebean/actions/workflows/multi-jdk-build.yml)
|
||||
[](https://github.com/ebean-orm/ebean/actions/workflows/jdk-18-ea.yml)
|
||||
|
||||
[](https://github.com/ebean-orm/ebean/actions/workflows/h2database.yml)
|
||||
[](https://github.com/ebean-orm/ebean/actions/workflows/postgres.yml)
|
||||
[](https://github.com/ebean-orm/ebean/actions/workflows/mysql.yml)
|
||||
[](https://github.com/ebean-orm/ebean/actions/workflows/mariadb.yml)
|
||||
[](https://github.com/ebean-orm/ebean/actions/workflows/sqlserver.yml)
|
||||
[](https://github.com/ebean-orm/ebean/actions/workflows/yugabyte.yml)
|
||||
|
||||
|
||||
#### Builds against EA (Early Access) versions of Java (19, Loom, panama etc)
|
||||
|
||||
[](https://github.com/ebean-orm/ebean/actions/workflows/jdk-ea.yml)
|
||||
[](https://github.com/ebean-orm/ebean-datasource/actions/workflows/jdk-ea.yml)
|
||||
[](https://github.com/ebean-orm/ebean-migration/actions/workflows/jdk-ea.yml)
|
||||
[](https://github.com/ebean-orm/ebean-test-docker/actions/workflows/jdk-ea.yml)
|
||||
|
||||
|
||||
# Sponsors
|
||||
<table>
|
||||
@@ -37,15 +48,15 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
# Need help?
|
||||
## Need help?
|
||||
Post questions or issues to the Ebean google group - https://groups.google.com/forum/#!forum/ebean
|
||||
|
||||
# Documentation
|
||||
## Documentation
|
||||
Goto [https://ebean.io/docs/](https://ebean.io/docs/)
|
||||
|
||||
|
||||
## Maven central links:
|
||||
[Maven central - ebean](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22io.ebean%22%20AND%20a%3A%22ebean%22 "maven central ebean")
|
||||
## Maven central
|
||||
[Maven central - io.ebean](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22io.ebean%22%20)
|
||||
|
||||
|
||||
[Maven central - all related projects](http://search.maven.org/#search%7Cga%7C1%7Cebean "maven central all related projects")
|
||||
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</parent>
|
||||
|
||||
<name>ebean api</name>
|
||||
@@ -49,7 +49,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-annotation</artifactId>
|
||||
<version>7.6</version>
|
||||
<version>7.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -106,7 +106,7 @@
|
||||
<dependency>
|
||||
<groupId>io.avaje</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>1.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ public interface Database {
|
||||
* Create a new instance of T that is an EntityBean.
|
||||
* <p>
|
||||
* Useful if you use BeanPostConstructListeners or @PostConstruct Annotations.
|
||||
* In this case you should not use "new Bean...()". Making all bean construtors protected
|
||||
* In this case you should not use "new Bean...()". Making all bean constructors protected
|
||||
* could be a good idea here.
|
||||
* </p>
|
||||
*/
|
||||
|
||||
@@ -246,6 +246,16 @@ public interface SqlQuery extends Serializable, CancelableQuery {
|
||||
*/
|
||||
SqlQuery setParameter(Object value);
|
||||
|
||||
/**
|
||||
* Set a null parameter by position.
|
||||
*/
|
||||
SqlQuery setNullParameter(int position, int jdbcType);
|
||||
|
||||
/**
|
||||
* Set a null parameter by name.
|
||||
*/
|
||||
SqlQuery setNullParameter(String name, int jdbcType);
|
||||
|
||||
/**
|
||||
* Bind the parameter by its index position (1 based like JDBC).
|
||||
* <p>
|
||||
|
||||
@@ -98,4 +98,14 @@ public class Version<T> {
|
||||
public Map<String, ValuePair> getDiff() {
|
||||
return diff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Version{" +
|
||||
"bean=" + bean +
|
||||
", start=" + start +
|
||||
", end=" + end +
|
||||
", diff=" + diff +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ public final class EntityBeanIntercept implements Serializable {
|
||||
* Return true if the entity should be updated.
|
||||
*/
|
||||
public boolean isUpdate() {
|
||||
return forceUpdate || state == STATE_LOADED;
|
||||
return forceUpdate || state == STATE_LOADED || state == STATE_REFERENCE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -829,7 +829,7 @@ public final class EntityBeanIntercept implements Serializable {
|
||||
/**
|
||||
* Load the bean when it is a reference.
|
||||
*/
|
||||
protected void loadBean(int loadProperty) {
|
||||
void loadBean(int loadProperty) {
|
||||
lock.lock();
|
||||
try {
|
||||
if (beanLoader == null) {
|
||||
@@ -886,7 +886,7 @@ public final class EntityBeanIntercept implements Serializable {
|
||||
* Helper method to check if two objects are equal.
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
protected static boolean notEqual(Object obj1, Object obj2) {
|
||||
static boolean notEqual(Object obj1, Object obj2) {
|
||||
if (obj1 == null) {
|
||||
return (obj2 != null);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
try {
|
||||
if (set == null) {
|
||||
if (!disableLazyLoad && modifyListening) {
|
||||
lazyLoadCollection(true);
|
||||
lazyLoadCollection(false);
|
||||
} else {
|
||||
set = new LinkedHashSet<>();
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
|
||||
if (disableLazyLoad) {
|
||||
set = new LinkedHashSet<>();
|
||||
} else {
|
||||
lazyLoadCollection(true);
|
||||
lazyLoadCollection(false);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package io.ebean.config;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* BackgroundExecutorWrapper that can be used to wrap tasks that are sent to background (i.e. another thread).
|
||||
* It should copy all necessary thread-local variables. See {@link MdcBackgroundExecutorWrapper} for implementation details.
|
||||
*
|
||||
* @author Roland Praml, FOCONIS AG
|
||||
*/
|
||||
public interface BackgroundExecutorWrapper {
|
||||
|
||||
/**
|
||||
* Wrap the task with MDC context if defined.
|
||||
*/
|
||||
<T> Callable<T> wrap(Callable<T> task);
|
||||
|
||||
/**
|
||||
* Wrap the task with MDC context if defined.
|
||||
*/
|
||||
Runnable wrap(Runnable task);
|
||||
|
||||
/**
|
||||
* Combines two wrappers by nesting them.
|
||||
*/
|
||||
default BackgroundExecutorWrapper with(BackgroundExecutorWrapper inner) {
|
||||
return new BackgroundExecutorWrapper() {
|
||||
|
||||
@Override
|
||||
public Runnable wrap(Runnable task) {
|
||||
return BackgroundExecutorWrapper.this.wrap(inner.wrap(task));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Callable<T> wrap(Callable<T> task) {
|
||||
return BackgroundExecutorWrapper.this.wrap(inner.wrap(task));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -445,6 +445,7 @@ public class DatabaseConfig {
|
||||
|
||||
private int backgroundExecutorSchedulePoolSize = 1;
|
||||
private int backgroundExecutorShutdownSecs = 30;
|
||||
private BackgroundExecutorWrapper backgroundExecutorWrapper = new MdcBackgroundExecutorWrapper();
|
||||
|
||||
// defaults for the L2 bean caching
|
||||
|
||||
@@ -1463,6 +1464,20 @@ public class DatabaseConfig {
|
||||
this.backgroundExecutorShutdownSecs = backgroundExecutorShutdownSecs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the background executor wrapper.
|
||||
*/
|
||||
public BackgroundExecutorWrapper getBackgroundExecutorWrapper() {
|
||||
return backgroundExecutorWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the background executor wrapper. The wrapper is used when a task is sent to background and should copy the thread-locals.
|
||||
*/
|
||||
public void setBackgroundExecutorWrapper(BackgroundExecutorWrapper backgroundExecutorWrapper) {
|
||||
this.backgroundExecutorWrapper = backgroundExecutorWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the L2 cache default max size.
|
||||
*/
|
||||
@@ -2884,6 +2899,7 @@ public class DatabaseConfig {
|
||||
|
||||
backgroundExecutorSchedulePoolSize = p.getInt("backgroundExecutorSchedulePoolSize", backgroundExecutorSchedulePoolSize);
|
||||
backgroundExecutorShutdownSecs = p.getInt("backgroundExecutorShutdownSecs", backgroundExecutorShutdownSecs);
|
||||
backgroundExecutorWrapper = p.createInstance(BackgroundExecutorWrapper.class, "backgroundExecutorWrapper", backgroundExecutorWrapper);
|
||||
disableClasspathSearch = p.getBoolean("disableClasspathSearch", disableClasspathSearch);
|
||||
currentUserProvider = p.createInstance(CurrentUserProvider.class, "currentUserProvider", currentUserProvider);
|
||||
databasePlatform = p.createInstance(DatabasePlatform.class, "databasePlatform", databasePlatform);
|
||||
|
||||
@@ -184,17 +184,4 @@ public class DbConstraintNaming {
|
||||
return normalise.normaliseColumn(tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower case the table name checking for quoted identifiers.
|
||||
*/
|
||||
public String lowerTableName(String tableName) {
|
||||
return normalise.lowerTableName(tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower case the column name checking for quoted identifiers.
|
||||
*/
|
||||
public String lowerColumnName(String name) {
|
||||
return normalise.lowerColumnName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,53 +55,19 @@ public class DbConstraintNormalise {
|
||||
return value.replace("(","").replace(")","");
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower case the table name checking for quoted identifiers.
|
||||
*/
|
||||
public String lowerTableName(String tableName) {
|
||||
if (lowerCaseTables && notQuoted(tableName)) {
|
||||
return tableName.toLowerCase();
|
||||
}
|
||||
return tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower case the column name checking for quoted identifiers.
|
||||
*/
|
||||
public String lowerColumnName(String name) {
|
||||
if (lowerCaseColumns && notQuoted(name)) {
|
||||
return name.toLowerCase();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim off the platform quoted identifier quotes like [ ' and ".
|
||||
*/
|
||||
public boolean notQuoted(String tableName) {
|
||||
public String trimQuotes(String identifier) {
|
||||
|
||||
// remove quoted identifier characters
|
||||
for (String quotedIdentifier : quotedIdentifiers) {
|
||||
if (tableName.contains(quotedIdentifier)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim off the platform quoted identifier quotes like [ ' and ".
|
||||
*/
|
||||
public String trimQuotes(String tableName) {
|
||||
|
||||
if (tableName == null) {
|
||||
if (identifier == null) {
|
||||
return "";
|
||||
}
|
||||
// remove quoted identifier characters
|
||||
for (String quotedIdentifier : quotedIdentifiers) {
|
||||
tableName = tableName.replace(quotedIdentifier, "");
|
||||
identifier = identifier.replace(quotedIdentifier, "");
|
||||
}
|
||||
return tableName;
|
||||
return identifier;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package io.ebean.config;
|
||||
|
||||
import org.slf4j.MDC;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Propagates MDC context for tasks executed in the background.
|
||||
*/
|
||||
public final class MdcBackgroundExecutorWrapper implements BackgroundExecutorWrapper {
|
||||
|
||||
/**
|
||||
* Wrap the task with MDC context if defined.
|
||||
*/
|
||||
@Override
|
||||
public <T> Callable<T> wrap(Callable<T> task) {
|
||||
final Map<String, String> map = MDC.getCopyOfContextMap();
|
||||
if (map == null) {
|
||||
return task;
|
||||
} else {
|
||||
return () -> {
|
||||
MDC.setContextMap(map);
|
||||
try {
|
||||
return task.call();
|
||||
} finally {
|
||||
MDC.clear();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the task with MDC context if defined.
|
||||
*/
|
||||
@Override
|
||||
public Runnable wrap(Runnable task) {
|
||||
final Map<String, String> map = MDC.getCopyOfContextMap();
|
||||
if (map == null) {
|
||||
return task;
|
||||
} else {
|
||||
return () -> {
|
||||
MDC.setContextMap(map);
|
||||
try {
|
||||
task.run();
|
||||
} finally {
|
||||
MDC.clear();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,7 +165,7 @@ public class DatabasePlatform {
|
||||
* want to use quoted identifiers for. The backticks get converted to the
|
||||
* appropriate characters in convertQuotedIdentifiers
|
||||
*/
|
||||
private static final char BACK_TICK = '`';
|
||||
private static final char[] QUOTED_IDENTIFIERS = new char[] { '"', '\'', '[', ']', '`' };
|
||||
|
||||
/**
|
||||
* The non-escaped like clause (to stop slash being escaped on some platforms).
|
||||
@@ -606,13 +606,6 @@ public class DatabasePlatform {
|
||||
this.useMigrationStoredProcedures = useMigrationStoredProcedures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normally not needed - overridden in CockroachPlatform.
|
||||
*/
|
||||
public boolean isDdlAutoCommit() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the DB identity/sequence features for this platform.
|
||||
*
|
||||
@@ -669,8 +662,8 @@ public class DatabasePlatform {
|
||||
public String convertQuotedIdentifiers(String dbName) {
|
||||
// Ignore null values e.g. schema name or catalog
|
||||
if (dbName != null && !dbName.isEmpty()) {
|
||||
if (dbName.charAt(0) == BACK_TICK) {
|
||||
if (dbName.charAt(dbName.length() - 1) == BACK_TICK) {
|
||||
if (isQuote(dbName.charAt(0))) {
|
||||
if (isQuote(dbName.charAt(dbName.length() - 1))) {
|
||||
return openQuote + dbName.substring(1, dbName.length() - 1) + closeQuote;
|
||||
} else {
|
||||
log.error("Missing backquote on [" + dbName + "]");
|
||||
@@ -682,6 +675,15 @@ public class DatabasePlatform {
|
||||
return dbName;
|
||||
}
|
||||
|
||||
private boolean isQuote(char ch) {
|
||||
for (char identifer : QUOTED_IDENTIFIERS) {
|
||||
if (identifer == ch) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove quoted identifier quotes from the table or column name if present.
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,8 @@ public class ClickHousePlatform extends DatabasePlatform {
|
||||
//this.exceptionTranslator =
|
||||
this.nativeUuidType = true;
|
||||
this.dbDefaultValue.setNow("now()");
|
||||
this.dbDefaultValue.setFalse("0");
|
||||
this.dbDefaultValue.setTrue("1");
|
||||
|
||||
this.dbIdentity.setIdType(IdType.IDENTITY);
|
||||
this.dbIdentity.setSupportsGetGeneratedKeys(false);
|
||||
|
||||
+1
-12
@@ -11,18 +11,7 @@ public class CockroachPlatform extends PostgresPlatform {
|
||||
public CockroachPlatform() {
|
||||
super();
|
||||
this.platform = Platform.COCKROACH;
|
||||
// no like escape clause supported
|
||||
this.likeSpecialCharacters = new char[]{'%', '_'};
|
||||
this.likeClauseRaw = "like ?";
|
||||
this.likeClauseEscaped = "like ?";
|
||||
}
|
||||
|
||||
/**
|
||||
* Needs a commit after create index such that alter table add foreign key ... succeeds.
|
||||
*/
|
||||
@Override
|
||||
public boolean isDdlAutoCommit() {
|
||||
return true;
|
||||
this.historySupport = null; // not yet implemented in DDL
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.ebean.config.dbplatform.db2;
|
||||
|
||||
import io.ebean.BackgroundExecutor;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.config.dbplatform.DbPlatformType;
|
||||
@@ -37,6 +36,7 @@ public abstract class BaseDB2Platform extends DatabasePlatform {
|
||||
.addDataIntegrity("23502","23503","23504","23511","23512","23511","42917","23515")
|
||||
.build();
|
||||
|
||||
historySupport = new DB2HistorySupport();
|
||||
booleanDbType = Types.BOOLEAN;
|
||||
dbTypeMap.put(DbType.TINYINT, new DbPlatformType("smallint", false));
|
||||
dbTypeMap.put(DbType.INTEGER, new DbPlatformType("integer", false));
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package io.ebean.config.dbplatform.db2;
|
||||
|
||||
import io.ebean.config.dbplatform.DbStandardHistorySupport;
|
||||
|
||||
/**
|
||||
* DB2 based history support.
|
||||
*/
|
||||
public class DB2HistorySupport extends DbStandardHistorySupport {
|
||||
|
||||
@Override
|
||||
public String getAsOfViewSuffix(String asOfViewSuffix) {
|
||||
return " for system_time as of ?";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersionsBetweenSuffix(String asOfViewSuffix) {
|
||||
return " for system_time between ? and ?";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSysPeriodLower(String tableAlias, String sysPeriod) {
|
||||
return tableAlias + "." + sysPeriod + "_start";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSysPeriodUpper(String tableAlias, String sysPeriod) {
|
||||
return tableAlias + "." + sysPeriod + "_end";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@@ -76,7 +77,7 @@ public class H2HistoryTrigger implements Trigger {
|
||||
public void fire(Connection connection, Object[] oldRow, Object[] newRow) throws SQLException {
|
||||
if (oldRow != null) {
|
||||
// a delete or update event
|
||||
Timestamp now = new Timestamp(System.currentTimeMillis());
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
oldRow[effectEndPosition] = now;
|
||||
if (newRow != null) {
|
||||
// update event. Set the effective start timestamp to now.
|
||||
|
||||
@@ -92,4 +92,8 @@ public class HanaPlatform extends DatabasePlatform {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseMigrationStoredProcedures() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,18 @@ import io.ebean.bean.PersistenceContext;
|
||||
*/
|
||||
public interface JsonBeanReader<T> {
|
||||
|
||||
/**
|
||||
* Read the JSON into given bean. Will update existing properties.
|
||||
*/
|
||||
T read(T target);
|
||||
|
||||
/**
|
||||
* Read the JSON returning a bean.
|
||||
*/
|
||||
T read();
|
||||
|
||||
default T read() {
|
||||
return read(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new reader taking the context from the existing one but using a new JsonParser.
|
||||
*/
|
||||
|
||||
@@ -58,12 +58,60 @@ public interface JsonContext {
|
||||
*/
|
||||
<T> T toBean(Class<T> cls, JsonParser parser, JsonReadOptions options) throws JsonIOException;
|
||||
|
||||
/**
|
||||
* Read json parser input into a given Bean. <br>
|
||||
* Note: This is a kind of "update". Only properties in the json will be modified. Embedded Lists and Maps will become new
|
||||
* instances, so the object identity will not be preserved here.
|
||||
*
|
||||
* @throws JsonIOException When IOException occurs
|
||||
*/
|
||||
<T> void toBean(T target, JsonParser parser) throws JsonIOException;
|
||||
|
||||
/**
|
||||
* Read json parser input into a given Bean additionally using JsonReadOptions.<br>
|
||||
* See {@link #toBean(Class, JsonParser)} for details modified.
|
||||
*
|
||||
* @throws JsonIOException When IOException occurs
|
||||
*/
|
||||
<T> void toBean(T target, JsonParser parser, JsonReadOptions options) throws JsonIOException;
|
||||
|
||||
/**
|
||||
* Read json reader input into a given Bean.<br>
|
||||
* See {@link #toBean(Class, JsonParser)} for details
|
||||
*
|
||||
* @throws JsonIOException When IOException occurs
|
||||
*/
|
||||
<T> void toBean(T target, Reader json) throws JsonIOException;
|
||||
|
||||
/**
|
||||
* Read json reader input into a given Bean additionally using JsonReadOptions.<br>
|
||||
* See {@link #toBean(Class, JsonParser)} for details modified.
|
||||
*
|
||||
* @throws JsonIOException When IOException occurs
|
||||
*/
|
||||
<T> void toBean(T target, Reader json, JsonReadOptions options) throws JsonIOException;
|
||||
|
||||
/**
|
||||
* Read json string input into a given Bean.<br>
|
||||
* See {@link #toBean(Class, JsonParser)} for details
|
||||
*
|
||||
* @throws JsonIOException When IOException occurs
|
||||
*/
|
||||
<T> void toBean(T target, String json) throws JsonIOException;
|
||||
|
||||
/**
|
||||
* Read json string input into a given Bean additionally using JsonReadOptions.<br>
|
||||
* See {@link #toBean(Class, JsonParser)} for details
|
||||
*
|
||||
* @throws JsonIOException When IOException occurs
|
||||
*/
|
||||
<T> void toBean(T target, String json, JsonReadOptions options) throws JsonIOException;
|
||||
|
||||
/**
|
||||
* Create and return a new bean reading for the bean type given the JSON options and source.
|
||||
* <p>
|
||||
* Note that JsonOption provides an option for setting a persistence context and also enabling
|
||||
* further lazy loading. Further lazy loading requires a persistence context so if that is set
|
||||
* on then a persistence context is created if there is not one set.
|
||||
* Note that JsonOption provides an option for setting a persistence context and also enabling further lazy loading. Further lazy
|
||||
* loading requires a persistence context so if that is set on then a persistence context is created if there is not one set.
|
||||
*/
|
||||
<T> JsonBeanReader<T> createBeanReader(Class<T> cls, JsonParser parser, JsonReadOptions options) throws JsonIOException;
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ module io.ebean.api {
|
||||
|
||||
requires transitive java.sql;
|
||||
requires transitive io.avaje.config;
|
||||
requires transitive io.avaje.lang;
|
||||
requires transitive persistence.api;
|
||||
requires transitive io.ebean.annotation;
|
||||
requires transitive io.ebean.datasource.api;
|
||||
requires transitive org.slf4j;
|
||||
|
||||
requires static io.ebean.types;
|
||||
requires static io.avaje.jsr305x;
|
||||
requires static com.fasterxml.jackson.core;
|
||||
requires static javax.servlet.api;
|
||||
requires static com.h2database;
|
||||
@@ -41,6 +41,7 @@ module io.ebean.api {
|
||||
exports io.ebean.config.dbplatform.sqlanywhere;
|
||||
exports io.ebean.config.dbplatform.sqlite;
|
||||
exports io.ebean.config.dbplatform.sqlserver;
|
||||
exports io.ebean.config.dbplatform.yugabyte;
|
||||
exports io.ebean.event;
|
||||
exports io.ebean.event.readaudit;
|
||||
exports io.ebean.event.changelog;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package io.ebean;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class DbPrimaryTest {
|
||||
|
||||
@Test
|
||||
void testIsSkipPrimaryServer() {
|
||||
DbPrimary.setSkip(true);
|
||||
assertTrue(DbPrimary.isSkip());
|
||||
DbPrimary.setSkip(false);
|
||||
assertFalse(DbPrimary.isSkip());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetPrimaryServerName() {
|
||||
assertEquals("h2", DbPrimary.getDefaultServerName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLoadProperties() {
|
||||
Properties properties = DbPrimary.getProperties();
|
||||
assertFalse(properties.isEmpty());
|
||||
}
|
||||
}
|
||||
+1
-40
@@ -1,8 +1,5 @@
|
||||
package io.ebean.config.dbplatform;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.annotation.ForPlatform;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.MatchingNamingConvention;
|
||||
@@ -12,45 +9,9 @@ import io.ebean.config.dbplatform.postgres.PostgresPlatform;
|
||||
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class DatabasePlatformTest extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
@ForPlatform(Platform.H2)
|
||||
public void h2_platform() {
|
||||
final Platform platform = DB.getDefault().platform();
|
||||
assertThat(platform).isSameAs(Platform.H2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform(Platform.POSTGRES)
|
||||
public void postgres_platform() {
|
||||
final Platform platform = DB.getDefault().platform().base();
|
||||
assertThat(platform).isSameAs(Platform.POSTGRES);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform(Platform.MYSQL)
|
||||
public void mysql_platform() {
|
||||
final Platform platform = DB.getDefault().platform().base();
|
||||
assertThat(platform).isSameAs(Platform.MYSQL);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform(Platform.MARIADB)
|
||||
public void mariadb_platform() {
|
||||
final Platform platform = DB.getDefault().platform().base();
|
||||
assertThat(platform).isSameAs(Platform.MARIADB);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform(Platform.SQLSERVER)
|
||||
public void sqlserver_platform() {
|
||||
final Platform platform = DB.getDefault().platform().base();
|
||||
assertThat(platform).isSameAs(Platform.SQLSERVER);
|
||||
}
|
||||
class DatabasePlatformTest {
|
||||
|
||||
@Test
|
||||
public void convertQuotedIdentifiers_when_allQuotedIdentifier_sqlServer() {
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package io.ebean.config.dbplatform;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.sql.Types;
|
||||
@@ -13,7 +14,7 @@ public class DbPlatformTypeLookupTest {
|
||||
@Test
|
||||
public void byName() throws Exception {
|
||||
|
||||
assertEquals(lookup.byName("DECIMAL"), DbType.DECIMAL);
|
||||
Assertions.assertEquals(lookup.byName("DECIMAL"), DbType.DECIMAL);
|
||||
assertEquals(lookup.byName("Decimal"), DbType.DECIMAL);
|
||||
assertEquals(lookup.byName("decimal"), DbType.DECIMAL);
|
||||
|
||||
+1
-44
@@ -1,25 +1,12 @@
|
||||
package io.ebean.text;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.FetchPath;
|
||||
import io.ebean.Query;
|
||||
import io.ebean.test.LoggedSql;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.ResetBasicData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class PathPropertiesTests extends BaseTestCase {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PathPropertiesTests.class);
|
||||
public class PathPropertiesTests {
|
||||
|
||||
@Test
|
||||
public void test_noParentheses() {
|
||||
@@ -197,34 +184,4 @@ public class PathPropertiesTests extends BaseTestCase {
|
||||
assertFalse(root.includesPath("customer", "shippingAddress"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void example_withQueryAndJson() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
PathProperties pathProps = PathProperties.parse("id,name,billingAddress(city),shippingAddress(*))");
|
||||
|
||||
Query<Customer> query = DB.find(Customer.class)
|
||||
.where().lt("id", 2)
|
||||
.query();
|
||||
|
||||
pathProps.apply(query);
|
||||
|
||||
List<Customer> list = query.findList();
|
||||
|
||||
String asJson = DB.json().toJson(list, pathProps);
|
||||
log.info("Json: {}", asJson);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_withAllPropsQuery() {
|
||||
PathProperties root = PathProperties.parse("*,billingAddress(line1)");
|
||||
LoggedSql.start();
|
||||
Query<Customer> query = DB.find(Customer.class).apply(root);
|
||||
query.findList();
|
||||
List<String> sql = LoggedSql.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.name, t0.smallnote, t0.anniversary, t0.cretime, t0.updtime, t0.version, t0.shipping_address_id, t1.id, t1.line_1 from o_customer t0 left join o_address t1 on t1.id = t0.billing_address_id;");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package io.ebean.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
datasource.default=h2
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</parent>
|
||||
<!-- <parent>-->
|
||||
<!-- <groupId>org.avaje</groupId>-->
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<scm>
|
||||
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
|
||||
<tag>ebean-parent-12.15.0</tag>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<name>ebean autotune</name>
|
||||
@@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<dependency>
|
||||
<groupId>io.avaje</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>1.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
+15
-15
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</parent>
|
||||
|
||||
<name>ebean bom</name>
|
||||
@@ -71,88 +71,88 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core-type</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-ddl-generator</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-externalmapping-api</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-externalmapping-xml</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-autotune</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>querybean-generator</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>kotlin-querybean-generator</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-test</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-postgis</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-redis</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ebean-core-type</artifactId>
|
||||
@@ -16,7 +16,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
+9
-9
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ebean-core</artifactId>
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<scm>
|
||||
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
|
||||
<tag>ebean-parent-12.15.0</tag>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
@@ -23,7 +23,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-ddl-runner</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>${ebean-ddl-runner.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -35,25 +35,25 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-migration-auto</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>${ebean-migration-auto.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core-type</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-externalmapping-api</artifactId>
|
||||
<version>12.15.0</version>
|
||||
<version>12.16.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -136,7 +136,7 @@
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.3.2</version>
|
||||
<version>42.3.3</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
<dependency>
|
||||
<groupId>io.avaje</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>1.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ public final class BindParams implements Serializable {
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void setParameter(int position, Object value) {
|
||||
assert value != null : "use setNullParameter";
|
||||
//TODO: Review - assert value != null : "use setNullParameter";
|
||||
Param p = getParam(position);
|
||||
if (value instanceof Collection) {
|
||||
// use of postgres ANY with positioned parameter
|
||||
@@ -219,7 +219,7 @@ public final class BindParams implements Serializable {
|
||||
* Set a named In parameter that is not null.
|
||||
*/
|
||||
public Param setParameter(String name, Object value) {
|
||||
assert value != null : "use setNullParameter";
|
||||
// TODO: Review - assert value != null : "use setNullParameter";
|
||||
Param p = getParam(name);
|
||||
p.setInValue(value);
|
||||
return p;
|
||||
|
||||
@@ -35,7 +35,7 @@ public final class CacheIdLookupMany<T> implements CacheIdLookup<T> {
|
||||
@Override
|
||||
public List<T> removeHits(BeanCacheResult<T> cacheResult) {
|
||||
Set<Object> hitIds = new HashSet<>();
|
||||
List<T> beans = new ArrayList<>(hitIds.size());
|
||||
List<T> beans = new ArrayList<>();
|
||||
for (BeanCacheResult.Entry<T> hit : cacheResult.hits()) {
|
||||
hitIds.add(hit.getKey());
|
||||
beans.add(hit.getBean());
|
||||
|
||||
@@ -4,7 +4,7 @@ import io.ebean.bean.EntityBeanIntercept;
|
||||
import io.ebean.bean.PersistenceContext;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A buffer of beans for batch lazy loading and secondary query loading.
|
||||
@@ -13,7 +13,7 @@ public interface LoadBeanBuffer {
|
||||
|
||||
int batchSize();
|
||||
|
||||
List<EntityBeanIntercept> batch();
|
||||
Set<EntityBeanIntercept> batch();
|
||||
|
||||
BeanDescriptor<?> descriptor();
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.Set;
|
||||
*/
|
||||
public final class LoadBeanRequest extends LoadRequest {
|
||||
|
||||
private final List<EntityBeanIntercept> batch;
|
||||
private final Set<EntityBeanIntercept> batch;
|
||||
private final LoadBeanBuffer loadBuffer;
|
||||
private final String lazyLoadProperty;
|
||||
private final boolean loadCache;
|
||||
@@ -58,7 +58,7 @@ public final class LoadBeanRequest extends LoadRequest {
|
||||
/**
|
||||
* Return the batch of beans to actually load.
|
||||
*/
|
||||
public List<EntityBeanIntercept> batch() {
|
||||
public Set<EntityBeanIntercept> batch() {
|
||||
return batch;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,8 +97,12 @@ public final class LoadManyRequest extends LoadRequest {
|
||||
// potentially changes the joins, selected properties, cache mode
|
||||
loadContext.configureQuery(query);
|
||||
if (onlyIds) {
|
||||
// lazy loading invoked via clear() and removeAll()
|
||||
query.select(many.targetIdProperty());
|
||||
String mapKey = many.mapKey();
|
||||
if (mapKey != null) {
|
||||
query.select(mapKey);
|
||||
} else {
|
||||
query.select(many.targetIdProperty());
|
||||
}
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package io.ebeaninternal.api;
|
||||
import io.ebean.*;
|
||||
import io.ebean.bean.BeanCollectionLoader;
|
||||
import io.ebean.bean.CallOrigin;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.event.readaudit.ReadAuditLogger;
|
||||
import io.ebean.event.readaudit.ReadAuditPrepare;
|
||||
import io.ebean.meta.MetricVisitor;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.api;
|
||||
|
||||
import io.ebean.meta.QueryPlanRequest;
|
||||
import io.ebeaninternal.server.type.bindcapture.BindCapture;
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import io.ebean.event.changelog.BeanChange;
|
||||
import io.ebean.event.changelog.ChangeSet;
|
||||
import io.ebean.event.changelog.ChangeType;
|
||||
import io.ebean.text.json.JsonContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
@@ -15,8 +15,6 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
/**
|
||||
* Wraps the objects involved in executing a SQL / Relational Query.
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,6 @@ import io.avaje.classpath.scanner.ClassPathScannerFactory;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
|
||||
@@ -106,7 +106,9 @@ final class DScriptRunner implements ScriptRunner {
|
||||
try (Connection connection = obtainConnection()) {
|
||||
DdlRunner runner = new DdlRunner(useAutoCommit, scriptName, platformName);
|
||||
runner.runAll(content, connection);
|
||||
connection.commit();
|
||||
if (!connection.getAutoCommit()) {
|
||||
connection.commit();
|
||||
}
|
||||
runner.runNonTransactional(connection);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package io.ebeaninternal.server.core;
|
||||
|
||||
import io.ebean.CacheMode;
|
||||
import io.ebean.ExpressionList;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.bean.BeanCollection;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.bean.EntityBeanIntercept;
|
||||
@@ -17,6 +16,7 @@ import org.slf4j.Logger;
|
||||
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Helper to handle lazy loading and refreshing of beans.
|
||||
@@ -39,14 +39,14 @@ final class DefaultBeanLoader {
|
||||
}
|
||||
|
||||
void loadMany(BeanCollection<?> bc, boolean onlyIds) {
|
||||
loadManyInternal(bc.getOwnerBean(), bc.getPropertyName(), null, false, onlyIds);
|
||||
loadManyInternal(bc.getOwnerBean(), bc.getPropertyName(), false, onlyIds);
|
||||
}
|
||||
|
||||
void refreshMany(EntityBean parentBean, String propertyName) {
|
||||
loadManyInternal(parentBean, propertyName, null, true, false);
|
||||
loadManyInternal(parentBean, propertyName, true, false);
|
||||
}
|
||||
|
||||
private void loadManyInternal(EntityBean parentBean, String propertyName, Transaction t, boolean refresh, boolean onlyIds) {
|
||||
private void loadManyInternal(EntityBean parentBean, String propertyName, boolean refresh, boolean onlyIds) {
|
||||
EntityBeanIntercept ebi = parentBean._ebean_getIntercept();
|
||||
PersistenceContext pc = ebi.getPersistenceContext();
|
||||
BeanDescriptor<?> parentDesc = server.descriptor(parentBean.getClass());
|
||||
@@ -105,7 +105,7 @@ final class DefaultBeanLoader {
|
||||
query.setReadOnly(true);
|
||||
}
|
||||
|
||||
server.findOne(query, t);
|
||||
server.findOne(query, null);
|
||||
if (beanCollection != null) {
|
||||
if (beanCollection.checkEmptyLazyLoad()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
@@ -121,7 +121,7 @@ final class DefaultBeanLoader {
|
||||
* Load a batch of beans for +query or +lazy loading.
|
||||
*/
|
||||
void loadBean(LoadBeanRequest loadRequest) {
|
||||
List<EntityBeanIntercept> batch = loadRequest.batch();
|
||||
Set<EntityBeanIntercept> batch = loadRequest.batch();
|
||||
if (batch.isEmpty()) {
|
||||
throw new RuntimeException("Nothing in batch?");
|
||||
}
|
||||
@@ -199,7 +199,7 @@ final class DefaultBeanLoader {
|
||||
query.setLazyLoadProperty(ebi.getLazyLoadProperty());
|
||||
if (draft) {
|
||||
query.asDraft();
|
||||
} else {
|
||||
} else if (mode == SpiQuery.Mode.LAZYLOAD_BEAN) {
|
||||
query.setIncludeSoftDeletes();
|
||||
}
|
||||
if (embeddedOwnerIndex > -1) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
import io.ebean.config.BackgroundExecutorWrapper;
|
||||
import io.ebean.config.ContainerConfig;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.DatabaseConfigProvider;
|
||||
@@ -67,7 +68,8 @@ public final class DefaultContainer implements SpiContainer {
|
||||
String namePrefix = "ebean-" + config.getName();
|
||||
int schedulePoolSize = config.getBackgroundExecutorSchedulePoolSize();
|
||||
int shutdownSecs = config.getBackgroundExecutorShutdownSecs();
|
||||
return new DefaultBackgroundExecutor(schedulePoolSize, shutdownSecs, namePrefix);
|
||||
BackgroundExecutorWrapper wrapper = config.getBackgroundExecutorWrapper();
|
||||
return new DefaultBackgroundExecutor(schedulePoolSize, shutdownSecs, namePrefix, wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -373,7 +373,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
migrationRunner.setDefaultDbSchema(dbSchema);
|
||||
}
|
||||
migrationRunner.setName(config.getName());
|
||||
migrationRunner.setPlatform(config.getDatabasePlatform().getPlatform().base().name().toLowerCase());
|
||||
Platform platform = config.getDatabasePlatform().getPlatform();
|
||||
migrationRunner.setBasePlatform(platform.base().name().toLowerCase());
|
||||
migrationRunner.setPlatform(platform.name().toLowerCase());
|
||||
migrationRunner.loadProperties(config.getProperties());
|
||||
migrationRunner.run(config.getDataSource());
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ public final class InternalConfiguration {
|
||||
|
||||
private MultiValueBind createMultiValueBind(Platform platform) {
|
||||
// only Postgres at this stage
|
||||
if (platform.base() == Platform.POSTGRES || platform.base() == Platform.YUGABYTE) {
|
||||
if (platform.base() == Platform.POSTGRES || platform.base() == Platform.YUGABYTE || platform.base() == Platform.COCKROACH) {
|
||||
return new PostgresMultiValueBind();
|
||||
}
|
||||
return new MultiValueBind();
|
||||
@@ -445,6 +445,9 @@ public final class InternalConfiguration {
|
||||
*/
|
||||
private DataTimeZone initDataTimeZone() {
|
||||
String tz = config.getDataTimeZone();
|
||||
if ("NoTimeZone".equals(tz)) {
|
||||
return new NoDataTimeZone();
|
||||
}
|
||||
if (tz == null) {
|
||||
if (isMySql(getPlatform())) {
|
||||
return new MySqlDataTimeZone();
|
||||
|
||||
+20
-2
@@ -3,6 +3,7 @@ package io.ebeaninternal.server.deploy;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.bean.PersistenceContext;
|
||||
import io.ebeaninternal.server.query.SqlJoinType;
|
||||
import io.ebeaninternal.server.query.SqlTreeJoin;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@@ -60,11 +61,28 @@ final class AssocOneHelpRefInherit extends AssocOneHelp {
|
||||
return ref;
|
||||
}
|
||||
|
||||
@Override
|
||||
void appendFrom(DbSqlContext ctx, SqlJoinType joinType) {
|
||||
// add join to support the discriminator column
|
||||
String relativePrefix = ctx.getRelativePrefix(property.name);
|
||||
property.tableJoin.addJoin(joinType, relativePrefix, ctx);
|
||||
ctx.addExtraJoin(new Extra(relativePrefix, joinType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Extra join to support the discriminator column.
|
||||
*/
|
||||
final class Extra implements SqlTreeJoin {
|
||||
final String relativePrefix;
|
||||
final SqlJoinType joinType;
|
||||
Extra(String relativePrefix, SqlJoinType joinType) {
|
||||
this.relativePrefix = relativePrefix;
|
||||
this.joinType = joinType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addJoin(DbSqlContext ctx) {
|
||||
// add join to support the discriminator column *IF* join is not already present
|
||||
property.tableJoin.addJoin(joinType, relativePrefix, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -121,6 +121,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
private final boolean softDelete;
|
||||
private final String draftTable;
|
||||
private final PartitionMeta partitionMeta;
|
||||
private final TablespaceMeta tablespaceMeta;
|
||||
private final String storageEngine;
|
||||
private final String dbComment;
|
||||
private final boolean readAuditing;
|
||||
@@ -275,6 +276,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
this.dependentTables = deploy.getDependentTables();
|
||||
this.dbComment = deploy.getDbComment();
|
||||
this.partitionMeta = deploy.getPartitionMeta();
|
||||
this.tablespaceMeta = deploy.getTablespaceMeta();
|
||||
this.storageEngine = deploy.getStorageEngine();
|
||||
this.autoTunable = beanFinder == null && (entityType == EntityType.ORM || entityType == EntityType.VIEW);
|
||||
// helper object used to derive lists of properties
|
||||
@@ -1310,8 +1312,8 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
* Hit the bean cache trying to load a list/batch of entities.
|
||||
* Return the set of entities that were successfully loaded from L2 cache.
|
||||
*/
|
||||
public Set<EntityBeanIntercept> cacheBeanLoadAll(List<EntityBeanIntercept> list, PersistenceContext persistenceContext, int lazyLoadProperty, String propertyName) {
|
||||
return cacheHelp.beanCacheLoadAll(list, persistenceContext, lazyLoadProperty, propertyName);
|
||||
public Set<EntityBeanIntercept> cacheBeanLoadAll(Set<EntityBeanIntercept> batch, PersistenceContext persistenceContext, int lazyLoadProperty, String propertyName) {
|
||||
return cacheHelp.beanCacheLoadAll(batch, persistenceContext, lazyLoadProperty, propertyName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2671,6 +2673,13 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
public PartitionMeta partitionMeta() {
|
||||
return partitionMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the tablespace details of the bean.
|
||||
*/
|
||||
public TablespaceMeta tablespaceMeta() {
|
||||
return tablespaceMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the storage engine.
|
||||
@@ -3372,12 +3381,12 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
jsonHelp.jsonWriteProperties(writeJson, bean);
|
||||
}
|
||||
|
||||
public T jsonRead(SpiJsonReader jsonRead, String path) throws IOException {
|
||||
return jsonHelp.jsonRead(jsonRead, path, true);
|
||||
public T jsonRead(SpiJsonReader jsonRead, String path, T target) throws IOException {
|
||||
return jsonHelp.jsonRead(jsonRead, path, true, target);
|
||||
}
|
||||
|
||||
T jsonReadObject(SpiJsonReader jsonRead, String path) throws IOException {
|
||||
return jsonHelp.jsonRead(jsonRead, path, false);
|
||||
T jsonReadObject(SpiJsonReader jsonRead, String path, T target) throws IOException {
|
||||
return jsonHelp.jsonRead(jsonRead, path, false, target);
|
||||
}
|
||||
|
||||
public List<BeanProperty[]> uniqueProps() {
|
||||
|
||||
+2
-3
@@ -693,9 +693,9 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
/**
|
||||
* Load a batch of entities from L2 bean cache checking the lazy loaded property is loaded.
|
||||
*/
|
||||
Set<EntityBeanIntercept> beanCacheLoadAll(List<EntityBeanIntercept> list, PersistenceContext context, int lazyLoadProperty, String propertyName) {
|
||||
Set<EntityBeanIntercept> beanCacheLoadAll(Set<EntityBeanIntercept> batch, PersistenceContext context, int lazyLoadProperty, String propertyName) {
|
||||
Map<Object, EntityBeanIntercept> ebis = new HashMap<>();
|
||||
for (EntityBeanIntercept ebi : list) {
|
||||
for (EntityBeanIntercept ebi : batch) {
|
||||
ebis.put(desc.cacheKeyForBean(ebi.getOwner()), ebi);
|
||||
}
|
||||
|
||||
@@ -716,7 +716,6 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
if (beanLog.isTraceEnabled()) {
|
||||
beanLog.trace(" load {}({}) - cache miss on property({})", cacheName, key, propertyName);
|
||||
}
|
||||
iterator.remove();
|
||||
} else {
|
||||
CachedBeanDataToBean.load(desc, ebi.getOwner(), cacheData, context);
|
||||
loaded.add(ebi);
|
||||
|
||||
+4
-4
@@ -61,13 +61,13 @@ class BeanDescriptorElementEmbedded<T> extends BeanDescriptorElement<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T jsonRead(SpiJsonReader jsonRead, String path) throws IOException {
|
||||
return readJsonElement(jsonRead, path);
|
||||
public T jsonRead(SpiJsonReader jsonRead, String path, T target) throws IOException {
|
||||
return readJsonElement(jsonRead, path, target);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
T readJsonElement(SpiJsonReader jsonRead, String path) throws IOException {
|
||||
return (T)targetDescriptor.jsonRead(jsonRead, path);
|
||||
T readJsonElement(SpiJsonReader jsonRead, String path, T target) throws IOException {
|
||||
return (T)targetDescriptor.jsonRead(jsonRead, path, target);
|
||||
}
|
||||
|
||||
void writeJsonElement(SpiJsonWriter ctx, Object element) {
|
||||
|
||||
+2
-2
@@ -58,13 +58,13 @@ class BeanDescriptorElementEmbeddedMap<T> extends BeanDescriptorElementEmbedded<
|
||||
}
|
||||
if (stringKey) {
|
||||
parser.nextToken();
|
||||
Object val = readJsonElement(readJson, null);
|
||||
Object val = readJsonElement(readJson, null, null); // CHECKME: Update existing map entry here?
|
||||
add.addKeyValue(fieldName, val);
|
||||
} else {
|
||||
parser.nextFieldName();
|
||||
Object key = scalarTypeKey.jsonRead(parser);
|
||||
parser.nextFieldName();
|
||||
Object val = readJsonElement(readJson, null);
|
||||
Object val = readJsonElement(readJson, null, null); // CHECKME: Update existing map entry here?
|
||||
add.addKeyValue(key, val);
|
||||
}
|
||||
} while (true);
|
||||
|
||||
+14
-6
@@ -65,7 +65,7 @@ final class BeanDescriptorJsonHelp<T> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
T jsonRead(SpiJsonReader jsonRead, String path, boolean withInheritance) throws IOException {
|
||||
T jsonRead(SpiJsonReader jsonRead, String path, boolean withInheritance, T target) throws IOException {
|
||||
JsonParser parser = jsonRead.getParser();
|
||||
//noinspection StatementWithEmptyBody
|
||||
if (parser.getCurrentToken() == JsonToken.START_OBJECT) {
|
||||
@@ -82,7 +82,7 @@ final class BeanDescriptorJsonHelp<T> {
|
||||
}
|
||||
|
||||
if (desc.inheritInfo == null || !withInheritance) {
|
||||
return jsonReadObject(jsonRead, path);
|
||||
return jsonReadObject(jsonRead, path, target);
|
||||
}
|
||||
|
||||
ObjectNode node = jsonRead.getObjectMapper().readTree(parser);
|
||||
@@ -97,17 +97,25 @@ final class BeanDescriptorJsonHelp<T> {
|
||||
JsonNode discNode = node.get(discColumn);
|
||||
if (discNode == null || discNode.isNull()) {
|
||||
if (!desc.isAbstractType()) {
|
||||
return desc.jsonReadObject(newReader, path);
|
||||
return desc.jsonReadObject(newReader, path, target);
|
||||
}
|
||||
String msg = "Error reading inheritance discriminator - expected [" + discColumn + "] but no json key?";
|
||||
throw new JsonParseException(newParser, msg, parser.getCurrentLocation());
|
||||
}
|
||||
|
||||
return (T) inheritInfo.readType(discNode.asText()).desc().jsonReadObject(newReader, path);
|
||||
BeanDescriptor<T> inheritDesc = (BeanDescriptor<T>) inheritInfo.readType(discNode.asText()).desc();
|
||||
return inheritDesc.jsonReadObject(newReader, path, target);
|
||||
}
|
||||
|
||||
private T jsonReadObject(SpiJsonReader readJson, String path) throws IOException {
|
||||
EntityBean bean = desc.createEntityBeanForJson();
|
||||
private T jsonReadObject(SpiJsonReader readJson, String path, T target) throws IOException {
|
||||
EntityBean bean;
|
||||
if (target == null) {
|
||||
bean = desc.createEntityBeanForJson();
|
||||
} else if (desc.beanType.isInstance(target)) {
|
||||
bean = (EntityBean) target;
|
||||
} else {
|
||||
throw new ClassCastException(target.getClass().getName() + " provided, but " + desc.beanType.getClass().getName() + " expected");
|
||||
}
|
||||
return jsonReadProperties(readJson, bean, path);
|
||||
}
|
||||
|
||||
|
||||
@@ -992,6 +992,9 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
*/
|
||||
public String renderDbType(DbPlatformType dbType, boolean strict) {
|
||||
if (dbColumnDefn != null) {
|
||||
if (dbColumnDefn.endsWith(";")) {
|
||||
return dbColumnDefn + dbType.renderType(dbLength, dbScale, strict);
|
||||
}
|
||||
return dbColumnDefn;
|
||||
}
|
||||
return dbType.renderType(dbLength, dbScale, strict);
|
||||
@@ -1001,7 +1004,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
* Return the DB column default to use for DDL.
|
||||
*/
|
||||
public String dbColumnDefault() {
|
||||
return dbColumnDefn != null ? null : dbColumnDefault;
|
||||
return dbColumnDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1160,26 +1163,27 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
public boolean isLob() {
|
||||
return lob;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this <code>isLob()</code> or the type will effectively map to a lob.
|
||||
* Returns true if this <code>isLob()</code> or the type will effectively map to a lob.
|
||||
*/
|
||||
@Override
|
||||
public boolean isDbLob() {
|
||||
if (lob) {
|
||||
return true;
|
||||
}
|
||||
switch (dbType) {
|
||||
case DbPlatformType.JSON:
|
||||
case DbPlatformType.JSONB:
|
||||
return dbLength == 0; // must be analog to DbPlatformTypeMapping.lookup
|
||||
case DbPlatformType.JSONBlob:
|
||||
case DbPlatformType.JSONClob:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case DbPlatformType.JSON:
|
||||
case DbPlatformType.JSONB:
|
||||
return dbLength == 0; // must be analog to DbPlatformTypeMapping.lookup
|
||||
case DbPlatformType.JSONBlob:
|
||||
case DbPlatformType.JSONClob:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean isLobType(int type) {
|
||||
switch (type) {
|
||||
case Types.CLOB:
|
||||
|
||||
@@ -1016,7 +1016,8 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
BeanCollection<?> collection = createEmpty(parentBean);
|
||||
BeanCollectionAdd add = beanCollectionAdd(collection);
|
||||
do {
|
||||
EntityBean detailBean = (EntityBean) targetDescriptor.jsonRead(readJson, name);
|
||||
// CHECKME: Update existing list entry here?
|
||||
EntityBean detailBean = (EntityBean) targetDescriptor.jsonRead(readJson, name, null);
|
||||
if (detailBean == null) {
|
||||
// read the entire array
|
||||
break;
|
||||
|
||||
@@ -783,7 +783,8 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
@Override
|
||||
public void jsonRead(SpiJsonReader readJson, EntityBean bean) throws IOException {
|
||||
if (jsonDeserialize && targetDescriptor != null) {
|
||||
T assocBean = targetDescriptor.jsonRead(readJson, name);
|
||||
T target = (T) value(bean);
|
||||
T assocBean = targetDescriptor.jsonRead(readJson, name, target);
|
||||
setValue(bean, assocBean);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import io.ebeaninternal.server.query.SqlJoinType;
|
||||
import io.ebeaninternal.server.query.SqlTreeJoin;
|
||||
|
||||
/**
|
||||
* Used to provide context during sql construction.
|
||||
@@ -133,4 +134,13 @@ public interface DbSqlContext {
|
||||
*/
|
||||
void appendFromForUpdate();
|
||||
|
||||
/**
|
||||
* Delay adding an extra join to support inheritance discriminator in projection (IF required).
|
||||
*/
|
||||
void addExtraJoin(SqlTreeJoin treeJoin);
|
||||
|
||||
/**
|
||||
* Add extra joins *IF* required to support inheritance discriminator in projection.
|
||||
*/
|
||||
void flushExtraJoins();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Meta data for table spaces. If table space is configured, tablespaceName, indexTablespace, lobTablespace is never null;
|
||||
*
|
||||
* @author Noemi Szemenyei, FOCONIS AG
|
||||
*
|
||||
*/
|
||||
public final class TablespaceMeta {
|
||||
|
||||
private final String tablespaceName;
|
||||
private final String indexTablespace;
|
||||
private final String lobTablespace;
|
||||
|
||||
public TablespaceMeta(String tablespaceName, String indexTablespace, String lobTablespace) {
|
||||
this.tablespaceName = tablespaceName;
|
||||
this.indexTablespace = indexTablespace;
|
||||
this.lobTablespace = lobTablespace;
|
||||
}
|
||||
|
||||
public String getTablespaceName() {
|
||||
return tablespaceName;
|
||||
}
|
||||
|
||||
public String getIndexTablespace() {
|
||||
return indexTablespace;
|
||||
}
|
||||
|
||||
public String getLobTablespace() {
|
||||
return lobTablespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(indexTablespace, tablespaceName, lobTablespace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TablespaceMeta other = (TablespaceMeta) obj;
|
||||
return Objects.equals(indexTablespace, other.indexTablespace)
|
||||
&& Objects.equals(tablespaceName, other.tablespaceName)
|
||||
&& Objects.equals(lobTablespace, other.lobTablespace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "tablespace=" + tablespaceName + ", indexTablespace=" + indexTablespace + ", lobTablespace=" + lobTablespace;
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -32,6 +32,7 @@ import io.ebeaninternal.server.deploy.IndexDefinition;
|
||||
import io.ebeaninternal.server.deploy.InheritInfo;
|
||||
import io.ebeaninternal.server.deploy.PartitionMeta;
|
||||
import io.ebeaninternal.server.deploy.TableJoin;
|
||||
import io.ebeaninternal.server.deploy.TablespaceMeta;
|
||||
import io.ebeaninternal.server.deploy.parse.DeployBeanInfo;
|
||||
import io.ebeaninternal.server.idgen.UuidV1IdGenerator;
|
||||
import io.ebeaninternal.server.idgen.UuidV1RndIdGenerator;
|
||||
@@ -135,6 +136,7 @@ public class DeployBeanDescriptor<T> {
|
||||
private ChangeLogFilter changeLogFilter;
|
||||
private String dbComment;
|
||||
private PartitionMeta partitionMeta;
|
||||
private TablespaceMeta tablespaceMeta;
|
||||
/**
|
||||
* One of NONE, INDEX or EMBEDDED.
|
||||
*/
|
||||
@@ -252,6 +254,14 @@ public class DeployBeanDescriptor<T> {
|
||||
}
|
||||
return partitionMeta;
|
||||
}
|
||||
|
||||
public void setTablespaceMeta(TablespaceMeta tablespaceMeta) {
|
||||
this.tablespaceMeta = tablespaceMeta;
|
||||
}
|
||||
|
||||
public TablespaceMeta getTablespaceMeta() {
|
||||
return tablespaceMeta;
|
||||
}
|
||||
|
||||
public void setDraftable() {
|
||||
draftable = true;
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
package io.ebeaninternal.server.deploy.parse;
|
||||
|
||||
import io.ebean.annotation.Aggregation;
|
||||
import io.ebean.annotation.Avg;
|
||||
import io.ebean.annotation.DbMigration;
|
||||
import io.ebean.annotation.Index;
|
||||
import io.ebean.annotation.Indices;
|
||||
import io.ebean.annotation.Max;
|
||||
import io.ebean.annotation.Min;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.annotation.Sum;
|
||||
import io.ebean.config.NamingConvention;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.util.AnnotationUtil;
|
||||
@@ -20,7 +15,6 @@ import javax.persistence.JoinColumns;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import io.ebean.annotation.Index;
|
||||
import io.ebean.annotation.InvalidateQueryCache;
|
||||
import io.ebean.annotation.ReadAudit;
|
||||
import io.ebean.annotation.StorageEngine;
|
||||
import io.ebean.annotation.Tablespace;
|
||||
import io.ebean.annotation.View;
|
||||
import io.ebean.config.TableName;
|
||||
import io.ebeaninternal.api.CoreLog;
|
||||
@@ -19,6 +20,7 @@ import io.ebeaninternal.server.deploy.BeanDescriptor.EntityType;
|
||||
import io.ebeaninternal.server.deploy.IndexDefinition;
|
||||
import io.ebeaninternal.server.deploy.InheritInfo;
|
||||
import io.ebeaninternal.server.deploy.PartitionMeta;
|
||||
import io.ebeaninternal.server.deploy.TablespaceMeta;
|
||||
import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
|
||||
|
||||
import javax.persistence.AttributeOverride;
|
||||
@@ -154,6 +156,18 @@ final class AnnotationClass extends AnnotationParser {
|
||||
if (partition != null) {
|
||||
descriptor.setPartitionMeta(new PartitionMeta(partition.mode(), partition.property()));
|
||||
}
|
||||
Tablespace tablespace = typeGet(cls, Tablespace.class);
|
||||
if (tablespace != null) {
|
||||
String indexTs = tablespace.index();
|
||||
if("".equals(indexTs)) {
|
||||
indexTs = tablespace.value();
|
||||
}
|
||||
String lobTs = tablespace.lob();
|
||||
if("".equals(lobTs)) {
|
||||
lobTs = tablespace.value();
|
||||
}
|
||||
descriptor.setTablespaceMeta(new TablespaceMeta(tablespace.value(), indexTs, lobTs));
|
||||
}
|
||||
Draftable draftable = typeGet(cls, Draftable.class);
|
||||
if (draftable != null) {
|
||||
descriptor.setDraftable();
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package io.ebeaninternal.server.executor;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/**
|
||||
* A "CachedThreadPool" based on Daemon threads.
|
||||
* <p>
|
||||
* The Threads are created as needed and once idle live for 60 seconds.
|
||||
*/
|
||||
final class DaemonExecutorService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DaemonExecutorService.class);
|
||||
|
||||
private final ReentrantLock lock = new ReentrantLock(false);
|
||||
private final String namePrefix;
|
||||
private final int shutdownWaitSeconds;
|
||||
private final ExecutorService service;
|
||||
|
||||
DaemonExecutorService(int shutdownWaitSeconds, String namePrefix) {
|
||||
this.service = Executors.newCachedThreadPool(new DaemonThreadFactory(namePrefix));
|
||||
this.shutdownWaitSeconds = shutdownWaitSeconds;
|
||||
this.namePrefix = namePrefix;
|
||||
}
|
||||
|
||||
<T> Future<T> submit(Callable<T> task) {
|
||||
return service.submit(task);
|
||||
}
|
||||
|
||||
Future<?> submit(Runnable task) {
|
||||
return service.submit(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown this thread pool nicely if possible.
|
||||
* <p>
|
||||
* This will wait a maximum of 20 seconds before terminating any threads still working.
|
||||
*/
|
||||
void shutdown() {
|
||||
lock.lock();
|
||||
try {
|
||||
if (service.isShutdown()) {
|
||||
logger.debug("DaemonExecutorService[{}] already shut down", namePrefix);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
logger.debug("DaemonExecutorService[{}] shutting down...", namePrefix);
|
||||
service.shutdown();
|
||||
if (!service.awaitTermination(shutdownWaitSeconds, TimeUnit.SECONDS)) {
|
||||
logger.info("DaemonExecutorService[{}] shut down timeout exceeded. Terminating running threads.", namePrefix);
|
||||
service.shutdownNow();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during shutdown of DaemonThreadPool[" + namePrefix + "]", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+69
-41
@@ -1,15 +1,13 @@
|
||||
package io.ebeaninternal.server.executor;
|
||||
|
||||
import io.avaje.lang.NonNullApi;
|
||||
import io.ebean.config.BackgroundExecutorWrapper;
|
||||
import io.ebeaninternal.api.SpiBackgroundExecutor;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The default implementation of the BackgroundExecutor.
|
||||
@@ -17,56 +15,81 @@ import java.util.concurrent.TimeUnit;
|
||||
@NonNullApi
|
||||
public final class DefaultBackgroundExecutor implements SpiBackgroundExecutor {
|
||||
|
||||
private final ScheduledExecutorService executor;
|
||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.BackgroundExecutor");
|
||||
|
||||
private final ScheduledExecutorService schedulePool;
|
||||
private final DaemonExecutorService pool;
|
||||
private final BackgroundExecutorWrapper wrapper;
|
||||
|
||||
/**
|
||||
* Construct the default implementation of BackgroundExecutor.
|
||||
*/
|
||||
public DefaultBackgroundExecutor(int schedulePoolSize, int shutdownWaitSeconds, String namePrefix) {
|
||||
this.executor = new DaemonScheduleThreadPool(schedulePoolSize, shutdownWaitSeconds, namePrefix);
|
||||
public DefaultBackgroundExecutor(int schedulePoolSize, int shutdownWaitSeconds, String namePrefix, BackgroundExecutorWrapper wrapper) {
|
||||
this.schedulePool = new DaemonScheduleThreadPool(schedulePoolSize, shutdownWaitSeconds, namePrefix + "-periodic-");
|
||||
this.pool = new DaemonExecutorService(shutdownWaitSeconds, namePrefix);
|
||||
this.wrapper = wrapper;
|
||||
log.debug("Created backgroundExecutor {} (schedulePoolSize={}, shutdownWaitSeconds={})", namePrefix, schedulePoolSize, shutdownWaitSeconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the task with MDC context if defined.
|
||||
*/
|
||||
<T> Callable<T> wrapMDC(Callable<T> task) {
|
||||
final Map<String, String> map = MDC.getCopyOfContextMap();
|
||||
if (map == null) {
|
||||
<T> Callable<T> wrap(Callable<T> task) {
|
||||
if (wrapper == null) {
|
||||
return task;
|
||||
} else {
|
||||
return () -> {
|
||||
MDC.setContextMap(map);
|
||||
try {
|
||||
return task.call();
|
||||
} finally {
|
||||
MDC.clear();
|
||||
}
|
||||
};
|
||||
return wrapper.wrap(task);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the task with MDC context if defined.
|
||||
*/
|
||||
Runnable wrapMDC(Runnable task) {
|
||||
final Map<String, String> map = MDC.getCopyOfContextMap();
|
||||
if (map == null) {
|
||||
Runnable wrap(Runnable task) {
|
||||
if (wrapper == null) {
|
||||
return task;
|
||||
} else {
|
||||
return () -> {
|
||||
MDC.setContextMap(map);
|
||||
try {
|
||||
return wrapper.wrap(task);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decorates a runnable by adding an exception handler and some timing metrics.
|
||||
* This is used in methods that accepts a <code>Runnable</code> and return
|
||||
* either <code>void</code> or <code>ScheduledFuture</code>, as there is
|
||||
* normally no Future.get() call.
|
||||
*
|
||||
* Note: When submitting a <code>Callable</code>, you must check
|
||||
* <code>Future.get()</code> for exceptions.
|
||||
*/
|
||||
private Runnable logExceptions(Runnable task) {
|
||||
long queued = System.nanoTime();
|
||||
log.trace("Queued {}", task);
|
||||
return () -> {
|
||||
try {
|
||||
if (log.isTraceEnabled()) {
|
||||
long start = System.nanoTime();
|
||||
log.trace("Start {} (delay time {} us)", task, (start - queued) / 1000L);
|
||||
task.run();
|
||||
log.trace("Stop {} (exec time {} us)", task, (System.nanoTime() - start) / 1000L);
|
||||
} else {
|
||||
task.run();
|
||||
} finally {
|
||||
MDC.clear();
|
||||
}
|
||||
};
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// log any exception here. Note they will not bubble up to the calling user
|
||||
// unless Future.get() is checked. (Which is almost never done on scheduled
|
||||
// background executions)
|
||||
log.error("Error while executing the task {}", task, t);
|
||||
throw t;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Future<T> submit(Callable<T> task) {
|
||||
return executor.submit(wrapMDC(task));
|
||||
// Note: No "logExceptions" as we expect Future.get() by the invoker
|
||||
return pool.submit(wrap(task));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,47 +97,52 @@ public final class DefaultBackgroundExecutor implements SpiBackgroundExecutor {
|
||||
*/
|
||||
@Override
|
||||
public Future<?> submit(Runnable task) {
|
||||
return executor.submit(wrapMDC(task));
|
||||
return pool.submit(wrap(task));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Runnable task) {
|
||||
submit(task);
|
||||
submit(logExceptions(task));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executePeriodically(Runnable task, long delay, TimeUnit unit) {
|
||||
executor.scheduleWithFixedDelay(wrapMDC(task), delay, delay, unit);
|
||||
schedulePool.scheduleWithFixedDelay(wrap(logExceptions(task)), delay, delay, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executePeriodically(Runnable task, long initialDelay, long delay, TimeUnit unit) {
|
||||
executor.scheduleWithFixedDelay(wrapMDC(task), initialDelay, delay, unit);
|
||||
schedulePool.scheduleWithFixedDelay(wrap(logExceptions(task)), initialDelay, delay, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit) {
|
||||
return executor.scheduleWithFixedDelay(wrapMDC(task), initialDelay, delay, unit);
|
||||
return schedulePool.scheduleWithFixedDelay(wrap(logExceptions(task)), initialDelay, delay, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScheduledFuture<?> scheduleAtFixedRate(Runnable task, long initialDelay, long delay, TimeUnit unit) {
|
||||
return executor.scheduleAtFixedRate(wrapMDC(task), initialDelay, delay, unit);
|
||||
return schedulePool.scheduleAtFixedRate(wrap(logExceptions(task)), initialDelay, delay, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScheduledFuture<?> schedule(Runnable task, long delay, TimeUnit unit) {
|
||||
return executor.schedule(wrapMDC(task), delay, unit);
|
||||
return schedulePool.schedule(wrap(logExceptions(task)), delay, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> ScheduledFuture<V> schedule(Callable<V> task, long delay, TimeUnit unit) {
|
||||
return executor.schedule(wrapMDC(task), delay, unit);
|
||||
// Note: No "logExceptions" as we expect Future.get() by the invoker
|
||||
return schedulePool.schedule(wrap(task), delay, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
executor.shutdown();
|
||||
log.trace("BackgroundExecutor shutting down");
|
||||
schedulePool.shutdown();
|
||||
pool.shutdown();
|
||||
log.debug("BackgroundExecutor stopped");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ abstract class AbstractTextExpression extends AbstractExpression {
|
||||
@Override
|
||||
public void queryBindKey(BindValuesKey key) {
|
||||
// do nothing, only execute against document store
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameByBind(SpiExpression other) {
|
||||
|
||||
@@ -4,8 +4,6 @@ import io.ebeaninternal.api.BindValuesKey;
|
||||
import io.ebeaninternal.api.SpiExpression;
|
||||
import io.ebeaninternal.api.SpiExpressionRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Bitwise expression.
|
||||
*/
|
||||
@@ -25,7 +23,7 @@ final class BitwiseExpression extends AbstractExpression {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
public void writeDocQuery(DocQueryContext context) {
|
||||
throw new IllegalStateException("Not supported for document queries");
|
||||
}
|
||||
|
||||
|
||||
+6
-8
@@ -47,12 +47,12 @@ final class DefaultExampleExpression implements SpiExpression, ExampleExpression
|
||||
private final EntityBean entity;
|
||||
|
||||
/**
|
||||
* Set to true to use case insensitive expressions.
|
||||
* Set to true to use case-insensitive expressions.
|
||||
*/
|
||||
private boolean caseInsensitive;
|
||||
|
||||
/**
|
||||
* The type of like (RAW, STARTS_WITH, ENDS_WITH etc)
|
||||
* The type of like (RAW, STARTS_WITH, ENDS_WITH)
|
||||
*/
|
||||
private LikeType likeType;
|
||||
|
||||
@@ -62,7 +62,7 @@ final class DefaultExampleExpression implements SpiExpression, ExampleExpression
|
||||
private boolean includeZeros;
|
||||
|
||||
/**
|
||||
* The non null bean properties and found and together added as a list of
|
||||
* The non-null bean properties and found and together added as a list of
|
||||
* expressions (like or equal to expressions).
|
||||
*/
|
||||
private ArrayList<SpiExpression> list;
|
||||
@@ -71,8 +71,8 @@ final class DefaultExampleExpression implements SpiExpression, ExampleExpression
|
||||
/**
|
||||
* Construct the query by example expression.
|
||||
*
|
||||
* @param entity the example entity with non null property values
|
||||
* @param caseInsensitive if true use case insensitive expressions
|
||||
* @param entity the example entity with non-null property values
|
||||
* @param caseInsensitive if true use case-insensitive expressions
|
||||
* @param likeType the type of Like wild card used
|
||||
*/
|
||||
DefaultExampleExpression(EntityBean entity, boolean caseInsensitive, LikeType likeType) {
|
||||
@@ -303,9 +303,7 @@ final class DefaultExampleExpression implements SpiExpression, ExampleExpression
|
||||
*/
|
||||
private boolean isZero(Object value) {
|
||||
if (value instanceof Number) {
|
||||
if (((Number) value).doubleValue() == 0) {
|
||||
return true;
|
||||
}
|
||||
return ((Number) value).doubleValue() == 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+13
-13
@@ -186,7 +186,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
|
||||
/**
|
||||
* Case Insensitive Equal To - property equal to the given value (typically
|
||||
* using a lower() function to make it case insensitive).
|
||||
* using a lower() function to make it case-insensitive).
|
||||
*/
|
||||
@Override
|
||||
public Expression ieq(String propertyName, String value) {
|
||||
@@ -198,7 +198,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
|
||||
/**
|
||||
* Case Insensitive Equal To - property equal to the given value (typically
|
||||
* using a lower() function to make it case insensitive).
|
||||
* using a lower() function to make it case-insensitive).
|
||||
*/
|
||||
@Override
|
||||
public Expression ine(String propertyName, String value) {
|
||||
@@ -336,7 +336,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive {@link #exampleLike(Object)}
|
||||
* Case-insensitive {@link #exampleLike(Object)}
|
||||
*/
|
||||
@Override
|
||||
public ExampleExpression iexampleLike(Object example) {
|
||||
@@ -344,7 +344,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the query by Example expression which is case sensitive and using
|
||||
* Create the query by Example expression which is case-sensitive and using
|
||||
* LikeType.RAW (you need to add you own wildcards % and _).
|
||||
*/
|
||||
@Override
|
||||
@@ -375,9 +375,9 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive Like - property like value where the value contains the
|
||||
* SQL wild card characters % (percentage) and _ (underscore). Typically uses
|
||||
* a lower() function to make the expression case insensitive.
|
||||
* Case-insensitive Like - property like value where the value contains the
|
||||
* SQL wild card characters % (percentage) and _ (underscore). Typically, uses
|
||||
* a lower() function to make the expression case-insensitive.
|
||||
*/
|
||||
@Override
|
||||
public Expression ilike(String propertyName, String value) {
|
||||
@@ -397,8 +397,8 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive Starts With - property like value%. Typically uses a
|
||||
* lower() function to make the expression case insensitive.
|
||||
* Case-insensitive Starts With - property like value%. Typically, uses a
|
||||
* lower() function to make the expression case-insensitive.
|
||||
*/
|
||||
@Override
|
||||
public Expression istartsWith(String propertyName, String value) {
|
||||
@@ -414,8 +414,8 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive Ends With - property like %value. Typically uses a lower()
|
||||
* function to make the expression case insensitive.
|
||||
* Case-insensitive Ends With - property like %value. Typically, uses a lower()
|
||||
* function to make the expression case-insensitive.
|
||||
*/
|
||||
@Override
|
||||
public Expression iendsWith(String propertyName, String value) {
|
||||
@@ -431,8 +431,8 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive Contains - property like %value%. Typically uses a lower()
|
||||
* function to make the expression case insensitive.
|
||||
* Case-insensitive Contains - property like %value%. Typically, uses a lower()
|
||||
* function to make the expression case-insensitive.
|
||||
*/
|
||||
@Override
|
||||
public Expression icontains(String propertyName, String value) {
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
writeDocQuery(context, null);
|
||||
|
||||
} else {
|
||||
// this is a Top level "text" expressions so we may need to wrap in Bool SHOULD etc.
|
||||
// this is a Top level "text" expressions, so we may need to wrap in Bool SHOULD etc.
|
||||
if (list.isEmpty()) {
|
||||
throw new IllegalStateException("empty expression list?");
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public interface DocQueryContext {
|
||||
void writeIn(String propertyName, Object[] values, boolean not) throws IOException;
|
||||
|
||||
/**
|
||||
* Write an Id in expression.
|
||||
* Write an ID in expression.
|
||||
*/
|
||||
void writeIds(Collection<?> idCollection) throws IOException;
|
||||
|
||||
@@ -131,7 +131,7 @@ public interface DocQueryContext {
|
||||
void writeTextQueryString(String search, TextQueryString options) throws IOException;
|
||||
|
||||
/**
|
||||
* Start a Bool which may contain some of Must, Must Not, Should.
|
||||
* Start a Bool which may contain Must, Must Not, Should.
|
||||
*/
|
||||
void startBoolGroup() throws IOException;
|
||||
|
||||
|
||||
+3
-11
@@ -1,19 +1,11 @@
|
||||
package io.ebeaninternal.server.expression;
|
||||
|
||||
import io.ebean.event.BeanQueryRequest;
|
||||
import io.ebeaninternal.api.BindValuesKey;
|
||||
import io.ebeaninternal.api.ManyWhereJoins;
|
||||
import io.ebeaninternal.api.NaturalKeyQueryData;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.api.SpiExpression;
|
||||
import io.ebeaninternal.api.SpiExpressionRequest;
|
||||
import io.ebeaninternal.api.SpiExpressionValidation;
|
||||
import io.ebeaninternal.api.SpiQuery;
|
||||
import io.ebeaninternal.api.*;
|
||||
import io.ebeaninternal.api.SpiQuery.Type;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import io.ebeaninternal.server.query.CQuery;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
final class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpression {
|
||||
@@ -52,7 +44,7 @@ final class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreE
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
public void writeDocQuery(DocQueryContext context) {
|
||||
throw new IllegalStateException("Not supported");
|
||||
}
|
||||
|
||||
@@ -77,7 +69,7 @@ final class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreE
|
||||
/**
|
||||
* Compile/build the sub query.
|
||||
*/
|
||||
protected CQuery<?> compileSubQuery(BeanQueryRequest<?> queryRequest) {
|
||||
CQuery<?> compileSubQuery(BeanQueryRequest<?> queryRequest) {
|
||||
SpiEbeanServer ebeanServer = (SpiEbeanServer) queryRequest.database();
|
||||
return ebeanServer.compileQuery(Type.SQ_EXISTS, subQuery, queryRequest.transaction());
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ final class IdExpression extends NonPrepareExpression implements SpiExpression {
|
||||
@Override
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
|
||||
// 'flatten' EmbeddedId and multiple Id cases
|
||||
// 'flatten' EmbeddedId and multiple ID cases
|
||||
// into an array of the underlying scalar field values
|
||||
DefaultExpressionRequest r = (DefaultExpressionRequest) request;
|
||||
Object[] bindIdValues = r.getBeanDescriptor().bindIdValues(value);
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Id IN expression common for cache handling.
|
||||
* ID IN expression common for cache handling.
|
||||
*/
|
||||
public interface IdInCommon {
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* In a collection of Id values.
|
||||
* In a collection of ID values.
|
||||
*/
|
||||
public final class IdInExpression extends NonPrepareExpression implements IdInCommon {
|
||||
|
||||
@@ -73,7 +73,7 @@ public final class IdInExpression extends NonPrepareExpression implements IdInCo
|
||||
if (idCollection.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// Bind the Id values including EmbeddedId and multiple Id
|
||||
// Bind the ID values including EmbeddedId and multiple ID
|
||||
|
||||
DefaultExpressionRequest r = (DefaultExpressionRequest) request;
|
||||
BeanDescriptor<?> descriptor = r.getBeanDescriptor();
|
||||
@@ -82,7 +82,7 @@ public final class IdInExpression extends NonPrepareExpression implements IdInCo
|
||||
}
|
||||
|
||||
/**
|
||||
* For use with deleting non attached detail beans during stateless update.
|
||||
* For use with deleting non-attached detail beans during stateless update.
|
||||
*/
|
||||
public void addSqlNoAlias(SpiExpressionRequest request) {
|
||||
|
||||
@@ -116,7 +116,7 @@ public final class IdInExpression extends NonPrepareExpression implements IdInCo
|
||||
}
|
||||
|
||||
/**
|
||||
* Incorporates the number of Id values to bind.
|
||||
* Incorporates the number of ID values to bind.
|
||||
*/
|
||||
@Override
|
||||
public void queryPlanHash(StringBuilder builder) {
|
||||
|
||||
@@ -9,7 +9,6 @@ import io.ebeaninternal.api.SpiExpression;
|
||||
import io.ebeaninternal.api.SpiExpressionRequest;
|
||||
import io.ebeaninternal.server.persist.MultiValueWrapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -54,7 +53,7 @@ final class InPairsExpression extends AbstractExpression {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
public void writeDocQuery(DocQueryContext context) {
|
||||
throw new RuntimeException("Not supported with document query");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
package io.ebeaninternal.server.expression;
|
||||
|
||||
import io.ebean.event.BeanQueryRequest;
|
||||
import io.ebeaninternal.api.BindValuesKey;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.api.SpiExpression;
|
||||
import io.ebeaninternal.api.SpiExpressionRequest;
|
||||
import io.ebeaninternal.api.SpiQuery;
|
||||
import io.ebeaninternal.api.*;
|
||||
import io.ebeaninternal.api.SpiQuery.Type;
|
||||
import io.ebeaninternal.server.query.CQuery;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -42,7 +37,7 @@ final class InQueryExpression extends AbstractExpression implements UnsupportedD
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
public void writeDocQuery(DocQueryContext context) {
|
||||
throw new IllegalStateException("Not supported");
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ final class IsEmptyExpression extends AbstractExpression {
|
||||
}
|
||||
}
|
||||
|
||||
public final String getPropName() {
|
||||
public String getPropName() {
|
||||
return propName;
|
||||
}
|
||||
|
||||
|
||||
@@ -868,7 +868,7 @@ final class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, Expr
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> select(FetchGroup fetchGroup) {
|
||||
public Query<T> select(FetchGroup<T> fetchGroup) {
|
||||
return exprList.select(fetchGroup);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A logical And or Or for joining two expressions.
|
||||
* A logical And or, Or for joining two expressions.
|
||||
*/
|
||||
abstract class LogicExpression implements SpiExpression {
|
||||
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
package io.ebeaninternal.server.expression;
|
||||
|
||||
import io.ebean.event.BeanQueryRequest;
|
||||
import io.ebeaninternal.api.BindValuesKey;
|
||||
import io.ebeaninternal.api.ManyWhereJoins;
|
||||
import io.ebeaninternal.api.NaturalKeyQueryData;
|
||||
import io.ebeaninternal.api.SpiExpression;
|
||||
import io.ebeaninternal.api.SpiExpressionRequest;
|
||||
import io.ebeaninternal.api.SpiExpressionValidation;
|
||||
import io.ebeaninternal.api.*;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Effectively an expression that has no effect.
|
||||
*/
|
||||
@@ -40,7 +33,7 @@ final class NoopExpression implements SpiExpression {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context) throws IOException {
|
||||
public void writeDocQuery(DocQueryContext context) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-4
@@ -16,7 +16,7 @@ final class RawExpressionBuilder {
|
||||
*/
|
||||
static RawExpression buildSingle(String raw, Object value) {
|
||||
if (isExpand(value, raw, BP_1)) {
|
||||
Collection val = (Collection) value;
|
||||
Collection<?> val = (Collection<?>) value;
|
||||
raw = raw.replace(BP_1, expand(val));
|
||||
return new RawExpression(raw, val.toArray());
|
||||
}
|
||||
@@ -50,8 +50,7 @@ final class RawExpressionBuilder {
|
||||
return "?" + (i + 1);
|
||||
}
|
||||
|
||||
private static String expand(Collection values) {
|
||||
|
||||
private static String expand(Collection<?> values) {
|
||||
StringBuilder sqlExpand = new StringBuilder(values.size() * 2);
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
if (i > 0) {
|
||||
@@ -72,7 +71,7 @@ final class RawExpressionBuilder {
|
||||
if (!isExpand(values[i], raw, match)) {
|
||||
params.add(values[i]);
|
||||
} else {
|
||||
Collection val = (Collection) values[i];
|
||||
Collection<?> val = (Collection<?>) values[i];
|
||||
params.addAll(val);
|
||||
raw = raw.replace(match, expand(val));
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Objects;
|
||||
final class Same {
|
||||
|
||||
/**
|
||||
* Return true if both values are null or both an not null.
|
||||
* Return true if both values are null or both not null.
|
||||
*/
|
||||
static boolean sameByNull(Object v1, Object v2) {
|
||||
return (v1 == null) == (v2 == null);
|
||||
|
||||
@@ -55,7 +55,7 @@ public final class SimpleExpression extends AbstractValueExpression {
|
||||
}
|
||||
}
|
||||
|
||||
public final String getPropName() {
|
||||
public String getPropName() {
|
||||
return propName;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ Expressions for building WHERE clauses.
|
||||
<p>
|
||||
In the code above the LIKE and GREATER THAN Expressions are added to the where clause.
|
||||
The way this works is that where() returns an ExpressionList which has methods on
|
||||
it to create the standard expressions (EQUAL TO, LIKE etc).
|
||||
it to create the standard expressions (EQUAL TO, LIKE etc.)
|
||||
</p>
|
||||
<p>
|
||||
I expect most people to add their expressions in this way. The Expr expression factory
|
||||
|
||||
+15
-14
@@ -15,6 +15,7 @@ import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||
import io.ebeaninternal.server.querydefn.OrmQueryProperties;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
@@ -66,7 +67,7 @@ final class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext
|
||||
}
|
||||
}
|
||||
|
||||
protected void register(EntityBeanIntercept ebi) {
|
||||
void register(EntityBeanIntercept ebi) {
|
||||
if (currentBuffer.isFull()) {
|
||||
currentBuffer = createBuffer(batchSize);
|
||||
}
|
||||
@@ -91,7 +92,7 @@ final class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext
|
||||
try {
|
||||
if (bufferList != null) {
|
||||
for (LoadBuffer loadBuffer : bufferList) {
|
||||
if (!loadBuffer.list.isEmpty()) {
|
||||
if (!loadBuffer.batch.isEmpty()) {
|
||||
parent.getEbeanServer().loadBean(new LoadBeanRequest(loadBuffer, parentRequest));
|
||||
}
|
||||
if (forEach) {
|
||||
@@ -115,13 +116,13 @@ final class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext
|
||||
private final ReentrantLock bufferLock = new ReentrantLock();
|
||||
private final DLoadBeanContext context;
|
||||
private final int batchSize;
|
||||
private final List<EntityBeanIntercept> list;
|
||||
private final Set<EntityBeanIntercept> batch;
|
||||
private PersistenceContext persistenceContext;
|
||||
|
||||
LoadBuffer(DLoadBeanContext context, int batchSize) {
|
||||
this.context = context;
|
||||
this.batchSize = batchSize;
|
||||
this.list = new ArrayList<>(batchSize);
|
||||
this.batch = new HashSet<>(Math.max((int) (batchSize/.75f) + 1, 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,7 +140,7 @@ final class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext
|
||||
* Return true if the buffer is full.
|
||||
*/
|
||||
public boolean isFull() {
|
||||
return batchSize == list.size();
|
||||
return batchSize == batch.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,12 +151,12 @@ final class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext
|
||||
// get persistenceContext from first loaded bean into the buffer
|
||||
persistenceContext = ebi.getPersistenceContext();
|
||||
}
|
||||
list.add(ebi);
|
||||
batch.add(ebi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntityBeanIntercept> batch() {
|
||||
return list;
|
||||
public Set<EntityBeanIntercept> batch() {
|
||||
return batch;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -190,13 +191,13 @@ final class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext
|
||||
// lazy load property was a Many
|
||||
return;
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
if (!batch.contains(ebi)) {
|
||||
// re-add to the batch and lazy load from DB skipping l2 cache
|
||||
list.add(ebi);
|
||||
batch.add(ebi);
|
||||
} else if (context.hitCache) {
|
||||
Set<EntityBeanIntercept> hits = context.desc.cacheBeanLoadAll(list, persistenceContext, ebi.getLazyLoadPropertyIndex(), ebi.getLazyLoadProperty());
|
||||
list.removeAll(hits);
|
||||
if (list.isEmpty() || hits.contains(ebi)) {
|
||||
Set<EntityBeanIntercept> hits = context.desc.cacheBeanLoadAll(batch, persistenceContext, ebi.getLazyLoadPropertyIndex(), ebi.getLazyLoadProperty());
|
||||
batch.removeAll(hits);
|
||||
if (batch.isEmpty() || hits.contains(ebi)) {
|
||||
// successfully hit the L2 cache so don't invoke DB lazy loading
|
||||
return;
|
||||
}
|
||||
@@ -204,7 +205,7 @@ final class DLoadBeanContext extends DLoadBaseContext implements LoadBeanContext
|
||||
|
||||
LoadBeanRequest req = new LoadBeanRequest(this, ebi, context.hitCache);
|
||||
context.desc.ebeanServer().loadBean(req);
|
||||
list.clear();
|
||||
batch.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,8 +81,7 @@ public final class DefaultPersister implements Persister {
|
||||
int rc = request.executeOrQueue();
|
||||
request.commitTransIfRequired();
|
||||
return rc;
|
||||
|
||||
} catch (RuntimeException e) {
|
||||
} catch (Throwable e) {
|
||||
request.rollbackTransIfRequired();
|
||||
throw e;
|
||||
} finally {
|
||||
@@ -383,8 +382,7 @@ public final class DefaultPersister implements Persister {
|
||||
req.resetDepth();
|
||||
req.commitTransIfRequired();
|
||||
req.flushBatchOnCascade();
|
||||
|
||||
} catch (RuntimeException ex) {
|
||||
} catch (Throwable ex) {
|
||||
req.rollbackTransIfRequired();
|
||||
throw ex;
|
||||
} finally {
|
||||
@@ -420,8 +418,7 @@ public final class DefaultPersister implements Persister {
|
||||
req.resetDepth();
|
||||
req.commitTransIfRequired();
|
||||
req.flushBatchOnCascade();
|
||||
|
||||
} catch (RuntimeException ex) {
|
||||
} catch (Throwable ex) {
|
||||
req.rollbackTransIfRequired();
|
||||
throw ex;
|
||||
} finally {
|
||||
@@ -559,7 +556,7 @@ public final class DefaultPersister implements Persister {
|
||||
req.flushBatchOnCascade();
|
||||
return rows;
|
||||
|
||||
} catch (RuntimeException ex) {
|
||||
} catch (Throwable ex) {
|
||||
req.rollbackTransIfRequired();
|
||||
throw ex;
|
||||
} finally {
|
||||
|
||||
@@ -757,7 +757,7 @@ final class CQueryBuilder {
|
||||
}
|
||||
|
||||
boolean isPlatformDistinctOn() {
|
||||
return dbPlatform.isPlatform(Platform.POSTGRES) || dbPlatform.isPlatform(Platform.YUGABYTE);
|
||||
return dbPlatform.isPlatform(Platform.POSTGRES) || dbPlatform.isPlatform(Platform.YUGABYTE) || dbPlatform.isPlatform(Platform.COCKROACH);
|
||||
}
|
||||
|
||||
boolean isPlatformDistinctNoLobs() {
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.ebeaninternal.server.query;
|
||||
import io.ebean.QueryIterator;
|
||||
import io.ebeaninternal.server.core.OrmQueryRequest;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user