mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-09-20 11:17:36 +00:00
Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4bdec0fda | ||
|
|
328b13af18 | ||
|
|
fd8ef48486 | ||
|
|
69f39f9c82 | ||
|
|
2f1625316b | ||
|
|
952d9940e7 | ||
|
|
c62b63119b | ||
|
|
fdcbb91981 | ||
|
|
0e2b1f95b2 | ||
|
|
80f5cab086 | ||
|
|
90aff3d9ef | ||
|
|
1c857e47b4 | ||
|
|
cc9e67c326 | ||
|
|
7a7dfb96d7 | ||
|
|
3c4e87f3f7 | ||
|
|
f5eee70ec4 | ||
|
|
46a73f6250 | ||
|
|
4a46cc0706 | ||
|
|
94630b7e1e | ||
|
|
aac85eec89 | ||
|
|
a8ec4ee437 | ||
|
|
12b9d0eaae | ||
|
|
eeb32514be | ||
|
|
02936735c1 | ||
|
|
57713a9686 | ||
|
|
4076b0fcbd | ||
|
|
49f6bef2fb | ||
|
|
d6ba4967b6 |
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -42,13 +42,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-clickhouse</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -42,13 +42,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-postgres</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -42,13 +42,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-db2</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -42,13 +42,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-h2</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -42,13 +42,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-hana</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -42,13 +42,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-mariadb</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -42,13 +42,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-mysql</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -47,19 +47,19 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-postgres</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-net-postgis-types</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -42,13 +42,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-nuodb</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -42,13 +42,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-oracle</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -47,19 +47,19 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-postgres</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-pgvector-types</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -47,19 +47,19 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-postgres</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-postgis-types</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -42,13 +42,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-postgres</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -42,13 +42,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-sqlite</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -42,13 +42,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-sqlserver</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -42,13 +42,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-postgres</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -41,7 +41,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-jackson-mapper</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -60,13 +60,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-all</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>composites</artifactId>
|
||||
|
||||
@@ -1,40 +1,39 @@
|
||||
# Guide: `@DbJson` / `@DbJsonB` mapping support — built-in vs Jackson ObjectMapper
|
||||
# Guide: `@DbJson` / `@DbJsonB` mapping support
|
||||
|
||||
## Purpose
|
||||
|
||||
Ebean can map `@DbJson` and `@DbJsonB` properties in two ways:
|
||||
Ebean can map `@DbJson` and `@DbJsonB` properties in three ways:
|
||||
|
||||
- **Built-in** JSON support, backed by **avaje-json-core** — no extra dependency.
|
||||
- **Jackson `ObjectMapper`**, provided by the **`ebean-jackson-mapper`** module — used
|
||||
for everything the built-in support does not handle.
|
||||
- **Jackson `ObjectMapper`**, provided by **`ebean-jackson-mapper`**.
|
||||
- **Avaje Jsonb**, provided by **`ebean-avajejsonb-mapper`** and its generated adapters.
|
||||
|
||||
This guide lists exactly which property types are handled built-in and which require
|
||||
`ebean-jackson-mapper`.
|
||||
The built-in mapper handles the common natural JSON types. Add one mapper module for
|
||||
typed collections, POJOs, records, and other custom types.
|
||||
|
||||
> If a property type is **not** handled built-in and `ebean-jackson-mapper` is not on the
|
||||
> classpath, Ebean fails fast at startup:
|
||||
> If a property type is **not** handled built-in and no mapper module is on the classpath,
|
||||
> Ebean fails fast at startup:
|
||||
>
|
||||
> ```text
|
||||
> Unsupported @DbJson mapping - Missing dependency ebean-jackson-mapper?
|
||||
> Jackson ObjectMapper not present for <property>
|
||||
> Unsupported @DbJson mapping - missing JSON mapper dependency for <property>
|
||||
> ```
|
||||
|
||||
---
|
||||
|
||||
## Quick reference
|
||||
|
||||
| Property type | Built-in (avaje-json-core) | Needs `ebean-jackson-mapper` |
|
||||
|---|:---:|:---:|
|
||||
| Property type | Built-in (avaje-json-core) | Mapper module |
|
||||
|---|:---:|---|
|
||||
| `String` | ✅ | |
|
||||
| `List<String>`, `List<Long>` | ✅ | |
|
||||
| `Set<String>`, `Set<Long>` | ✅ | |
|
||||
| `Map<String, Object>`, `Map<String, ?>` | ✅ | |
|
||||
| `Map<String, String>` | ✅ | |
|
||||
| `Map<Enum, Object>`, `Map<Enum, String>` | ✅ | |
|
||||
| `List`/`Set` of any other element type (`Integer`, `Double`, `UUID`, `LocalDate`, an enum, a POJO, …) | | ✅ |
|
||||
| `Map` with a typed value other than `String`/`Object` (`Map<String,Integer>`, `Map<String,UUID>`, …) | | ✅ |
|
||||
| `Map` with a key other than `String` or an enum (`Map<Integer, …>`, `Map<UUID, …>`) | | ✅ |
|
||||
| POJOs, records, or any other type | | ✅ |
|
||||
| `List`/`Set` of any other element type (`Integer`, `Double`, `UUID`, `LocalDate`, an enum, a POJO, …) | | Jackson or Avaje Jsonb |
|
||||
| `Map` with a typed value other than `String`/`Object` (`Map<String,Integer>`, `Map<String,UUID>`, …) | | Jackson or Avaje Jsonb |
|
||||
| `Map` with a key other than `String` or an enum (`Map<Integer, …>`, `Map<UUID, …>`) | | Jackson or Avaje Jsonb |
|
||||
| POJOs, records, or any other type | | Jackson or Avaje Jsonb |
|
||||
|
||||
---
|
||||
|
||||
@@ -59,10 +58,10 @@ Postgres `json` / `jsonb` — without `ebean-jackson-mapper`.
|
||||
|
||||
---
|
||||
|
||||
## Everything else → Jackson `ObjectMapper`
|
||||
## Jackson `ObjectMapper`
|
||||
|
||||
Any other `@DbJson` / `@DbJsonB` property routes to the Jackson `ObjectMapper` path, which
|
||||
requires `ebean-jackson-mapper`:
|
||||
`ebean-jackson-mapper` uses a Jackson `ObjectMapper` for the property types not handled
|
||||
built-in:
|
||||
|
||||
- **Typed collections** — `List`/`Set` whose element type is not `String` or `Long`
|
||||
(for example `List<Integer>`, `List<UUID>`, `List<LocalDate>`, `List<MyEnum>`, `List<MyPojo>`).
|
||||
@@ -77,7 +76,7 @@ requires `ebean-jackson-mapper`:
|
||||
|
||||
---
|
||||
|
||||
## Adding `ebean-jackson-mapper`
|
||||
### Adding `ebean-jackson-mapper`
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
@@ -92,6 +91,79 @@ registers the mapper-based JSON support automatically.
|
||||
|
||||
---
|
||||
|
||||
## Avaje Jsonb
|
||||
|
||||
`ebean-avajejsonb-mapper` uses Avaje Jsonb adapters. Annotate each JSON payload type with
|
||||
`@Json`, or use `@Json.Import`, and configure `avaje-jsonb-generator` as an annotation
|
||||
processor.
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-avajejsonb-mapper</artifactId>
|
||||
<version>${ebean.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
```xml
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>io.avaje</groupId>
|
||||
<artifactId>avaje-jsonb-generator</artifactId>
|
||||
<version>${avaje-jsonb.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```java
|
||||
import io.avaje.jsonb.Json;
|
||||
|
||||
@Json
|
||||
public class Address {
|
||||
public String line1;
|
||||
public String city;
|
||||
}
|
||||
```
|
||||
|
||||
Avaje Jsonb preserves a property's declared generic type, so `List<Address>` and other
|
||||
parameterised JSON values use the generated `Address` adapter.
|
||||
|
||||
### Avaje JsonNode
|
||||
|
||||
`@DbJson` and `@DbJsonB` properties declared as `io.avaje.json.node.JsonNode` are supported
|
||||
when the application includes `avaje-json-node`. Its Jsonb component supplies the JSON tree
|
||||
adapters; no application-generated adapter is needed for the node hierarchy.
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>io.avaje</groupId>
|
||||
<artifactId>avaje-json-node</artifactId>
|
||||
<version>${avaje-jsonb.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## Mapper module selection
|
||||
|
||||
Use exactly one mapper module in an application: `ebean-jackson-mapper` or
|
||||
`ebean-avajejsonb-mapper`. Ebean selects a single `ScalarJsonMapper` service provider, so
|
||||
having both modules on the runtime classpath is not supported.
|
||||
|
||||
The `ebean` composite dependency includes `ebean-jackson-mapper`. Applications using Avaje
|
||||
Jsonb should depend on the individual Ebean modules they need instead of that composite.
|
||||
|
||||
To migrate from Jackson to Avaje Jsonb, remove `ebean-jackson-mapper`, add
|
||||
`ebean-avajejsonb-mapper`, and generate adapters for each JSON payload type.
|
||||
|
||||
---
|
||||
|
||||
## Notes
|
||||
|
||||
- **Enum map keys** are serialised using the enum `name()` (for example `ACTIVE`), not any
|
||||
@@ -102,15 +174,13 @@ registers the mapper-based JSON support automatically.
|
||||
(with a JSON fallback on platforms without array support) and supports more element types
|
||||
than built-in `@DbJson` collections.
|
||||
- The reason typed value/element collections need a real mapper is that the built-in path
|
||||
only produces natural JSON types — for example a JSON number always parses to `Long`, so a
|
||||
declared `List<Integer>` or `Map<String,Integer>` could not be populated safely without a
|
||||
type-aware mapper.
|
||||
only produces natural JSON types — for example a JSON number always parses to `Long`.
|
||||
|
||||
---
|
||||
|
||||
## Choosing
|
||||
|
||||
- Prefer the **built-in** mappings for the common cases (`String`, string/long lists and sets,
|
||||
object/string maps) to avoid pulling in Jackson.
|
||||
- Add **`ebean-jackson-mapper`** when you need rich POJO JSON columns or typed collections /
|
||||
typed-value maps.
|
||||
object/string maps) to avoid an additional mapper module.
|
||||
- Add **`ebean-jackson-mapper`** or **`ebean-avajejsonb-mapper`** when you need rich POJO JSON
|
||||
columns or typed collections / typed-value maps.
|
||||
|
||||
@@ -376,7 +376,12 @@ public class Customer {
|
||||
**Important:**
|
||||
- Use `List<>` not `Set<>` for collections (Set calls equals/hashCode before beans have IDs)
|
||||
- `mappedBy` means Order.customer is the owner
|
||||
- Relationships are lazy-loaded by default
|
||||
- Relationships are lazy-loaded by default — **except** `@OneToOne(mappedBy=...)`,
|
||||
which defaults to `FetchType.EAGER` and adds a `left join` to every default
|
||||
select of the owning entity. Explicitly set `fetch = FetchType.LAZY` on
|
||||
`@OneToOne(mappedBy=...)` fields unless the association is needed on
|
||||
(almost) every load. See "`@OneToOne(mappedBy=...)` is EAGER by default" in
|
||||
the query-beans guide for details.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -431,6 +431,48 @@ List<Customer> customers = new QCustomer()
|
||||
If the caller needs multiple to-many paths or a paged query, be suspicious of a
|
||||
plain `fetch(...)` on those paths. `fetchQuery()` is often the safer default.
|
||||
|
||||
### `@OneToOne(mappedBy=...)` is EAGER by default — mark it LAZY
|
||||
|
||||
The non-owning side of a `@OneToOne` (the side with `mappedBy`) defaults to
|
||||
`FetchType.EAGER` per JPA, same as `@ManyToOne`. Unlike a `@ManyToOne`
|
||||
reference (which is FK-only until `.fetch()`'d), Ebean's default select for an
|
||||
EAGER `@OneToOne(mappedBy=...)` still adds a `left join` to the target table
|
||||
on **every** query for the owning entity — even a plain `findById()` — because
|
||||
there is no local FK column to use as a lazy reference; the only way to know
|
||||
the associated row exists is to join to it.
|
||||
|
||||
If that association is rarely needed (e.g. a rarely-read child/detail table),
|
||||
this join executes on every load of the parent, including in hot-path list
|
||||
queries, and can dominate query cost as more such associations accumulate.
|
||||
|
||||
**Always set `fetch = FetchType.LAZY` on `@OneToOne(mappedBy=...)`
|
||||
associations unless the association is genuinely needed on (almost) every
|
||||
load:**
|
||||
|
||||
```java
|
||||
@OneToOne(mappedBy = "device", fetch = FetchType.LAZY)
|
||||
private SensorBoard sensorBoard;
|
||||
```
|
||||
|
||||
This correctly excludes the join from Ebean's default select clause (verified
|
||||
for FK-based, non-shared-primary-key `@OneToOne` relationships — the common
|
||||
case). Callers that do need the association can still `.fetch("sensorBoard")`
|
||||
explicitly on the query bean.
|
||||
|
||||
**Caveat:** the exclusion is driven by Ebean's default-select-clause
|
||||
mechanism. It is bypassed if the query has already been switched into an
|
||||
"all properties" mode by something other than the deploy-time
|
||||
`FetchType.LAZY`/`EAGER` metadata (for example, an active AutoTune profile
|
||||
that supplies its own tuned property set). Confirm the join is actually gone
|
||||
by checking generated SQL (`LoggedSql` in tests, or query logging) after
|
||||
making this change — don't assume it's excluded from the annotation alone.
|
||||
|
||||
### Agent rule
|
||||
|
||||
Default new `@OneToOne(mappedBy=...)` fields to `fetch = FetchType.LAZY`
|
||||
unless there's a clear reason the association is needed on every load. This
|
||||
is a one-line, low-risk change that avoids an always-on join.
|
||||
|
||||
---
|
||||
|
||||
## Step 8 - Use DTO projection when the caller does not need entity beans
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<name>ebean api</name>
|
||||
|
||||
@@ -5,13 +5,18 @@ package io.ebean.meta;
|
||||
*/
|
||||
public abstract class AbstractMetricVisitor implements MetricVisitor {
|
||||
|
||||
private final boolean reset;
|
||||
private final Mode mode;
|
||||
private final boolean collectTransactionMetrics;
|
||||
private final boolean collectQueryMetrics;
|
||||
private final boolean collectL2Metrics;
|
||||
|
||||
public AbstractMetricVisitor(boolean reset, boolean collectTransactionMetrics, boolean collectQueryMetrics, boolean collectL2Metrics) {
|
||||
this.reset = reset;
|
||||
this(reset ? Mode.RESET : Mode.CUMULATIVE,
|
||||
collectTransactionMetrics, collectQueryMetrics, collectL2Metrics);
|
||||
}
|
||||
|
||||
public AbstractMetricVisitor(Mode mode, boolean collectTransactionMetrics, boolean collectQueryMetrics, boolean collectL2Metrics) {
|
||||
this.mode = mode;
|
||||
this.collectTransactionMetrics = collectTransactionMetrics;
|
||||
this.collectQueryMetrics = collectQueryMetrics;
|
||||
this.collectL2Metrics = collectL2Metrics;
|
||||
@@ -19,7 +24,12 @@ public abstract class AbstractMetricVisitor implements MetricVisitor {
|
||||
|
||||
@Override
|
||||
public boolean reset() {
|
||||
return reset;
|
||||
return mode == Mode.RESET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mode mode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,4 +57,3 @@ public abstract class AbstractMetricVisitor implements MetricVisitor {
|
||||
// do nothing by default
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,16 @@ public class BasicMetricVisitor extends AbstractMetricVisitor implements ServerM
|
||||
* Construct specifying reset and what to collect.
|
||||
*/
|
||||
public BasicMetricVisitor(String name, Function<String,String> naming, boolean reset, boolean collectTransactionMetrics, boolean collectQueryMetrics, boolean collectL2Metrics) {
|
||||
super(reset, collectTransactionMetrics, collectQueryMetrics, collectL2Metrics);
|
||||
this(name, naming, reset ? Mode.RESET : Mode.CUMULATIVE,
|
||||
collectTransactionMetrics, collectQueryMetrics, collectL2Metrics);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct specifying the collection mode and what to collect.
|
||||
*/
|
||||
public BasicMetricVisitor(String name, Function<String,String> naming, Mode mode,
|
||||
boolean collectTransactionMetrics, boolean collectQueryMetrics, boolean collectL2Metrics) {
|
||||
super(mode, collectTransactionMetrics, collectQueryMetrics, collectL2Metrics);
|
||||
this.name = name;
|
||||
this.naming = naming;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,11 @@ import java.time.Instant;
|
||||
*/
|
||||
public interface MetaQueryPlan {
|
||||
|
||||
/**
|
||||
* Return the name of the database for the query.
|
||||
*/
|
||||
String dbName();
|
||||
|
||||
/**
|
||||
* Return the bean type for the query.
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,12 @@ import java.util.function.Function;
|
||||
*/
|
||||
public interface MetricVisitor {
|
||||
|
||||
enum Mode {
|
||||
RESET,
|
||||
CUMULATIVE,
|
||||
DELTA
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the naming convention that should be applied to the reported metric names.
|
||||
*/
|
||||
@@ -17,6 +23,13 @@ public interface MetricVisitor {
|
||||
*/
|
||||
boolean reset();
|
||||
|
||||
/**
|
||||
* Return the metric collection mode.
|
||||
*/
|
||||
default Mode mode() {
|
||||
return reset() ? Mode.RESET : Mode.CUMULATIVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if we should visit the transaction metrics.
|
||||
*/
|
||||
|
||||
@@ -37,6 +37,16 @@ public interface TimedMetric {
|
||||
*/
|
||||
TimedMetricStats collect(boolean reset);
|
||||
|
||||
/**
|
||||
* Collect a snapshot using the given collection mode.
|
||||
*
|
||||
* <p>Implementations that do not support delta collection use cumulative
|
||||
* collection for {@link MetricVisitor.Mode#DELTA}.</p>
|
||||
*/
|
||||
default TimedMetricStats collect(MetricVisitor.Mode mode) {
|
||||
return collect(mode == MetricVisitor.Mode.RESET);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visit non empty metrics.
|
||||
*/
|
||||
|
||||
@@ -43,4 +43,18 @@ class MetaInfoManagerTest {
|
||||
|
||||
assertThat(manager.collectMetrics(false)).isSameAs(metrics);
|
||||
}
|
||||
|
||||
@Test
|
||||
void basicMetricVisitorSupportsExplicitCollectionModes() {
|
||||
var reset = new BasicMetricVisitor("db", MetricNamingMatch.INSTANCE, MetricVisitor.Mode.RESET, true, true, true);
|
||||
var cumulative = new BasicMetricVisitor("db", MetricNamingMatch.INSTANCE, MetricVisitor.Mode.CUMULATIVE, true, true, true);
|
||||
var delta = new BasicMetricVisitor("db", MetricNamingMatch.INSTANCE, MetricVisitor.Mode.DELTA, true, true, true);
|
||||
|
||||
assertThat(reset.reset()).isTrue();
|
||||
assertThat(reset.mode()).isEqualTo(MetricVisitor.Mode.RESET);
|
||||
assertThat(cumulative.reset()).isFalse();
|
||||
assertThat(cumulative.mode()).isEqualTo(MetricVisitor.Mode.CUMULATIVE);
|
||||
assertThat(delta.reset()).isFalse();
|
||||
assertThat(delta.mode()).isEqualTo(MetricVisitor.Mode.DELTA);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ebean-avajejsonb-mapper</artifactId>
|
||||
<name>ebean-avajejsonb-mapper</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core-type</artifactId>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.avaje</groupId>
|
||||
<artifactId>avaje-json-core</artifactId>
|
||||
<version>${avaje-json-core.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.avaje</groupId>
|
||||
<artifactId>avaje-jsonb</artifactId>
|
||||
<version>${avaje-jsonb.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.avaje</groupId>
|
||||
<artifactId>avaje-json-node</artifactId>
|
||||
<version>${avaje-jsonb.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-h2</artifactId>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-datasource</artifactId>
|
||||
<version>${ebean-datasource.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>${h2database.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-ddl-generator</artifactId>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>io.avaje</groupId>
|
||||
<artifactId>avaje-jsonb-generator</artifactId>
|
||||
<version>${avaje-jsonb.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-maven-plugin</artifactId>
|
||||
<version>${ebean-maven-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test</id>
|
||||
<phase>process-test-classes</phase>
|
||||
<configuration>
|
||||
<packages>org/example/avajejsonb/**</packages>
|
||||
<transformArgs>debug=0</transformArgs>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>testEnhance</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
+223
@@ -0,0 +1,223 @@
|
||||
package io.ebean.avajejsonb.mapper;
|
||||
|
||||
import io.avaje.json.JsonReader;
|
||||
import io.avaje.json.JsonWriter;
|
||||
import io.avaje.jsonb.JsonType;
|
||||
import io.avaje.jsonb.Jsonb;
|
||||
import io.ebean.annotation.MutationDetection;
|
||||
import io.ebean.core.type.DataBinder;
|
||||
import io.ebean.core.type.DataReader;
|
||||
import io.ebean.core.type.DocPropertyType;
|
||||
import io.ebean.core.type.JsonTrim;
|
||||
import io.ebean.core.type.PostgresHelper;
|
||||
import io.ebean.core.type.ScalarJsonManager;
|
||||
import io.ebean.core.type.ScalarJsonMapper;
|
||||
import io.ebean.core.type.ScalarJsonRequest;
|
||||
import io.ebean.core.type.ScalarType;
|
||||
import io.ebean.core.type.ScalarTypeBase;
|
||||
import io.ebean.text.TextException;
|
||||
import jakarta.persistence.PersistenceException;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Supports {@code @DbJson} properties using Avaje Jsonb.
|
||||
*/
|
||||
public final class ScalarJsonAvajeJsonbMapper implements ScalarJsonMapper {
|
||||
|
||||
private final ConcurrentHashMap<Type, JsonType<Object>> jsonTypes = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public <A extends Annotation> Class<A> markerAnnotation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScalarType<?> createType(ScalarJsonRequest request) {
|
||||
Type genericType = genericType(request);
|
||||
JsonType<Object> jsonType = jsonTypes.computeIfAbsent(genericType, type -> jsonb(request.manager()).type(type));
|
||||
if (request.mode() == MutationDetection.NONE) {
|
||||
return new NoMutationDetection(request.manager(), jsonType, request.dbType(), request.docType());
|
||||
}
|
||||
return new GenericObject(request.manager(), jsonType, request.dbType(), request.docType());
|
||||
}
|
||||
|
||||
private Jsonb jsonb(ScalarJsonManager manager) {
|
||||
Object mapper = manager.mapper();
|
||||
return mapper instanceof Jsonb ? (Jsonb) mapper : Jsonb.instance();
|
||||
}
|
||||
|
||||
private Type genericType(ScalarJsonRequest request) {
|
||||
Class<?> type = request.beanType();
|
||||
while (type != null) {
|
||||
try {
|
||||
Field field = type.getDeclaredField(request.name());
|
||||
return field.getGenericType();
|
||||
} catch (NoSuchFieldException e) {
|
||||
type = type.getSuperclass();
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Field not found to match " + request.name());
|
||||
}
|
||||
|
||||
private static final class NoMutationDetection extends Base<Object> {
|
||||
|
||||
NoMutationDetection(ScalarJsonManager jsonManager, JsonType<Object> jsonType, int dbType, DocPropertyType docType) {
|
||||
super(Object.class, jsonManager, jsonType, dbType, docType);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class GenericObject extends Base<Object> {
|
||||
|
||||
private final boolean jsonb;
|
||||
|
||||
GenericObject(ScalarJsonManager jsonManager, JsonType<Object> jsonType, int dbType, DocPropertyType docType) {
|
||||
super(Object.class, jsonManager, jsonType, dbType, docType);
|
||||
this.jsonb = "jsonb".equals(pgType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mutable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean jsonMapper() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object read(DataReader reader) throws SQLException {
|
||||
String json = reader.getString();
|
||||
if (jsonb) {
|
||||
json = JsonTrim.trim(json);
|
||||
}
|
||||
reader.pushJson(json);
|
||||
return parseJson(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(DataBinder binder, Object value) throws SQLException {
|
||||
String rawJson = binder.popJson();
|
||||
if (rawJson == null && value != null) {
|
||||
rawJson = formatValue(value);
|
||||
}
|
||||
bindJson(binder, value, rawJson);
|
||||
}
|
||||
}
|
||||
|
||||
private static abstract class Base<T> extends ScalarTypeBase<T> {
|
||||
|
||||
private final JsonType<T> jsonType;
|
||||
protected final String pgType;
|
||||
private final DocPropertyType docType;
|
||||
|
||||
Base(Class<T> cls, ScalarJsonManager jsonManager, JsonType<T> jsonType, int dbType, DocPropertyType docType) {
|
||||
super(cls, false, dbType);
|
||||
this.jsonType = jsonType;
|
||||
this.pgType = jsonManager.postgresType(dbType);
|
||||
this.docType = docType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T read(DataReader reader) throws SQLException {
|
||||
return parseJson(reader.getString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(DataBinder binder, T value) throws SQLException {
|
||||
bindJson(binder, value, value == null ? null : formatValue(value));
|
||||
}
|
||||
|
||||
final T parseJson(String json) {
|
||||
if (json == null || json.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return jsonType.fromJson(json);
|
||||
} catch (RuntimeException e) {
|
||||
throw new TextException("Failed to parse JSON [{}] as " + jsonType, json, e);
|
||||
}
|
||||
}
|
||||
|
||||
final void bindJson(DataBinder binder, Object value, String rawJson) throws SQLException {
|
||||
if (pgType != null) {
|
||||
binder.setObject(PostgresHelper.asObject(pgType, rawJson));
|
||||
} else if (value == null) {
|
||||
binder.setNull(Types.VARCHAR);
|
||||
} else {
|
||||
binder.setString(rawJson);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Object toJdbcType(Object value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final T toBeanType(Object value) {
|
||||
return (T) value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String formatValue(T value) {
|
||||
try {
|
||||
return jsonType.toJson(value);
|
||||
} catch (RuntimeException e) {
|
||||
throw new PersistenceException("Unable to create JSON", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final T parse(String value) {
|
||||
return parseJson(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DocPropertyType docType() {
|
||||
return docType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final T jsonRead(JsonReader parser) {
|
||||
if (parser.isNullValue()) {
|
||||
return null;
|
||||
}
|
||||
return parseJson(parser.readRaw());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void jsonWrite(JsonWriter writer, T value) throws IOException {
|
||||
if (value == null) {
|
||||
writer.nullValue();
|
||||
} else {
|
||||
writer.rawValue(formatValue(value));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final T readData(DataInput dataInput) throws IOException {
|
||||
return dataInput.readBoolean() ? parse(dataInput.readUTF()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void writeData(DataOutput dataOutput, T value) throws IOException {
|
||||
if (value == null) {
|
||||
dataOutput.writeBoolean(false);
|
||||
} else {
|
||||
dataOutput.writeBoolean(true);
|
||||
dataOutput.writeUTF(format(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import io.ebean.avajejsonb.mapper.ScalarJsonAvajeJsonbMapper;
|
||||
|
||||
module io.ebean.avajejsonb.mapper {
|
||||
|
||||
requires io.avaje.jsonb;
|
||||
requires io.ebean.core.type;
|
||||
|
||||
provides io.ebean.core.type.ScalarJsonMapper with ScalarJsonAvajeJsonbMapper;
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
io.ebean.avajejsonb.mapper.ScalarJsonAvajeJsonbMapper
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package io.ebean.avajejsonb.mapper;
|
||||
|
||||
import io.avaje.json.node.JsonNode;
|
||||
import io.avaje.json.node.JsonObject;
|
||||
import io.ebean.Database;
|
||||
import io.ebean.DatabaseBuilder;
|
||||
import org.example.avajejsonb.JsonbEntity;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class JsonbDatabaseTest {
|
||||
|
||||
@Test
|
||||
void dbJson_roundTripsJsonbPayloadsAndJsonNode() {
|
||||
Database database = buildDatabase();
|
||||
try {
|
||||
JsonbEntity entity = new JsonbEntity();
|
||||
entity.setPayload(new JsonbPayload("main", 1));
|
||||
entity.setPayloads(List.of(new JsonbPayload("first", 2), new JsonbPayload("second", 3)));
|
||||
entity.setNode(JsonObject.create().add("name", "node").add("count", 4));
|
||||
database.save(entity);
|
||||
|
||||
JsonbEntity found = database.find(JsonbEntity.class, entity.getId());
|
||||
|
||||
assertThat(found.getPayload()).isEqualTo(new JsonbPayload("main", 1));
|
||||
assertThat(found.getPayloads()).containsExactly(new JsonbPayload("first", 2), new JsonbPayload("second", 3));
|
||||
JsonNode node = found.getNode();
|
||||
assertThat(node.extract("name")).isEqualTo("node");
|
||||
assertThat(node.extract("count", 0)).isEqualTo(4);
|
||||
} finally {
|
||||
database.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private static Database buildDatabase() {
|
||||
DatabaseBuilder config = Database.builder();
|
||||
config.setName("avajeJsonbMapper");
|
||||
config.setDefaultServer(false);
|
||||
config.setDdlGenerate(true);
|
||||
config.setDdlRun(true);
|
||||
config.setDdlExtra(false);
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("datasource.avajeJsonbMapper.username", "sa");
|
||||
properties.setProperty("datasource.avajeJsonbMapper.password", "");
|
||||
properties.setProperty("datasource.avajeJsonbMapper.databaseUrl", "jdbc:h2:mem:avajeJsonbMapper");
|
||||
properties.setProperty("datasource.avajeJsonbMapper.databaseDriver", "org.h2.Driver");
|
||||
config.loadFromProperties(properties);
|
||||
config.addClass(JsonbEntity.class);
|
||||
return config.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package io.ebean.avajejsonb.mapper;
|
||||
|
||||
import io.avaje.jsonb.Json;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Json
|
||||
public class JsonbPayload {
|
||||
|
||||
public String name;
|
||||
public int count;
|
||||
|
||||
public JsonbPayload() {
|
||||
}
|
||||
|
||||
JsonbPayload(String name, int count) {
|
||||
this.name = name;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (!(object instanceof JsonbPayload)) {
|
||||
return false;
|
||||
}
|
||||
JsonbPayload other = (JsonbPayload) object;
|
||||
return count == other.count && Objects.equals(name, other.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, count);
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
package io.ebean.avajejsonb.mapper;
|
||||
|
||||
import io.avaje.json.node.JsonNode;
|
||||
import io.avaje.json.node.JsonObject;
|
||||
import io.avaje.jsonb.Json;
|
||||
import io.ebean.annotation.MutationDetection;
|
||||
import io.ebean.core.type.DocPropertyType;
|
||||
import io.ebean.core.type.ScalarJsonManager;
|
||||
import io.ebean.core.type.ScalarJsonRequest;
|
||||
import io.ebean.core.type.ScalarType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ScalarJsonAvajeJsonbMapperTest {
|
||||
|
||||
private static final ScalarJsonManager JSON_MANAGER = new ScalarJsonManager() {
|
||||
|
||||
@Override
|
||||
public MutationDetection mutationDetection() {
|
||||
return MutationDetection.HASH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object mapper() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String postgresType(int dbType) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
private final ScalarJsonAvajeJsonbMapper mapper = new ScalarJsonAvajeJsonbMapper();
|
||||
|
||||
@Test
|
||||
void pojo_roundTripsThroughGeneratedJsonbAdapter() {
|
||||
ScalarType<Object> scalarType = scalarType("document", MutationDetection.HASH);
|
||||
Payload payload = new Payload("hello", 42);
|
||||
|
||||
String json = scalarType.formatValue(payload);
|
||||
|
||||
assertThat(json).isEqualTo("{\"name\":\"hello\",\"count\":42}");
|
||||
assertThat(scalarType.parse(json)).isEqualTo(payload);
|
||||
assertThat(scalarType.mutable()).isTrue();
|
||||
assertThat(scalarType.jsonMapper()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void genericList_roundTripsUsingPropertyGenericType() {
|
||||
ScalarType<Object> scalarType = scalarType("payloads", MutationDetection.HASH);
|
||||
List<Payload> payloads = List.of(new Payload("one", 1), new Payload("two", 2));
|
||||
|
||||
String json = scalarType.formatValue(payloads);
|
||||
|
||||
assertThat(json).isEqualTo("[{\"name\":\"one\",\"count\":1},{\"name\":\"two\",\"count\":2}]");
|
||||
assertThat(scalarType.parse(json)).isEqualTo(payloads);
|
||||
}
|
||||
|
||||
@Test
|
||||
void jsonNode_roundTripsThroughAvajeJsonNodeComponent() {
|
||||
ScalarType<Object> scalarType = scalarType("node", MutationDetection.HASH);
|
||||
JsonNode node = JsonObject.create().add("name", "node").add("count", 3);
|
||||
|
||||
String json = scalarType.formatValue(node);
|
||||
|
||||
assertThat(json).isEqualTo("{\"name\":\"node\",\"count\":3}");
|
||||
JsonNode parsed = (JsonNode) scalarType.parse(json);
|
||||
assertThat(parsed.extract("name")).isEqualTo("node");
|
||||
assertThat(parsed.extract("count", 0)).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void mutationDetectionNone_isNotMutable() {
|
||||
ScalarType<Object> scalarType = scalarType("document", MutationDetection.NONE);
|
||||
|
||||
assertThat(scalarType.mutable()).isFalse();
|
||||
assertThat(scalarType.jsonMapper()).isFalse();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ScalarType<Object> scalarType(String property, MutationDetection mutationDetection) {
|
||||
var request = new ScalarJsonRequest(JSON_MANAGER, Types.VARCHAR, DocPropertyType.OBJECT, Entity.class, mutationDetection, property);
|
||||
return (ScalarType<Object>) mapper.createType(request);
|
||||
}
|
||||
|
||||
private static final class Entity {
|
||||
|
||||
Payload document;
|
||||
List<Payload> payloads;
|
||||
JsonNode node;
|
||||
}
|
||||
|
||||
@Json
|
||||
static class Payload {
|
||||
|
||||
public String name;
|
||||
public int count;
|
||||
|
||||
Payload() {
|
||||
}
|
||||
|
||||
Payload(String name, int count) {
|
||||
this.name = name;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (!(object instanceof Payload)) {
|
||||
return false;
|
||||
}
|
||||
Payload other = (Payload) object;
|
||||
return count == other.count && Objects.equals(name, other.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.example.avajejsonb;
|
||||
|
||||
import io.avaje.json.node.JsonNode;
|
||||
import io.ebean.avajejsonb.mapper.JsonbPayload;
|
||||
import io.ebean.annotation.DbJson;
|
||||
import io.ebean.annotation.DbJsonB;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class JsonbEntity {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@DbJson
|
||||
JsonbPayload payload;
|
||||
|
||||
@DbJson
|
||||
List<JsonbPayload> payloads;
|
||||
|
||||
@DbJsonB
|
||||
JsonNode node;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public JsonbPayload getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
public void setPayload(JsonbPayload payload) {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public List<JsonbPayload> getPayloads() {
|
||||
return payloads;
|
||||
}
|
||||
|
||||
public void setPayloads(List<JsonbPayload> payloads) {
|
||||
this.payloads = payloads;
|
||||
}
|
||||
|
||||
public JsonNode getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
public void setNode(JsonNode node) {
|
||||
this.node = node;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
entity-packages: org.example.avajejsonb
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ebean-bench</artifactId>
|
||||
|
||||
+34
-28
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<name>ebean bom</name>
|
||||
@@ -89,25 +89,25 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core-type</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -125,13 +125,19 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-jackson-mapper</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-avajejsonb-mapper</artifactId>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-ddl-generator</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -155,37 +161,37 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>querybean-generator</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>kotlin-querybean-generator</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-test</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-redis</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-spring-txn</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- platforms -->
|
||||
@@ -193,91 +199,91 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-clickhouse</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-db2</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-h2</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-hana</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-mariadb</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-mysql</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-nuodb</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-oracle</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-postgres</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-postgis</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-postgis-types</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-pgvector</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-pgvector-types</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-sqlite</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-sqlserver</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
<artifactId>ebean-core-json</artifactId>
|
||||
<name>ebean-core-json</name>
|
||||
@@ -16,7 +16,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ebean-core-type</artifactId>
|
||||
@@ -16,7 +16,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -29,7 +29,7 @@
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.7.11</version>
|
||||
<version>42.7.12</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
||||
+10
-5
@@ -1,14 +1,19 @@
|
||||
package io.ebean.jackson.mapper;
|
||||
package io.ebean.core.type;
|
||||
|
||||
/**
|
||||
* Helper that removes whitespace from JSON. Used to normalise Postgres JSONB content.
|
||||
* Helper that removes whitespace from JSON content.
|
||||
* <p>
|
||||
* Used to normalise PostgreSQL JSONB content before it is retained for mutation detection.
|
||||
*/
|
||||
final class JsonTrim {
|
||||
public final class JsonTrim {
|
||||
|
||||
private JsonTrim() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return JSON with whitespace trimmed.
|
||||
*/
|
||||
static String trim(String json) {
|
||||
public static String trim(String json) {
|
||||
if (json == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -18,7 +23,7 @@ final class JsonTrim {
|
||||
boolean quoted = false;
|
||||
for (int i = 0; i < len; i++) {
|
||||
char c = json.charAt(i);
|
||||
if (c == '\"') {
|
||||
if (c == '"') {
|
||||
if (!escaped) {
|
||||
quoted = !quoted;
|
||||
} else {
|
||||
+7
-7
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ebean-core</artifactId>
|
||||
@@ -22,13 +22,13 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core-json</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -52,7 +52,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core-type</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -157,21 +157,21 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-h2</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-postgres</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-sqlserver</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -80,6 +80,10 @@ public final class DtoMappingRequest {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String dbName() {
|
||||
return server.name();
|
||||
}
|
||||
|
||||
public String hash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ abstract class DtoQueryPlanBase implements DtoQueryPlan, SpiQueryPlan {
|
||||
private final QueryPlanMetric planMetric;
|
||||
private final TimedMetric metric;
|
||||
private final Class<?> beanType;
|
||||
private final String dbName;
|
||||
private final String name;
|
||||
private final String hash;
|
||||
private final String sql;
|
||||
@@ -26,6 +27,7 @@ abstract class DtoQueryPlanBase implements DtoQueryPlan, SpiQueryPlan {
|
||||
this.planMetric = request.createMetric();
|
||||
this.metric = planMetric.metric();
|
||||
this.beanType = request.type();
|
||||
this.dbName = request.dbName();
|
||||
this.name = request.name();
|
||||
this.hash = request.hash();
|
||||
this.sql = request.sql();
|
||||
@@ -91,6 +93,6 @@ abstract class DtoQueryPlanBase implements DtoQueryPlan, SpiQueryPlan {
|
||||
|
||||
@Override
|
||||
public SpiDbQueryPlan createMeta(String bind, String planString) {
|
||||
return new DQueryPlanOutput(beanType, name, hash, sql, profileLocation, bind, planString);
|
||||
return new DQueryPlanOutput(beanType, dbName, name, hash, sql, profileLocation, bind, planString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,13 @@ public final class BatchControl {
|
||||
*/
|
||||
private int bufferMax;
|
||||
|
||||
/**
|
||||
* True while the batched requests are being executed. A persist performed from a
|
||||
* BeanPersistController callback must not flush the batch that is executing it, the same way
|
||||
* executeNow() stops a query from doing so.
|
||||
*/
|
||||
private boolean executing;
|
||||
|
||||
private final Queue[] queues = new Queue[2];
|
||||
|
||||
static final int DELETE_QUEUE = 0;
|
||||
@@ -139,8 +146,9 @@ public final class BatchControl {
|
||||
* to the depth.
|
||||
*/
|
||||
public int executeStatementOrBatch(PersistRequest request, boolean batch, boolean addBatch) throws BatchedSqlException {
|
||||
if (!batch || (batchFlushOnMixed && !isBeansEmpty())) {
|
||||
// flush when mixing beans and updateSql
|
||||
if (!executing && (!batch || (batchFlushOnMixed && !isBeansEmpty()))) {
|
||||
// flush when mixing beans and updateSql, unless we are inside the execution of the batch
|
||||
// itself : flushing then would issue the statements queued behind the current one early
|
||||
flush();
|
||||
}
|
||||
if (!batch) {
|
||||
@@ -163,8 +171,9 @@ public final class BatchControl {
|
||||
* according to the depth (object graph depth).
|
||||
*/
|
||||
public int executeOrQueue(PersistRequestBean<?> request, boolean batch) throws BatchedSqlException {
|
||||
if (!batch || (batchFlushOnMixed && !pstmtHolder.isEmpty())) {
|
||||
// flush when mixing beans and updateSql
|
||||
if (!executing && (!batch || (batchFlushOnMixed && !pstmtHolder.isEmpty()))) {
|
||||
// flush when mixing beans and updateSql, unless we are inside the execution of the batch
|
||||
// itself : flushing then would issue the statements queued behind the current one early
|
||||
flush();
|
||||
}
|
||||
if (!batch) {
|
||||
@@ -226,7 +235,9 @@ public final class BatchControl {
|
||||
void executeNow(ArrayList<PersistRequest> list) throws BatchedSqlException {
|
||||
boolean old = transaction.isFlushOnQuery();
|
||||
transaction.setFlushOnQuery(false);
|
||||
// disable flush on query due transaction callbacks
|
||||
boolean oldExecuting = executing;
|
||||
executing = true;
|
||||
// disable flush on query and on persist due transaction callbacks
|
||||
try {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (i % batchSize == 0) {
|
||||
@@ -237,6 +248,7 @@ public final class BatchControl {
|
||||
}
|
||||
flushPstmtHolder();
|
||||
} finally {
|
||||
executing = oldExecuting;
|
||||
transaction.setFlushOnQuery(old);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,24 +4,19 @@ import io.ebean.meta.MetricVisitor;
|
||||
import io.ebean.metric.CountMetric;
|
||||
import io.ebean.metric.CountMetricStats;
|
||||
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
|
||||
/**
|
||||
* Used to collect counter metrics.
|
||||
*/
|
||||
final class DCountMetric implements CountMetric {
|
||||
|
||||
private final String name;
|
||||
private final LongAdder count = new LongAdder();
|
||||
private final ValueAdder count = new ValueAdder();
|
||||
private String reportName;
|
||||
|
||||
DCountMetric(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a value. Usually the value is Time or Bytes etc.
|
||||
*/
|
||||
@Override
|
||||
public void add(long value) {
|
||||
count.add(value);
|
||||
@@ -29,12 +24,12 @@ final class DCountMetric implements CountMetric {
|
||||
|
||||
@Override
|
||||
public void increment() {
|
||||
count.increment();
|
||||
count.add(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return count.sum() == 0;
|
||||
return count.currentValue() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,12 +39,25 @@ final class DCountMetric implements CountMetric {
|
||||
|
||||
@Override
|
||||
public long get(boolean reset) {
|
||||
return reset ? count.sumThenReset() : count.sum();
|
||||
return reset ? count.getAndReset() : count.cumulative();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MetricVisitor visitor) {
|
||||
long val = visitor.reset() ? count.sumThenReset() : count.sum();
|
||||
long val;
|
||||
switch (visitor.mode()) {
|
||||
case RESET:
|
||||
val = count.getAndReset();
|
||||
break;
|
||||
case CUMULATIVE:
|
||||
val = count.cumulative();
|
||||
break;
|
||||
case DELTA:
|
||||
val = count.delta();
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown metric collection mode");
|
||||
}
|
||||
if (val > 0) {
|
||||
final String name = reportName != null ? reportName : reportName(visitor);
|
||||
visitor.visitCount(new DCountMetricStats(name, val));
|
||||
|
||||
@@ -20,7 +20,7 @@ final class DQueryPlanMetric implements QueryPlanMetric {
|
||||
|
||||
@Override
|
||||
public void visit(MetricVisitor visitor) {
|
||||
TimedMetricStats stats = metric.collect(visitor.reset());
|
||||
TimedMetricStats stats = metric.collect(visitor.mode());
|
||||
if (stats != null) {
|
||||
String name = reportName != null ? reportName : reportName(visitor);
|
||||
visitor.visitQuery(new Stats(name, meta, stats, collected));
|
||||
|
||||
@@ -3,9 +3,6 @@ package io.ebeaninternal.server.profile;
|
||||
import io.ebean.meta.MetricVisitor;
|
||||
import io.ebean.metric.TimedMetric;
|
||||
|
||||
import java.util.concurrent.atomic.LongAccumulator;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
|
||||
/**
|
||||
* Used to collect timed execution statistics.
|
||||
* <p>
|
||||
@@ -15,14 +12,19 @@ import java.util.concurrent.atomic.LongAdder;
|
||||
final class DTimedMetric implements TimedMetric {
|
||||
|
||||
private final String name;
|
||||
private final LongAdder count = new LongAdder();
|
||||
private final LongAdder total = new LongAdder();
|
||||
private final LongAccumulator max = new LongAccumulator(Math::max, 0);
|
||||
private final ValueAdder count = new ValueAdder();
|
||||
private final ValueAdder total = new ValueAdder();
|
||||
private final ValueMax max;
|
||||
private boolean collected;
|
||||
private String reportName;
|
||||
|
||||
DTimedMetric(String name) {
|
||||
this(name, new ValueMax());
|
||||
}
|
||||
|
||||
DTimedMetric(String name, ValueMax max) {
|
||||
this.name = name;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,7 +34,7 @@ final class DTimedMetric implements TimedMetric {
|
||||
final long mean = totalMicros / batch;
|
||||
count.add(batch);
|
||||
total.add(totalMicros);
|
||||
max.accumulate(mean);
|
||||
max.add(mean);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,14 +45,14 @@ final class DTimedMetric implements TimedMetric {
|
||||
|
||||
@Override
|
||||
public void add(long value) {
|
||||
count.increment();
|
||||
count.add(1);
|
||||
total.add(value);
|
||||
max.accumulate(value);
|
||||
max.add(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return count.sum() == 0;
|
||||
return count.currentValue() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,30 +64,63 @@ final class DTimedMetric implements TimedMetric {
|
||||
|
||||
@Override
|
||||
public void visit(MetricVisitor visitor) {
|
||||
final long countSum = visitor.reset() ? count.sumThenReset() : count.sum();
|
||||
if (countSum > 0) {
|
||||
final DTimeMetricStats stats = collect(visitor.mode());
|
||||
if (stats != null) {
|
||||
final String name = reportName != null ? reportName : reportName(visitor);
|
||||
visitor.visitTimed(stats(visitor.reset(), name, countSum));
|
||||
stats.setName(name);
|
||||
visitor.visitTimed(stats);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DTimeMetricStats collect(boolean reset) {
|
||||
final long countSum = reset ? count.sumThenReset() : count.sum();
|
||||
return collect(reset ? MetricVisitor.Mode.RESET : MetricVisitor.Mode.CUMULATIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DTimeMetricStats collect(MetricVisitor.Mode mode) {
|
||||
final long maxValue = max.collect();
|
||||
final long countSum;
|
||||
switch (mode) {
|
||||
case RESET:
|
||||
countSum = count.getAndReset();
|
||||
break;
|
||||
case CUMULATIVE:
|
||||
countSum = count.cumulative();
|
||||
break;
|
||||
case DELTA:
|
||||
countSum = count.delta();
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown metric collection mode");
|
||||
}
|
||||
if (countSum == 0) {
|
||||
return null;
|
||||
} else {
|
||||
return stats(reset, name, countSum);
|
||||
return stats(mode, name, countSum, maxValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current statistics resetting the internal values if reset is true.
|
||||
*/
|
||||
private DTimeMetricStats stats(boolean reset, String name, long countSum) {
|
||||
private DTimeMetricStats stats(MetricVisitor.Mode mode, String name, long countSum, long maxValue) {
|
||||
try {
|
||||
final long totalSum = reset ? total.sumThenReset() : total.sum();
|
||||
return new DTimeMetricStats(name, collected, countSum, totalSum, max.getThenReset());
|
||||
final long totalSum;
|
||||
switch (mode) {
|
||||
case RESET:
|
||||
totalSum = total.getAndReset();
|
||||
break;
|
||||
case CUMULATIVE:
|
||||
totalSum = total.cumulative();
|
||||
break;
|
||||
case DELTA:
|
||||
totalSum = total.delta();
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown metric collection mode");
|
||||
}
|
||||
return new DTimeMetricStats(name, collected, countSum, totalSum, maxValue);
|
||||
} finally {
|
||||
collected = true;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ final class DTimedProfileLocation extends DProfileLocation implements TimedProfi
|
||||
|
||||
@Override
|
||||
public void visit(MetricVisitor visitor) {
|
||||
TimedMetricStats collect = timedMetric.collect(visitor.reset());
|
||||
TimedMetricStats collect = timedMetric.collect(visitor.mode());
|
||||
if (collect != null) {
|
||||
final String name = reportName != null ? reportName : reportName(visitor, collect.name());
|
||||
collect.setName(name);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package io.ebeaninternal.server.profile;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
|
||||
/**
|
||||
* Accumulates a value while supporting cumulative and reset-based delta reads.
|
||||
*/
|
||||
final class ValueAdder {
|
||||
|
||||
private final LongAdder value = new LongAdder();
|
||||
private final AtomicLong previousValue = new AtomicLong();
|
||||
|
||||
void add(long amount) {
|
||||
value.add(amount);
|
||||
}
|
||||
|
||||
long cumulative() {
|
||||
return value.sum();
|
||||
}
|
||||
|
||||
long delta() {
|
||||
long currentValue = value.sum();
|
||||
long previous = previousValue.getAndSet(currentValue);
|
||||
return currentValue >= previous ? currentValue - previous : currentValue;
|
||||
}
|
||||
|
||||
long getAndReset() {
|
||||
long currentValue = value.sumThenReset();
|
||||
previousValue.set(0);
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
value.reset();
|
||||
previousValue.set(0);
|
||||
}
|
||||
|
||||
long currentValue() {
|
||||
return value.sum();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package io.ebeaninternal.server.profile;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.LongAccumulator;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
/**
|
||||
* Accumulates a maximum value and publishes it in rolling 59-second windows.
|
||||
*/
|
||||
final class ValueMax {
|
||||
|
||||
private static final long WINDOW_NANOS = TimeUnit.SECONDS.toNanos(59);
|
||||
|
||||
private final LongSupplier nanoTime;
|
||||
private final LongAccumulator value;
|
||||
private volatile long published;
|
||||
private long lastResetNanos;
|
||||
|
||||
ValueMax() {
|
||||
this(System::nanoTime);
|
||||
}
|
||||
|
||||
ValueMax(LongSupplier nanoTime) {
|
||||
this.nanoTime = nanoTime;
|
||||
this.value = new LongAccumulator(Math::max, 0);
|
||||
this.lastResetNanos = nanoTime.getAsLong() - 2 * WINDOW_NANOS;
|
||||
}
|
||||
|
||||
void add(long amount) {
|
||||
value.accumulate(amount);
|
||||
}
|
||||
|
||||
synchronized long collect() {
|
||||
long now = nanoTime.getAsLong();
|
||||
if (now - lastResetNanos >= WINDOW_NANOS) {
|
||||
published = value.getThenReset();
|
||||
lastResetNanos = now;
|
||||
}
|
||||
return published;
|
||||
}
|
||||
|
||||
synchronized void reset() {
|
||||
value.reset();
|
||||
published = 0;
|
||||
lastResetNanos = nanoTime.getAsLong() - 2 * WINDOW_NANOS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -274,7 +274,7 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
|
||||
@Override
|
||||
public final DQueryPlanOutput createMeta(String bind, String planString) {
|
||||
return new DQueryPlanOutput(beanType(), name, hash, sql, profileLocation, bind, planString);
|
||||
return new DQueryPlanOutput(beanType(), server.name(), name, hash, sql, profileLocation, bind, planString);
|
||||
}
|
||||
|
||||
public DataReader createDataReader(boolean unmodifiable, ResultSet rset) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.time.Instant;
|
||||
public final class DQueryPlanOutput implements MetaQueryPlan, SpiDbQueryPlan {
|
||||
|
||||
private final Class<?> beanType;
|
||||
private final String dbName;
|
||||
private final String label;
|
||||
private final ProfileLocation profileLocation;
|
||||
|
||||
@@ -25,8 +26,9 @@ public final class DQueryPlanOutput implements MetaQueryPlan, SpiDbQueryPlan {
|
||||
private Instant whenCaptured;
|
||||
private Object tenantId;
|
||||
|
||||
public DQueryPlanOutput(Class<?> beanType, String label, String hash, String sql, ProfileLocation profileLocation, String bind, String plan) {
|
||||
public DQueryPlanOutput(Class<?> beanType, String dbName, String label, String hash, String sql, ProfileLocation profileLocation, String bind, String plan) {
|
||||
this.beanType = beanType;
|
||||
this.dbName = dbName;
|
||||
this.label = label;
|
||||
this.hash = hash;
|
||||
this.sql = sql;
|
||||
@@ -35,6 +37,11 @@ public final class DQueryPlanOutput implements MetaQueryPlan, SpiDbQueryPlan {
|
||||
this.plan = plan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String dbName() {
|
||||
return dbName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String hash() {
|
||||
return hash;
|
||||
|
||||
@@ -21,11 +21,13 @@ public final class SqlQueryPlan implements SpiQueryPlan {
|
||||
private final String name;
|
||||
private final String hash;
|
||||
private final String sql;
|
||||
private final String dbName;
|
||||
private final SpiQueryBindCapture bindCapture;
|
||||
|
||||
SqlQueryPlan(SpiEbeanServer server, String name, String sql) {
|
||||
this.name = name;
|
||||
this.sql = sql;
|
||||
this.dbName = server.name();
|
||||
this.hash = Md5.hash(sql, name);
|
||||
this.bindCapture = server.createQueryBindCapture(this);
|
||||
}
|
||||
@@ -77,6 +79,6 @@ public final class SqlQueryPlan implements SpiQueryPlan {
|
||||
|
||||
@Override
|
||||
public SpiDbQueryPlan createMeta(String bind, String planString) {
|
||||
return new DQueryPlanOutput(null, name, hash, sql, null, bind, planString);
|
||||
return new DQueryPlanOutput(null, dbName, name, hash, sql, null, bind, planString);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -285,7 +285,9 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
|
||||
private SpiTransaction createTransaction(TxScope txScope) {
|
||||
if (txScope.isReadonly()) {
|
||||
return createReadOnlyTransaction(null, false);
|
||||
// Honor isolation on read-only scopes (e.g. @Transactional(readOnly=true, isolation=...))
|
||||
SpiTransaction transaction = createReadOnlyTransaction(null, false);
|
||||
return transactionFactory.setIsolationLevel(transaction, txScope.getIsolationLevel());
|
||||
} else {
|
||||
return createTransaction(true, txScope.getIsolationLevel());
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ public final class DefaultTypeManager implements TypeManager {
|
||||
this.databasePlatform = config.getDatabasePlatform();
|
||||
this.postgres = isPostgresCompatible(config.getDatabasePlatform());
|
||||
this.objectMapperPresent = config.getClassLoadConfig().isJacksonObjectMapperPresent();
|
||||
this.objectMapper = (objectMapperPresent) ? initObjectMapper(config) : null;
|
||||
this.jsonManager = (objectMapperPresent) ? new TypeJsonManager(postgres, objectMapper, config.getJsonMutationDetection()) : null;
|
||||
this.objectMapper = (objectMapperPresent) ? initObjectMapper(config) : config.getObjectMapper();
|
||||
this.jsonManager = new TypeJsonManager(postgres, objectMapper, config.getJsonMutationDetection());
|
||||
this.extraTypeFactory = new DefaultTypeFactory(config);
|
||||
this.arrayTypeListFactory = arrayTypeListFactory(config.getDatabasePlatform());
|
||||
this.arrayTypeSetFactory = arrayTypeSetFactory(config.getDatabasePlatform());
|
||||
@@ -413,7 +413,7 @@ public final class DefaultTypeManager implements TypeManager {
|
||||
|
||||
private ScalarType<?> createJsonObjectMapperType(DeployProperty prop, int dbType, DocPropertyType docType) {
|
||||
if (jsonMapper == null) {
|
||||
throw new IllegalArgumentException("Unsupported @DbJson mapping - Missing dependency ebean-jackson-mapper? Jackson ObjectMapper not present for " + prop);
|
||||
throw new IllegalArgumentException("Unsupported @DbJson mapping - missing JSON mapper dependency for " + prop);
|
||||
}
|
||||
if (MutationDetection.DEFAULT == prop.mutationDetection()) {
|
||||
prop.setMutationDetection(jsonManager.mutationDetection());
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.ebeaninternal.server.profile;
|
||||
|
||||
import io.ebean.meta.BasicMetricVisitor;
|
||||
import io.ebean.meta.MetaCountMetric;
|
||||
import io.ebean.meta.MetricVisitor;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
@@ -40,4 +41,61 @@ class DCountMetricTest {
|
||||
assertThat(result2.get(0).count()).isEqualTo(12);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void cumulativeAndDeltaAreIndependent() {
|
||||
DCountMetric counter = new DCountMetric("org.hello");
|
||||
counter.add(7);
|
||||
|
||||
assertThat(counter.get(false)).isEqualTo(7);
|
||||
assertThat(counter.get(false)).isEqualTo(7);
|
||||
assertThat(counter.get(true)).isEqualTo(7);
|
||||
|
||||
counter.add(5);
|
||||
assertThat(counter.get(false)).isEqualTo(5);
|
||||
assertThat(counter.get(true)).isEqualTo(5);
|
||||
assertThat(counter.get(true)).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void valueAdderSupportsExplicitCollectionOperations() {
|
||||
var values = new ValueAdder();
|
||||
values.add(7);
|
||||
|
||||
assertThat(values.cumulative()).isEqualTo(7);
|
||||
assertThat(values.delta()).isEqualTo(7);
|
||||
|
||||
values.add(5);
|
||||
assertThat(values.cumulative()).isEqualTo(12);
|
||||
assertThat(values.delta()).isEqualTo(5);
|
||||
assertThat(values.getAndReset()).isEqualTo(12);
|
||||
assertThat(values.cumulative()).isEqualTo(0);
|
||||
assertThat(values.delta()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void visitorCanCollectDeltaWithoutResettingCumulativeValue() {
|
||||
var counter = new DCountMetric("org.hello");
|
||||
counter.add(7);
|
||||
|
||||
var cumulative = new BasicMetricVisitor("db", naming, MetricVisitor.Mode.CUMULATIVE, true, true, true);
|
||||
counter.visit(cumulative);
|
||||
assertThat(cumulative.countMetrics()).hasSize(1);
|
||||
assertThat(cumulative.countMetrics().get(0).count()).isEqualTo(7);
|
||||
|
||||
var delta = new BasicMetricVisitor("db", naming, MetricVisitor.Mode.DELTA, true, true, true);
|
||||
counter.visit(delta);
|
||||
assertThat(delta.countMetrics()).hasSize(1);
|
||||
assertThat(delta.countMetrics().get(0).count()).isEqualTo(7);
|
||||
|
||||
counter.add(5);
|
||||
delta = new BasicMetricVisitor("db", naming, MetricVisitor.Mode.DELTA, true, true, true);
|
||||
counter.visit(delta);
|
||||
assertThat(delta.countMetrics()).hasSize(1);
|
||||
assertThat(delta.countMetrics().get(0).count()).isEqualTo(5);
|
||||
|
||||
cumulative = new BasicMetricVisitor("db", naming, MetricVisitor.Mode.CUMULATIVE, true, true, true);
|
||||
counter.visit(cumulative);
|
||||
assertThat(cumulative.countMetrics().get(0).count()).isEqualTo(12);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,19 +5,22 @@ import io.ebean.meta.MetaQueryMetric;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class DQueryPlanMetricTest {
|
||||
|
||||
private final AtomicLong nanoTime = new AtomicLong();
|
||||
Function<String, String> naming = (String name) -> "prefix[" + name.replace('.', '-') + "]";
|
||||
|
||||
@Test
|
||||
void visit() {
|
||||
|
||||
DQueryPlanMeta meta = new DQueryPlanMeta(Object.class, "dto.Object.lab", "lab", null, "sql", "hash");
|
||||
DTimedMetric metric = new DTimedMetric("org.timed.plan");
|
||||
DTimedMetric metric = new DTimedMetric("org.timed.plan", new ValueMax(nanoTime::get));
|
||||
DQueryPlanMetric planMetric = new DQueryPlanMetric(meta, metric);
|
||||
|
||||
metric.add(560);
|
||||
@@ -46,10 +49,10 @@ class DQueryPlanMetricTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void visitCumulativeResetsMax() {
|
||||
void visitCumulativePublishesSharedMax() {
|
||||
|
||||
DQueryPlanMeta meta = new DQueryPlanMeta(Object.class, "dto.Object.lab", "lab", null, "sql", "hash");
|
||||
DTimedMetric metric = new DTimedMetric("org.timed.plan");
|
||||
DTimedMetric metric = new DTimedMetric("org.timed.plan", new ValueMax(nanoTime::get));
|
||||
DQueryPlanMetric planMetric = new DQueryPlanMetric(meta, metric);
|
||||
|
||||
metric.add(560);
|
||||
@@ -74,7 +77,7 @@ class DQueryPlanMetricTest {
|
||||
assertThat(result.get(0).name()).isEqualTo("prefix[dto-Object-lab]");
|
||||
assertThat(result.get(0).count()).isEqualTo(2);
|
||||
assertThat(result.get(0).total()).isEqualTo(820);
|
||||
assertThat(result.get(0).max()).isEqualTo(0);
|
||||
assertThat(result.get(0).max()).isEqualTo(560);
|
||||
}
|
||||
|
||||
metric.add(410);
|
||||
@@ -87,7 +90,14 @@ class DQueryPlanMetricTest {
|
||||
assertThat(result.get(0).name()).isEqualTo("prefix[dto-Object-lab]");
|
||||
assertThat(result.get(0).count()).isEqualTo(3);
|
||||
assertThat(result.get(0).total()).isEqualTo(1230);
|
||||
assertThat(result.get(0).max()).isEqualTo(410);
|
||||
assertThat(result.get(0).max()).isEqualTo(560);
|
||||
}
|
||||
|
||||
nanoTime.addAndGet(TimeUnit.SECONDS.toNanos(59));
|
||||
BasicMetricVisitor visitor = new BasicMetricVisitor("v", naming, false, true, true, true);
|
||||
planMetric.visit(visitor);
|
||||
List<MetaQueryMetric> result = visitor.queryMetrics();
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.get(0).max()).isEqualTo(410);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,16 +5,20 @@ import io.ebean.meta.MetaTimedMetric;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class DTimedMetricTest {
|
||||
|
||||
private final AtomicLong nanoTime = new AtomicLong();
|
||||
|
||||
@Test
|
||||
public void addSinceNanos() throws InterruptedException {
|
||||
|
||||
DTimedMetric metric = new DTimedMetric("addSinceNanos");
|
||||
DTimedMetric metric = new DTimedMetric("addSinceNanos", new ValueMax(nanoTime::get));
|
||||
|
||||
long start = System.nanoTime();
|
||||
Thread.sleep(11);
|
||||
@@ -28,6 +32,7 @@ public class DTimedMetricTest {
|
||||
|
||||
metric.addSinceNanos(start);
|
||||
|
||||
nanoTime.addAndGet(TimeUnit.SECONDS.toNanos(59));
|
||||
stats = metric.collect(true);
|
||||
assertThat(stats.count()).isEqualTo(1);
|
||||
assertThat(stats.total()).isGreaterThan(10);
|
||||
@@ -37,7 +42,7 @@ public class DTimedMetricTest {
|
||||
@Test
|
||||
public void addBatchSince() throws InterruptedException {
|
||||
|
||||
DTimedMetric metric = new DTimedMetric("addSinceNanos");
|
||||
DTimedMetric metric = new DTimedMetric("addSinceNanos", new ValueMax(nanoTime::get));
|
||||
|
||||
long start = System.nanoTime();
|
||||
Thread.sleep(11);
|
||||
@@ -52,6 +57,7 @@ public class DTimedMetricTest {
|
||||
|
||||
metric.addBatchSince(start, 2);
|
||||
|
||||
nanoTime.addAndGet(TimeUnit.SECONDS.toNanos(59));
|
||||
stats = metric.collect(true);
|
||||
assertThat(stats.count()).isEqualTo(2);
|
||||
assertThat(stats.total()).isGreaterThan(10000);
|
||||
@@ -92,8 +98,8 @@ public class DTimedMetricTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void collectCumulativeResetsMax() {
|
||||
DTimedMetric metric = new DTimedMetric("org.timed");
|
||||
void collectCumulativePublishesSharedMax() {
|
||||
DTimedMetric metric = new DTimedMetric("org.timed", new ValueMax(nanoTime::get));
|
||||
metric.add(560);
|
||||
metric.add(500);
|
||||
|
||||
@@ -105,7 +111,7 @@ public class DTimedMetricTest {
|
||||
stats = metric.collect(false);
|
||||
assertThat(stats.count()).isEqualTo(2);
|
||||
assertThat(stats.total()).isEqualTo(1060);
|
||||
assertThat(stats.max()).isEqualTo(0);
|
||||
assertThat(stats.max()).isEqualTo(560);
|
||||
|
||||
metric.add(160);
|
||||
metric.add(100);
|
||||
@@ -114,6 +120,31 @@ public class DTimedMetricTest {
|
||||
stats = metric.collect(false);
|
||||
assertThat(stats.count()).isEqualTo(5);
|
||||
assertThat(stats.total()).isEqualTo(1470);
|
||||
assertThat(stats.max()).isEqualTo(560);
|
||||
|
||||
nanoTime.addAndGet(TimeUnit.SECONDS.toNanos(59));
|
||||
stats = metric.collect(false);
|
||||
assertThat(stats.max()).isEqualTo(160);
|
||||
}
|
||||
|
||||
@Test
|
||||
void cumulativeAndDeltaAreIndependent() {
|
||||
DTimedMetric metric = new DTimedMetric("org.timed", new ValueMax(nanoTime::get));
|
||||
metric.add(560);
|
||||
metric.add(500);
|
||||
|
||||
DTimeMetricStats cumulative = metric.collect(false);
|
||||
assertThat(cumulative.count()).isEqualTo(2);
|
||||
assertThat(cumulative.total()).isEqualTo(1060);
|
||||
|
||||
metric.add(160);
|
||||
|
||||
DTimeMetricStats delta = metric.collect(true);
|
||||
assertThat(delta.count()).isEqualTo(3);
|
||||
assertThat(delta.total()).isEqualTo(1220);
|
||||
assertThat(delta.max()).isEqualTo(560);
|
||||
|
||||
cumulative = metric.collect(false);
|
||||
assertThat(cumulative).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<name>ebean ddl generation</name>
|
||||
@@ -28,14 +28,14 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core-type</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-all</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core-type</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.ebean.jackson.mapper;
|
||||
|
||||
|
||||
import io.ebean.core.type.JsonTrim;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<name>ebean net postgis types</name>
|
||||
@@ -19,14 +19,14 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-postgres</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- provided scope -->
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-test</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ebean-opentelemetry</artifactId>
|
||||
@@ -28,7 +28,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -71,21 +71,21 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-test</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>querybean-generator</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<name>ebean pgvector types</name>
|
||||
@@ -19,14 +19,14 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-postgres</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- provided scope -->
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-test</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<name>ebean postgis types</name>
|
||||
@@ -19,14 +19,14 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-postgres</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- provided scope -->
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.7.11</version>
|
||||
<version>42.7.12</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-test</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<name>ebean querybean</name>
|
||||
@@ -17,7 +17,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -59,14 +59,14 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-ddl-generator</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-test</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>querybean-generator</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
+6
-6
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ebean-redis</artifactId>
|
||||
@@ -29,35 +29,35 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-test</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>querybean-generator</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ ebean:
|
||||
dumpMetricsOptions: sql,hash,loc
|
||||
test:
|
||||
registerTestTenantProvider: false
|
||||
redis: latest
|
||||
redis: 8.6.2
|
||||
# shutdown: stop # stop | remove
|
||||
platform: h2 # h2, postgres, mysql, oracle, sqlserver, sqlite
|
||||
ddlMode: dropCreate # none | dropCreate | create | migration | createOnly | migrationDropCreate
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ebean-redisson</artifactId>
|
||||
@@ -29,35 +29,35 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-api</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-querybean</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-test</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>querybean-generator</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
+2
-2
@@ -10,13 +10,13 @@ import jakarta.persistence.Entity;
|
||||
@SuppressWarnings("unused")
|
||||
@Cache(naturalKey = {"one", "two"})
|
||||
@Entity
|
||||
public class OtherOne extends EBase {
|
||||
public class FOtherOne extends EBase {
|
||||
|
||||
private final String one;
|
||||
private final String two;
|
||||
private String notes;
|
||||
|
||||
public OtherOne(String one, String two, String notes) {
|
||||
public FOtherOne(String one, String two, String notes) {
|
||||
this.one = one;
|
||||
this.two = two;
|
||||
this.notes = notes;
|
||||
+2
-2
@@ -11,7 +11,7 @@ import java.time.LocalDate;
|
||||
@Cache(enableQueryCache = true, nearCache = true, naturalKey = "name")
|
||||
@CacheBeanTuning(maxSecsToLive = 1)
|
||||
@Entity
|
||||
public class Person extends EBase {
|
||||
public class FPerson extends EBase {
|
||||
|
||||
public enum Status {
|
||||
NEW,
|
||||
@@ -33,7 +33,7 @@ public class Person extends EBase {
|
||||
*/
|
||||
String key;
|
||||
|
||||
public Person(String name) {
|
||||
public FPerson(String name) {
|
||||
this.name = name;
|
||||
this.status = Status.NEW;
|
||||
}
|
||||
+2
-2
@@ -7,12 +7,12 @@ import jakarta.persistence.Entity;
|
||||
|
||||
@Cache(naturalKey = "name")
|
||||
@Entity
|
||||
public class RCust extends EBase {
|
||||
public class FRCust extends EBase {
|
||||
|
||||
@Index(unique = true)
|
||||
String name;
|
||||
|
||||
public RCust(String name) {
|
||||
public FRCust(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@ import jakarta.persistence.ManyToOne;
|
||||
|
||||
@Cache
|
||||
@Entity
|
||||
public class UChild extends Model {
|
||||
public class FUChild extends Model {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
@@ -16,9 +16,9 @@ public class UChild extends Model {
|
||||
String name;
|
||||
|
||||
@ManyToOne
|
||||
final UParent parent;
|
||||
final FUParent parent;
|
||||
|
||||
public UChild(UParent parent, String name) {
|
||||
public FUChild(FUParent parent, String name) {
|
||||
this.parent = parent;
|
||||
this.name = name;
|
||||
}
|
||||
+4
-4
@@ -15,7 +15,7 @@ import java.util.UUID;
|
||||
@Cache(enableQueryCache = true)
|
||||
@CacheBeanTuning(maxSecsToLive = 1)
|
||||
@Entity
|
||||
public class UParent extends Model {
|
||||
public class FUParent extends Model {
|
||||
|
||||
@Id
|
||||
private UUID id;
|
||||
@@ -23,9 +23,9 @@ public class UParent extends Model {
|
||||
private String name;
|
||||
|
||||
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
|
||||
private final List<UChild> children = new ArrayList<>();
|
||||
private final List<FUChild> children = new ArrayList<>();
|
||||
|
||||
public UParent(String name) {
|
||||
public FUParent(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class UParent extends Model {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<UChild> children() {
|
||||
public List<FUChild> children() {
|
||||
return children;
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
|
||||
@Cache
|
||||
@Entity
|
||||
public class TestOne extends Model {
|
||||
public class RTestOne extends Model {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
@@ -18,9 +18,9 @@ public class TestOne extends Model {
|
||||
private String otherUnique;
|
||||
|
||||
@OneToMany(mappedBy = "testOne", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private List<TestTwo> testTwos = new ArrayList<>();
|
||||
private List<RTestTwo> testTwos = new ArrayList<>();
|
||||
|
||||
public TestOne(String id, String otherUnique) {
|
||||
public RTestOne(String id, String otherUnique) {
|
||||
this.id = id;
|
||||
this.otherUnique = otherUnique;
|
||||
}
|
||||
@@ -37,11 +37,11 @@ public class TestOne extends Model {
|
||||
this.otherUnique = otherUnique;
|
||||
}
|
||||
|
||||
public List<TestTwo> getTestTwos() {
|
||||
public List<RTestTwo> getTestTwos() {
|
||||
return testTwos;
|
||||
}
|
||||
|
||||
public void setTestTwos(List<TestTwo> testTwos) {
|
||||
public void setTestTwos(List<RTestTwo> testTwos) {
|
||||
this.testTwos = testTwos;
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -7,16 +7,16 @@ import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class TestTwo extends Model {
|
||||
public class RTestTwo extends Model {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn
|
||||
private TestOne testOne;
|
||||
private RTestOne testOne;
|
||||
|
||||
public TestTwo(String id) {
|
||||
public RTestTwo(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@ public class TestTwo extends Model {
|
||||
return id;
|
||||
}
|
||||
|
||||
public TestOne getTestOne() {
|
||||
public RTestOne getTestOne() {
|
||||
return testOne;
|
||||
}
|
||||
|
||||
public void setTestOne(TestOne testOne) {
|
||||
public void setTestOne(RTestOne testOne) {
|
||||
this.testOne = testOne;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package org.integration;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Database;
|
||||
import io.ebean.redisson.DuelCache;
|
||||
import org.domain.Person;
|
||||
import org.domain.query.QPerson;
|
||||
import org.domain.FPerson;
|
||||
import org.domain.query.QFPerson;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -37,65 +37,65 @@ class ClusterTest {
|
||||
|
||||
@Test
|
||||
void testBothNear() throws InterruptedException {
|
||||
new QPerson()
|
||||
new QFPerson()
|
||||
.name.eq("Someone")
|
||||
.delete();
|
||||
|
||||
Person foo = new Person("Someone");
|
||||
FPerson foo = new FPerson("Someone");
|
||||
foo.save();
|
||||
|
||||
DB.cacheManager().clearAll();
|
||||
db.metaInfo().resetAllMetrics();
|
||||
other.metaInfo().resetAllMetrics();
|
||||
|
||||
Person fooA = DB.find(Person.class, foo.getId());
|
||||
FPerson fooA = DB.find(FPerson.class, foo.getId());
|
||||
allowAsyncMessaging(); // allow time for background cache load
|
||||
Person fooB = other.find(Person.class, foo.getId());
|
||||
FPerson fooB = other.find(FPerson.class, foo.getId());
|
||||
|
||||
DuelCache dualCacheA = db.cacheManager().beanCache(Person.class).unwrap(DuelCache.class);
|
||||
DuelCache dualCacheA = db.cacheManager().beanCache(FPerson.class).unwrap(DuelCache.class);
|
||||
assertCounts(dualCacheA, 0, 1, 0, 1);
|
||||
fooA = DB.find(Person.class, foo.getId());
|
||||
fooA = DB.find(FPerson.class, foo.getId());
|
||||
assertCounts(dualCacheA, 1, 1, 0, 1);
|
||||
fooB = other.find(Person.class, foo.getId());
|
||||
fooA = DB.find(Person.class, foo.getId());
|
||||
fooB = other.find(FPerson.class, foo.getId());
|
||||
fooA = DB.find(FPerson.class, foo.getId());
|
||||
assertCounts(dualCacheA, 2, 1, 0, 1);
|
||||
fooB = other.find(Person.class, foo.getId());
|
||||
DuelCache dualCacheB = other.cacheManager().beanCache(Person.class).unwrap(DuelCache.class);
|
||||
fooB = other.find(FPerson.class, foo.getId());
|
||||
DuelCache dualCacheB = other.cacheManager().beanCache(FPerson.class).unwrap(DuelCache.class);
|
||||
assertCounts(dualCacheB, 2, 1, 1, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void test() throws InterruptedException {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Person foo = new Person("name " + i);
|
||||
FPerson foo = new FPerson("name " + i);
|
||||
foo.save();
|
||||
}
|
||||
|
||||
other.cacheManager().clearAll();
|
||||
other.metaInfo().resetAllMetrics();
|
||||
|
||||
DuelCache dualCache = other.cacheManager().beanCache(Person.class).unwrap(DuelCache.class);
|
||||
DuelCache dualCache = other.cacheManager().beanCache(FPerson.class).unwrap(DuelCache.class);
|
||||
|
||||
Person foo0 = other.find(Person.class, 1);
|
||||
FPerson foo0 = other.find(FPerson.class, 1);
|
||||
assertCounts(dualCache, 0, 1, 0, 1);
|
||||
|
||||
other.find(Person.class, 1);
|
||||
other.find(FPerson.class, 1);
|
||||
assertCounts(dualCache, 1, 1, 0, 1);
|
||||
|
||||
other.find(Person.class, 1);
|
||||
other.find(FPerson.class, 1);
|
||||
assertCounts(dualCache, 2, 1, 0, 1);
|
||||
|
||||
other.find(Person.class, 1);
|
||||
other.find(FPerson.class, 1);
|
||||
assertCounts(dualCache, 3, 1, 0, 1);
|
||||
|
||||
other.find(Person.class, 2);
|
||||
other.find(FPerson.class, 2);
|
||||
assertCounts(dualCache, 3, 2, 0, 2);
|
||||
|
||||
foo0.setName("name2");
|
||||
foo0.save();
|
||||
allowAsyncMessaging();
|
||||
|
||||
Person foo3 = other.find(Person.class, 1);
|
||||
FPerson foo3 = other.find(FPerson.class, 1);
|
||||
assertThat(foo3.getName()).isEqualTo("name2");
|
||||
assertCounts(dualCache, 3, 3, 1, 2);
|
||||
|
||||
@@ -103,7 +103,7 @@ class ClusterTest {
|
||||
foo0.save();
|
||||
allowAsyncMessaging();
|
||||
|
||||
foo3 = other.find(Person.class, 1);
|
||||
foo3 = other.find(FPerson.class, 1);
|
||||
assertThat(foo3.getName()).isEqualTo("name3");
|
||||
assertCounts(dualCache, 3, 4, 2, 2);
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ import io.ebean.cache.ServerCache;
|
||||
import io.ebean.cache.ServerCacheStatistics;
|
||||
import io.ebeaninternal.server.cache.CachedBeanData;
|
||||
import org.domain.*;
|
||||
import org.domain.query.QOtherOne;
|
||||
import org.domain.query.QPerson;
|
||||
import org.domain.query.QRCust;
|
||||
import org.domain.test.TestOne;
|
||||
import org.domain.query.QFOtherOne;
|
||||
import org.domain.query.QFPerson;
|
||||
import org.domain.query.QFRCust;
|
||||
import org.domain.test.RTestOne;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDate;
|
||||
@@ -21,8 +21,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class IntegrationTest {
|
||||
|
||||
private static OtherOne findOther(String a, String b) {
|
||||
return new QOtherOne()
|
||||
private static FOtherOne findOther(String a, String b) {
|
||||
return new QFOtherOne()
|
||||
.one.eq(a)
|
||||
.two.eq(b)
|
||||
.findOne();
|
||||
@@ -30,22 +30,22 @@ class IntegrationTest {
|
||||
|
||||
@Test
|
||||
void uuid_getPut() {
|
||||
UParent b0 = new UParent("b0");
|
||||
b0.children().add(new UChild(b0, "b0c0"));
|
||||
b0.children().add(new UChild(b0, "b0c1"));
|
||||
FUParent b0 = new FUParent("b0");
|
||||
b0.children().add(new FUChild(b0, "b0c0"));
|
||||
b0.children().add(new FUChild(b0, "b0c1"));
|
||||
b0.save();
|
||||
|
||||
ServerCache beanCache = DB.cacheManager().beanCache(UParent.class);
|
||||
ServerCache beanCache = DB.cacheManager().beanCache(FUParent.class);
|
||||
beanCache.clear();
|
||||
beanCache.statistics(true);
|
||||
|
||||
UParent found0 = DB.find(UParent.class, b0.id());
|
||||
FUParent found0 = DB.find(FUParent.class, b0.id());
|
||||
assertThat(found0.name()).isEqualTo("b0");
|
||||
|
||||
List<UChild> children = found0.children();
|
||||
List<FUChild> children = found0.children();
|
||||
assertThat(children).hasSize(2);
|
||||
|
||||
UParent found1 = DB.find(UParent.class, b0.id());
|
||||
FUParent found1 = DB.find(FUParent.class, b0.id());
|
||||
assertThat(found1.name()).isEqualTo("b0");
|
||||
|
||||
DB.delete(found1);
|
||||
@@ -57,13 +57,13 @@ class IntegrationTest {
|
||||
@Test
|
||||
void mget_when_emptyCollectionOfIds() {
|
||||
|
||||
List<RCust> f0 = new QRCust()
|
||||
List<FRCust> f0 = new QFRCust()
|
||||
.setIdIn(Collections.emptyList())
|
||||
.findList();
|
||||
|
||||
assertThat(f0).isEmpty();
|
||||
|
||||
List<RCust> f1 = new QRCust()
|
||||
List<FRCust> f1 = new QFRCust()
|
||||
.id.in(Collections.emptyList())
|
||||
.findList();
|
||||
|
||||
@@ -73,18 +73,18 @@ class IntegrationTest {
|
||||
@Test
|
||||
void mput_via_setIdIn() throws InterruptedException {
|
||||
|
||||
ServerCache beanCache = DB.cacheManager().beanCache(RCust.class);
|
||||
ServerCache beanCache = DB.cacheManager().beanCache(FRCust.class);
|
||||
beanCache.clear();
|
||||
beanCache.statistics(true);
|
||||
|
||||
List<RCust> people = new ArrayList<>();
|
||||
List<FRCust> people = new ArrayList<>();
|
||||
for (String name : new String[]{"mp0", "mp1", "mp2"}) {
|
||||
people.add(new RCust(name));
|
||||
people.add(new FRCust(name));
|
||||
}
|
||||
DB.saveAll(people);
|
||||
List<Long> ids = people.stream().map(RCust::getId).collect(Collectors.toList());
|
||||
List<Long> ids = people.stream().map(FRCust::getId).collect(Collectors.toList());
|
||||
|
||||
List<RCust> f0 = new QRCust()
|
||||
List<FRCust> f0 = new QFRCust()
|
||||
.setIdIn(ids) // using collection argument
|
||||
.findList();
|
||||
|
||||
@@ -95,7 +95,7 @@ class IntegrationTest {
|
||||
Thread.sleep(5);
|
||||
|
||||
// we will hit the cache this time
|
||||
List<RCust> f1 = new QRCust()
|
||||
List<FRCust> f1 = new QFRCust()
|
||||
.setIdIn(ids.toArray()) // using varargs argument
|
||||
.findList();
|
||||
|
||||
@@ -104,7 +104,7 @@ class IntegrationTest {
|
||||
assertThat(stats1.getHitCount()).isEqualTo(3);
|
||||
|
||||
// we will hit the cache again
|
||||
List<RCust> f2 = new QRCust()
|
||||
List<FRCust> f2 = new QFRCust()
|
||||
.setIdIn(ids) // using collection argument
|
||||
.findList();
|
||||
assertThat(f2).hasSize(3);
|
||||
@@ -115,18 +115,18 @@ class IntegrationTest {
|
||||
@Test
|
||||
void mput_via_propertyInExpression() throws InterruptedException {
|
||||
|
||||
ServerCache beanCache = DB.cacheManager().beanCache(RCust.class);
|
||||
ServerCache beanCache = DB.cacheManager().beanCache(FRCust.class);
|
||||
beanCache.clear();
|
||||
beanCache.statistics(true);
|
||||
|
||||
List<RCust> people = new ArrayList<>();
|
||||
List<FRCust> people = new ArrayList<>();
|
||||
for (String name : new String[]{"mpx0", "mpx1", "mpx2"}) {
|
||||
people.add(new RCust(name));
|
||||
people.add(new FRCust(name));
|
||||
}
|
||||
DB.saveAll(people);
|
||||
List<Long> ids = people.stream().map(RCust::getId).collect(Collectors.toList());
|
||||
List<Long> ids = people.stream().map(FRCust::getId).collect(Collectors.toList());
|
||||
|
||||
List<RCust> f0 = new QRCust()
|
||||
List<FRCust> f0 = new QFRCust()
|
||||
.id.in(ids)
|
||||
.findList();
|
||||
|
||||
@@ -137,7 +137,7 @@ class IntegrationTest {
|
||||
Thread.sleep(5);
|
||||
|
||||
// we will hit the cache this time
|
||||
List<RCust> f1 = new QRCust()
|
||||
List<FRCust> f1 = new QFRCust()
|
||||
.id.in(ids)
|
||||
.findList();
|
||||
|
||||
@@ -146,7 +146,7 @@ class IntegrationTest {
|
||||
assertThat(stats1.getHitCount()).isEqualTo(3);
|
||||
|
||||
// we will hit the cache again
|
||||
List<RCust> f2 = new QRCust()
|
||||
List<FRCust> f2 = new QFRCust()
|
||||
.id.isIn(ids)
|
||||
.findList();
|
||||
assertThat(f2).hasSize(3);
|
||||
@@ -156,18 +156,18 @@ class IntegrationTest {
|
||||
|
||||
@Test
|
||||
void testOtherOne() {
|
||||
DB.save(new OtherOne("A", "B", "ab"));
|
||||
DB.save(new OtherOne("A", "C", "ac"));
|
||||
DB.save(new OtherOne("B", "B", "bb"));
|
||||
DB.save(new FOtherOne("A", "B", "ab"));
|
||||
DB.save(new FOtherOne("A", "C", "ac"));
|
||||
DB.save(new FOtherOne("B", "B", "bb"));
|
||||
|
||||
ServerCache nkeyCache = DB.cacheManager().naturalKeyCache(OtherOne.class);
|
||||
ServerCache nkeyCache = DB.cacheManager().naturalKeyCache(FOtherOne.class);
|
||||
nkeyCache.clear();
|
||||
nkeyCache.statistics(true);
|
||||
|
||||
OtherOne ab0 = findOther("A", "B");
|
||||
OtherOne ab1 = findOther("A", "B");
|
||||
OtherOne ab2 = findOther("A", "B");
|
||||
OtherOne bb = findOther("B", "B");
|
||||
FOtherOne ab0 = findOther("A", "B");
|
||||
FOtherOne ab1 = findOther("A", "B");
|
||||
FOtherOne ab2 = findOther("A", "B");
|
||||
FOtherOne bb = findOther("B", "B");
|
||||
|
||||
assertThat(ab0).isNotNull();
|
||||
assertThat(ab1).isNotNull();
|
||||
@@ -183,21 +183,21 @@ class IntegrationTest {
|
||||
|
||||
insertSomePeople();
|
||||
|
||||
Person fiona = findByName("Fiona");
|
||||
FPerson fiona = findByName("Fiona");
|
||||
fiona.setName("Fortuna");
|
||||
fiona.setLocalDate(LocalDate.now());
|
||||
fiona.update();
|
||||
|
||||
Thread.sleep(100);
|
||||
|
||||
Person one = findById(1);
|
||||
FPerson one = findById(1);
|
||||
assertThat(one).isNotNull();
|
||||
|
||||
for (int i = 1; i < 4; i++) {
|
||||
System.out.println("hit " + findById(i));
|
||||
}
|
||||
|
||||
List<Person> one2 = nameStartsWith("fo");
|
||||
List<FPerson> one2 = nameStartsWith("fo");
|
||||
assertThat(one2).hasSize(1);
|
||||
|
||||
one2 = nameStartsWith("j");
|
||||
@@ -207,7 +207,7 @@ class IntegrationTest {
|
||||
assertThat(one2).hasSize(2);
|
||||
|
||||
|
||||
List<Person> byNames = findByNames("Jack", "Rob");
|
||||
List<FPerson> byNames = findByNames("Jack", "Rob");
|
||||
assertThat(byNames).hasSize(2);
|
||||
|
||||
byNames = findByNames("Jack", "Rob", "Moby");
|
||||
@@ -228,40 +228,40 @@ class IntegrationTest {
|
||||
|
||||
System.out.println("one2 " + one2);
|
||||
|
||||
DB.cacheManager().clear(Person.class);
|
||||
DB.cacheManager().clear(FPerson.class);
|
||||
|
||||
System.out.println("done");
|
||||
}
|
||||
|
||||
private void insertSomePeople() {
|
||||
List<Person> people = new ArrayList<>();
|
||||
List<FPerson> people = new ArrayList<>();
|
||||
for (String name : new String[]{"Jack", "John", "Rob", "Moby", "Fiona"}) {
|
||||
people.add(new Person(name));
|
||||
people.add(new FPerson(name));
|
||||
}
|
||||
DB.saveAll(people);
|
||||
}
|
||||
|
||||
private Person findByName(String name) {
|
||||
return new QPerson()
|
||||
private FPerson findByName(String name) {
|
||||
return new QFPerson()
|
||||
.name.eq(name)
|
||||
.findOne();
|
||||
}
|
||||
|
||||
private List<Person> findByNames(String... names) {
|
||||
return new QPerson()
|
||||
private List<FPerson> findByNames(String... names) {
|
||||
return new QFPerson()
|
||||
.name.in(names)
|
||||
.setUseCache(true)
|
||||
.findList();
|
||||
}
|
||||
|
||||
private Person findById(int id) {
|
||||
return new QPerson()
|
||||
private FPerson findById(int id) {
|
||||
return new QFPerson()
|
||||
.id.eq(id)
|
||||
.findOne();
|
||||
}
|
||||
|
||||
private List<Person> nameStartsWith(String pattern) {
|
||||
return new QPerson()
|
||||
private List<FPerson> nameStartsWith(String pattern) {
|
||||
return new QFPerson()
|
||||
.name.istartsWith(pattern)
|
||||
.setUseQueryCache(true)
|
||||
.findList();
|
||||
@@ -273,15 +273,15 @@ class IntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void versionGated_newerCached_staleWriteIsIgnored() throws InterruptedException {
|
||||
ServerCache beanCache = DB.cacheManager().beanCache(RCust.class);
|
||||
ServerCache beanCache = DB.cacheManager().beanCache(FRCust.class);
|
||||
beanCache.clear();
|
||||
|
||||
RCust cust = new RCust("stale-test-orig");
|
||||
FRCust cust = new FRCust("stale-test-orig");
|
||||
DB.save(cust);
|
||||
long id = cust.getId();
|
||||
|
||||
// prime cache at version 1
|
||||
DB.find(RCust.class, id);
|
||||
DB.find(FRCust.class, id);
|
||||
Thread.sleep(150);
|
||||
Object staleV1 = beanCache.get(id);
|
||||
assertThat(staleV1).isNotNull();
|
||||
@@ -289,7 +289,7 @@ class IntegrationTest {
|
||||
// update to version 2; ensure v2 is in cache
|
||||
cust.setName("stale-test-updated");
|
||||
DB.save(cust);
|
||||
DB.find(RCust.class, id);
|
||||
DB.find(FRCust.class, id);
|
||||
Thread.sleep(150);
|
||||
|
||||
// stale write attempt: v2 is cached, v1 should be rejected
|
||||
@@ -302,7 +302,7 @@ class IntegrationTest {
|
||||
assertThat(((CachedBeanData) staleV2).getVersion()).isEqualTo(2L);
|
||||
|
||||
beanCache.statistics(true);
|
||||
RCust found = DB.find(RCust.class, id);
|
||||
FRCust found = DB.find(FRCust.class, id);
|
||||
ServerCacheStatistics stats = beanCache.statistics(true);
|
||||
assertThat(stats.getHitCount()).isEqualTo(1);
|
||||
assertThat(found.getVersion()).isEqualTo(2L);
|
||||
@@ -316,14 +316,14 @@ class IntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void zeroVersion_equalVersion_staleWriteIsNotBlocked() throws InterruptedException {
|
||||
ServerCache beanCache = DB.cacheManager().beanCache(TestOne.class);
|
||||
ServerCache beanCache = DB.cacheManager().beanCache(RTestOne.class);
|
||||
beanCache.clear();
|
||||
|
||||
TestOne t1 = new TestOne("zvw-test", "unique-a");
|
||||
RTestOne t1 = new RTestOne("zvw-test", "unique-a");
|
||||
DB.save(t1);
|
||||
|
||||
// prime cache at version 0 (no @Version field)
|
||||
DB.find(TestOne.class, "zvw-test");
|
||||
DB.find(RTestOne.class, "zvw-test");
|
||||
Thread.sleep(150);
|
||||
Object staleV0 = beanCache.get("zvw-test");
|
||||
assertThat(staleV0).isNotNull();
|
||||
@@ -331,7 +331,7 @@ class IntegrationTest {
|
||||
// update; ensure new v0 is in cache
|
||||
t1.setOtherUnique("unique-b");
|
||||
DB.save(t1);
|
||||
DB.find(TestOne.class, "zvw-test");
|
||||
DB.find(RTestOne.class, "zvw-test");
|
||||
Thread.sleep(150);
|
||||
|
||||
// stale write: v0 in cache, incoming v0 — must NOT be blocked (0 > 0 is false)
|
||||
@@ -339,7 +339,7 @@ class IntegrationTest {
|
||||
|
||||
// stale data should now be in cache (unlike the versioned case above)
|
||||
beanCache.statistics(true);
|
||||
TestOne found = DB.find(TestOne.class, "zvw-test");
|
||||
RTestOne found = DB.find(RTestOne.class, "zvw-test");
|
||||
ServerCacheStatistics stats = beanCache.statistics(true);
|
||||
assertThat(stats.getHitCount()).isEqualTo(1);
|
||||
assertThat(found.getOtherUnique()).isEqualTo("unique-a");
|
||||
|
||||
@@ -4,8 +4,7 @@ import io.ebean.DB;
|
||||
import io.ebean.Database;
|
||||
import io.ebean.cache.ServerCache;
|
||||
import io.ebean.cache.ServerCacheStatistics;
|
||||
import org.domain.RCust;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.domain.FRCust;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -36,27 +35,27 @@ class RedissonTenantAwareCacheTest {
|
||||
void singleBean_tenantA_hits_tenantB_misses() {
|
||||
Database db = buildTenantDb();
|
||||
try {
|
||||
RCust cust = new RCust("t-single-iso");
|
||||
FRCust cust = new FRCust("t-single-iso");
|
||||
DB.save(cust);
|
||||
long id = cust.getId();
|
||||
|
||||
ServerCache beanCache = db.cacheManager().beanCache(RCust.class);
|
||||
ServerCache beanCache = db.cacheManager().beanCache(FRCust.class);
|
||||
beanCache.clear();
|
||||
|
||||
// Tenant A: first load – goes to DB
|
||||
TENANT.set("tenantA");
|
||||
beanCache.statistics(true); // reset counters
|
||||
assertThat(db.find(RCust.class, id)).isNotNull();
|
||||
assertThat(db.find(FRCust.class, id)).isNotNull();
|
||||
assertThat(Objects.requireNonNull(beanCache.statistics(true)).getMissCount()).isEqualTo(1);
|
||||
|
||||
// Tenant A: second load – must hit cache
|
||||
assertThat(db.find(RCust.class, id)).isNotNull();
|
||||
assertThat(db.find(FRCust.class, id)).isNotNull();
|
||||
assertThat(Objects.requireNonNull(beanCache.statistics(true)).getHitCount()).isEqualTo(1);
|
||||
|
||||
// Tenant B: same ID, different tenant key – must miss
|
||||
TENANT.set("tenantB");
|
||||
beanCache.statistics(true); // reset counters
|
||||
assertThat(db.find(RCust.class, id)).isNotNull();
|
||||
assertThat(db.find(FRCust.class, id)).isNotNull();
|
||||
ServerCacheStatistics statsB = beanCache.statistics(true);
|
||||
assertNotNull(statsB);
|
||||
assertThat(statsB.getHitCount()).isEqualTo(0);
|
||||
@@ -72,26 +71,26 @@ class RedissonTenantAwareCacheTest {
|
||||
void getAll_tenantA_hits_tenantB_misses() throws InterruptedException {
|
||||
Database db = buildTenantDb();
|
||||
try {
|
||||
List<RCust> custs = new ArrayList<>();
|
||||
List<FRCust> custs = new ArrayList<>();
|
||||
for (String n : new String[]{"tga0", "tga1", "tga2"}) {
|
||||
custs.add(new RCust(n));
|
||||
custs.add(new FRCust(n));
|
||||
}
|
||||
DB.saveAll(custs);
|
||||
List<Long> ids = custs.stream().map(RCust::getId).collect(Collectors.toList());
|
||||
List<Long> ids = custs.stream().map(FRCust::getId).collect(Collectors.toList());
|
||||
|
||||
ServerCache beanCache = db.cacheManager().beanCache(RCust.class);
|
||||
ServerCache beanCache = db.cacheManager().beanCache(FRCust.class);
|
||||
beanCache.clear();
|
||||
|
||||
// Tenant A: first batch load – DB misses, cache populated
|
||||
TENANT.set("tenantA");
|
||||
List<RCust> listA0 = db.find(RCust.class).where().idIn(ids).setUseCache(true).findList();
|
||||
List<FRCust> listA0 = db.find(FRCust.class).where().idIn(ids).setUseCache(true).findList();
|
||||
assertThat(listA0).hasSize(3);
|
||||
|
||||
Thread.sleep(10);
|
||||
|
||||
// Tenant A: second batch load – all 3 must be cache hits
|
||||
beanCache.statistics(true); // reset
|
||||
List<RCust> listA1 = db.find(RCust.class).where().idIn(ids).setUseCache(true).findList();
|
||||
List<FRCust> listA1 = db.find(FRCust.class).where().idIn(ids).setUseCache(true).findList();
|
||||
assertThat(listA1).hasSize(3);
|
||||
ServerCacheStatistics statsA = beanCache.statistics(true);
|
||||
assertNotNull(statsA);
|
||||
@@ -101,7 +100,7 @@ class RedissonTenantAwareCacheTest {
|
||||
// Tenant B: same IDs, different tenant – all 3 must miss
|
||||
TENANT.set("tenantB");
|
||||
beanCache.statistics(true); // reset
|
||||
List<RCust> listB = db.find(RCust.class).where().idIn(ids).setUseCache(true).findList();
|
||||
List<FRCust> listB = db.find(FRCust.class).where().idIn(ids).setUseCache(true).findList();
|
||||
assertThat(listB).hasSize(3);
|
||||
ServerCacheStatistics statsB = beanCache.statistics(true);
|
||||
assertNotNull(statsB);
|
||||
|
||||
@@ -3,7 +3,7 @@ ebean:
|
||||
dumpMetricsOptions: sql,hash,loc
|
||||
test:
|
||||
registerTestTenantProvider: false
|
||||
redis: latest
|
||||
redis: 8.6.2
|
||||
# shutdown: stop # stop | remove
|
||||
platform: h2 # h2, postgres, mysql, oracle, sqlserver, sqlite
|
||||
ddlMode: dropCreate # none | dropCreate | create | migration | createOnly | migrationDropCreate
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
singleServerConfig:
|
||||
address: "redis://127.0.0.1:6379"
|
||||
password: null
|
||||
database: 0
|
||||
# ebean-redis test clients use database 0 in the shared Redis container.
|
||||
database: 1
|
||||
connectionMinimumIdleSize: 2
|
||||
connectionPoolSize: 10
|
||||
idleConnectionTimeout: 3000
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ebean-spring-txn</artifactId>
|
||||
@@ -28,7 +28,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-test</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
+7
-7
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>ebean-parent</artifactId>
|
||||
<groupId>io.ebean</groupId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</parent>
|
||||
|
||||
<name>ebean test</name>
|
||||
@@ -33,20 +33,20 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-h2</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-core</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-ddl-generator</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -149,14 +149,14 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-jackson-mapper</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-platform-all</artifactId>
|
||||
<version>18.3.0</version>
|
||||
<version>18.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -240,7 +240,7 @@
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
<artifactId>mariadb-java-client</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<version>3.3.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@ package io.ebean.xtest.base;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.ebean.ProfileLocation;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.meta.MetaQueryPlan;
|
||||
import io.ebean.meta.QueryPlanInit;
|
||||
import io.ebean.meta.QueryPlanRequest;
|
||||
import io.ebean.xtest.BaseTestCase;
|
||||
import io.ebean.xtest.IgnorePlatform;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.ResetBasicData;
|
||||
@@ -80,6 +82,7 @@ class DtoQueryPlanCaptureTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.DB2)
|
||||
void nativeDtoQuery_capturesQueryPlan() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
@@ -122,11 +125,13 @@ class DtoQueryPlanCaptureTest extends BaseTestCase {
|
||||
.orElse(null);
|
||||
|
||||
assertThat(dtoPlan).as("captured a native DTO query plan").isNotNull();
|
||||
assertThat(dtoPlan.dbName()).isEqualTo(DB.getDefault().name());
|
||||
assertThat(dtoPlan.sql()).contains("from o_customer where id > ?");
|
||||
assertThat(dtoPlan.plan()).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.DB2)
|
||||
void nativeDtoQuery_withProfileLocation_capturesQueryPlan() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@ package io.ebean.xtest.base;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.ebean.SqlRow;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.meta.MetaQueryPlan;
|
||||
import io.ebean.meta.QueryPlanInit;
|
||||
import io.ebean.meta.QueryPlanRequest;
|
||||
import io.ebean.xtest.BaseTestCase;
|
||||
import io.ebean.xtest.IgnorePlatform;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.ResetBasicData;
|
||||
|
||||
@@ -34,6 +36,7 @@ class SqlQueryPlanCaptureTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.DB2)
|
||||
void sqlQuery_capturesQueryPlan() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
@@ -68,6 +71,7 @@ class SqlQueryPlanCaptureTest extends BaseTestCase {
|
||||
.orElse(null);
|
||||
|
||||
assertThat(sqlPlan).as("captured a SqlQuery query plan").isNotNull();
|
||||
assertThat(sqlPlan.dbName()).isEqualTo(DB.getDefault().name());
|
||||
assertThat(sqlPlan.sql()).contains("from o_customer where id > ?");
|
||||
assertThat(sqlPlan.plan()).isNotEmpty();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package org.tests.delete;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.test.LoggedSql;
|
||||
import io.ebean.xtest.BaseTestCase;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.deleteorder.DcoAsset;
|
||||
import org.tests.model.deleteorder.DcoLinkAdapter;
|
||||
import org.tests.model.deleteorder.DcoParent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* A join entity owns the foreign key to the bean its delete cascades to, so the join row has to be
|
||||
* deleted first. When a persist callback writes to the database it flushes the batch from inside the
|
||||
* flush that is already running : the outer flush has taken the join rows out of their bean holder,
|
||||
* so the inner flush only finds the assets and executes them first.
|
||||
* <p>
|
||||
* See <a href="https://github.com/ebean-orm/ebean/issues/1852">#1852</a>.
|
||||
*/
|
||||
class TestDeleteCascadeOrder extends BaseTestCase {
|
||||
|
||||
@AfterEach
|
||||
void after() {
|
||||
DcoLinkAdapter.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteLinkBeforeAsset() {
|
||||
assertLinkDeletedBeforeAsset(deleteAllLinks(newParent(2)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteLinkBeforeAsset_whenCallbackWritesOnPreDelete() {
|
||||
DcoLinkAdapter.writeOnPreDelete(true);
|
||||
|
||||
assertLinkDeletedBeforeAsset(deleteAllLinks(newParent(2)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteLinkBeforeAsset_whenCallbackWritesOnPostDelete() {
|
||||
DcoLinkAdapter.writeOnPostDelete(true);
|
||||
|
||||
assertLinkDeletedBeforeAsset(deleteAllLinks(newParent(2)));
|
||||
}
|
||||
|
||||
private Long newParent(int assetCount) {
|
||||
DcoParent parent = new DcoParent("parent-" + assetCount);
|
||||
for (int i = 0; i < assetCount; i++) {
|
||||
parent.addAsset(new DcoAsset("asset-" + i));
|
||||
}
|
||||
DB.save(parent);
|
||||
return parent.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove every link of the parent, which cascades the delete to the assets behind them. The graph is
|
||||
* fetched up front : a lazy load would flush the batch on its own and hide the ordering.
|
||||
*/
|
||||
private List<String> deleteAllLinks(Long parentId) {
|
||||
try (Transaction txn = DB.beginTransaction()) {
|
||||
txn.setBatchMode(true);
|
||||
DcoParent parent = DB.find(DcoParent.class)
|
||||
.fetch("links")
|
||||
.fetch("links.asset")
|
||||
.where().idEq(parentId)
|
||||
.findOne();
|
||||
parent.getLinks().clear();
|
||||
|
||||
LoggedSql.start();
|
||||
DB.save(parent);
|
||||
txn.commit();
|
||||
return LoggedSql.stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void assertLinkDeletedBeforeAsset(List<String> sql) {
|
||||
assertThat(firstIndexOf(sql, "delete from dco_link"))
|
||||
.as("the join row must be deleted before the asset it references, statements were :%n%s", String.join("\n", sql))
|
||||
.isLessThan(firstIndexOf(sql, "delete from dco_asset"));
|
||||
}
|
||||
|
||||
private int firstIndexOf(List<String> sql, String fragment) {
|
||||
for (int i = 0; i < sql.size(); i++) {
|
||||
if (sql.get(i).contains(fragment)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
throw new AssertionError("no statement containing '" + fragment + "', statements were :\n" + String.join("\n", sql));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.tests.delete;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.ebean.xtest.BaseTestCase;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.deleteorder.DcoTree;
|
||||
import org.tests.model.deleteorder.DcoTreeContainer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* The tree shape reported on <a href="https://github.com/ebean-orm/ebean/issues/1852">#1852</a> :
|
||||
* deleting the container cascades down a self referencing tree, and the deletes have to reach the
|
||||
* leaves before their parents.
|
||||
*/
|
||||
class TestDeleteTreeCascadeOrder extends BaseTestCase {
|
||||
|
||||
/**
|
||||
* Still reproduces on 18.4.0. The tree is deleted level by level but not deepest first :
|
||||
* <pre>
|
||||
* delete from dco_tree where id in (?) -- the root, whose children are still there
|
||||
* delete from dco_tree where id in (?,?,?)
|
||||
* delete from dco_tree where id in (?,?)
|
||||
* </pre>
|
||||
* which fails with "Referential integrity constraint violation: FK_DCO_TREE_PARENT_ID". Disabled so
|
||||
* that it does not break the build, remove the annotation to see the failure.
|
||||
*/
|
||||
@Disabled("reproduces #1852, not fixed yet")
|
||||
@Test
|
||||
void deleteContainerOfNestedTree() {
|
||||
DcoTreeContainer container = new DcoTreeContainer();
|
||||
DcoTree root = new DcoTree("root");
|
||||
|
||||
DcoTree child1 = root.addChild("child 1");
|
||||
child1.addChild("child 1a").addChild("child 1a1");
|
||||
|
||||
DcoTree child2 = root.addChild("child 2");
|
||||
child2.addChild("child 2a");
|
||||
child2.addChild("child 2b");
|
||||
|
||||
container.getTrees().add(root);
|
||||
DB.save(container);
|
||||
|
||||
DB.delete(container);
|
||||
|
||||
assertThat(DB.find(DcoTree.class).findCount()).isZero();
|
||||
assertThat(DB.find(DcoTreeContainer.class).where().idEq(container.getId()).findCount()).isZero();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package org.tests.delete;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.test.LoggedSql;
|
||||
import io.ebean.xtest.BaseTestCase;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.deleteorder.DcoAsset;
|
||||
import org.tests.model.deleteorder.DcoParent;
|
||||
import org.tests.model.deleteorder.DcoParentAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Same defect as the cascaded delete one, on the insert side : a persist done from a BeanPersistController
|
||||
* flushes the batch from inside the flush that is already running, and the statements queued behind the
|
||||
* one being executed are issued out of order.
|
||||
* <p>
|
||||
* <a href="https://github.com/ebean-orm/ebean/pull/3148">#3148</a> fixed this for a flush triggered by a
|
||||
* query (BatchControl.executeNow disables flushOnQuery), but a flush triggered by a write goes through
|
||||
* BatchControl.executeOrQueue, which that guard does not cover.
|
||||
*/
|
||||
class TestInsertCascadeOrder extends BaseTestCase {
|
||||
|
||||
@AfterEach
|
||||
void after() {
|
||||
DcoParentAdapter.writeOnPreInsert(false);
|
||||
DcoParentAdapter.sqlUpdateOnPreInsert(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void insertParentBeforeItsLinks_whenCallbackWritesDuringFlush() {
|
||||
DcoParentAdapter.writeOnPreInsert(true);
|
||||
|
||||
List<String> sql = insertParents(3);
|
||||
|
||||
// every parent has to be inserted before the link that points at it
|
||||
assertThat(lastIndexOf(sql, "insert into dco_parent"))
|
||||
.as("a parent must be inserted before the links referencing it, statements were :%n%s", String.join("\n", sql))
|
||||
.isLessThan(lastIndexOf(sql, "insert into dco_link"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as above but the callback runs a SqlUpdate, which reaches BatchControl by
|
||||
* executeStatementOrBatch rather than executeOrQueue.
|
||||
*/
|
||||
@Test
|
||||
void insertParentBeforeItsLinks_whenCallbackRunsSqlUpdateDuringFlush() {
|
||||
DcoParentAdapter.sqlUpdateOnPreInsert(true);
|
||||
|
||||
List<String> sql = insertParents(3);
|
||||
|
||||
assertThat(lastIndexOf(sql, "insert into dco_parent"))
|
||||
.as("a parent must be inserted before the links referencing it, statements were :%n%s", String.join("\n", sql))
|
||||
.isLessThan(lastIndexOf(sql, "insert into dco_link"));
|
||||
}
|
||||
|
||||
private List<String> insertParents(int count) {
|
||||
List<DcoParent> parents = new ArrayList<>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
DcoParent parent = new DcoParent("batch-parent-" + i);
|
||||
parent.addAsset(new DcoAsset("batch-asset-" + i));
|
||||
parents.add(parent);
|
||||
}
|
||||
|
||||
try (Transaction txn = DB.beginTransaction()) {
|
||||
txn.setBatchMode(true);
|
||||
txn.setBatchSize(50);
|
||||
LoggedSql.start();
|
||||
DB.saveAll(parents);
|
||||
txn.commit();
|
||||
List<String> sql = LoggedSql.stop();
|
||||
System.out.println("---- insert order ----");
|
||||
sql.stream().filter(s -> !s.contains("-- bind")).forEach(s -> System.out.println(" " + s));
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
|
||||
private int lastIndexOf(List<String> sql, String fragment) {
|
||||
for (int i = sql.size() - 1; i >= 0; i--) {
|
||||
if (sql.get(i).contains(fragment)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
throw new AssertionError("no statement containing '" + fragment + "', statements were :\n" + String.join("\n", sql));
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,7 @@ public class TestInheritance extends BaseTestCase {
|
||||
|
||||
|
||||
server().save(grandparent1);
|
||||
var parent1Id = parent1.getIdentifier();
|
||||
|
||||
testMyDynamicFormulaWithIncludes();
|
||||
testMyDynamicFormulaWithIncludesAndFetchJoin();
|
||||
@@ -111,7 +112,7 @@ public class TestInheritance extends BaseTestCase {
|
||||
//grandparent1 = server().find(GrandParentPerson.class).setId(grandparent1.getIdentifier()).where()
|
||||
// .in("effectiveBean.id",2,null) // geht nicht!
|
||||
// .findOne();
|
||||
parent1 = server().find(ParentPerson.class).setId(1).fetch("someBean").findOne();
|
||||
parent1 = server().find(ParentPerson.class).setId(parent1Id).fetch("someBean").findOne();
|
||||
assertEquals("A Bean", parent1.getSomeBean().getName());
|
||||
grandparent1 = server().find(GrandParentPerson.class)
|
||||
.fetch("children", "*") // FIXME If I do not fetch childrenBean, I will get an exception
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ public class TestNatKeyCacheWithForeignKey extends BaseTestCase {
|
||||
|
||||
setupData();
|
||||
clearAllL2Cache();
|
||||
getStats();
|
||||
|
||||
final OCachedAppDetail found0 = findDetail(app0, "detail0");
|
||||
assertThat(found0).isNotNull();
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.tests.model.deleteorder;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Version;
|
||||
|
||||
/**
|
||||
* Owned by a {@link DcoLink} through a cascading OneToOne, so deleting the link deletes the asset.
|
||||
*/
|
||||
@Entity
|
||||
public class DcoAsset {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
Long id;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
String name;
|
||||
|
||||
public DcoAsset(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.tests.model.deleteorder;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
/**
|
||||
* Written from the delete callback of {@link DcoLink}, the way an audit or an outbox row is.
|
||||
*/
|
||||
@Entity
|
||||
public class DcoAudit {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
Long id;
|
||||
|
||||
String message;
|
||||
|
||||
public DcoAudit(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.tests.model.deleteorder;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToOne;
|
||||
|
||||
/**
|
||||
* Join entity between {@link DcoParent} and {@link DcoAsset}. It owns the foreign key to the asset,
|
||||
* so the link row has to be deleted before the asset it points at.
|
||||
* <p>
|
||||
* A real entity (rather than a plain join table) so that its delete fires a persistence callback,
|
||||
* see {@link DcoLinkAdapter}.
|
||||
*/
|
||||
@Entity
|
||||
public class DcoLink {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
Long id;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
DcoParent parent;
|
||||
|
||||
@OneToOne(optional = false, cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
DcoAsset asset;
|
||||
|
||||
public DcoLink(DcoParent parent, DcoAsset asset) {
|
||||
this.parent = parent;
|
||||
this.asset = asset;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public DcoParent getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public DcoAsset getAsset() {
|
||||
return asset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.tests.model.deleteorder;
|
||||
|
||||
import io.ebean.event.BeanPersistAdapter;
|
||||
import io.ebean.event.BeanPersistRequest;
|
||||
|
||||
/**
|
||||
* Persists a bean from inside a delete callback of {@link DcoLink}, the way an audit or an outbox row
|
||||
* is written. The BeanPersistController javadoc documents this as a supported use case.
|
||||
* <p>
|
||||
* Off by default so that the callbacks only fire for the tests that ask for them.
|
||||
*/
|
||||
public class DcoLinkAdapter extends BeanPersistAdapter {
|
||||
|
||||
private static boolean writeOnPreDelete;
|
||||
private static boolean writeOnPostDelete;
|
||||
|
||||
public static void writeOnPreDelete(boolean enabled) {
|
||||
writeOnPreDelete = enabled;
|
||||
}
|
||||
|
||||
public static void writeOnPostDelete(boolean enabled) {
|
||||
writeOnPostDelete = enabled;
|
||||
}
|
||||
|
||||
public static void reset() {
|
||||
writeOnPreDelete = false;
|
||||
writeOnPostDelete = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegisterFor(Class<?> cls) {
|
||||
return DcoLink.class.equals(cls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preDelete(BeanPersistRequest<?> request) {
|
||||
if (writeOnPreDelete) {
|
||||
audit(request, "pre");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postDelete(BeanPersistRequest<?> request) {
|
||||
if (writeOnPostDelete) {
|
||||
audit(request, "post");
|
||||
}
|
||||
}
|
||||
|
||||
private void audit(BeanPersistRequest<?> request, String phase) {
|
||||
DcoLink link = (DcoLink) request.bean();
|
||||
request.database().save(new DcoAudit(phase + " delete of link " + link.getId()), request.transaction());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.tests.model.deleteorder;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Parent of a join entity, see {@link DcoLink}.
|
||||
*/
|
||||
@Entity
|
||||
public class DcoParent {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "parent", orphanRemoval = true)
|
||||
List<DcoLink> links = new ArrayList<>();
|
||||
|
||||
public DcoParent(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<DcoLink> getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public void addAsset(DcoAsset asset) {
|
||||
links.add(new DcoLink(this, asset));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.tests.model.deleteorder;
|
||||
|
||||
import io.ebean.event.BeanPersistAdapter;
|
||||
import io.ebean.event.BeanPersistRequest;
|
||||
|
||||
/**
|
||||
* Persists a bean from inside the insert callback of {@link DcoParent}, the way an audit or an outbox
|
||||
* row is written. The BeanPersistController javadoc documents this as a supported use case.
|
||||
* <p>
|
||||
* Off by default so that the callback only fires for the tests that ask for it.
|
||||
*/
|
||||
public class DcoParentAdapter extends BeanPersistAdapter {
|
||||
|
||||
private static boolean writeOnPreInsert;
|
||||
private static boolean sqlUpdateOnPreInsert;
|
||||
|
||||
public static void writeOnPreInsert(boolean enabled) {
|
||||
writeOnPreInsert = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link #writeOnPreInsert(boolean)} but through SqlUpdate, which takes the
|
||||
* BatchControl.executeStatementOrBatch path rather than executeOrQueue.
|
||||
*/
|
||||
public static void sqlUpdateOnPreInsert(boolean enabled) {
|
||||
sqlUpdateOnPreInsert = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegisterFor(Class<?> cls) {
|
||||
return DcoParent.class.equals(cls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preInsert(BeanPersistRequest<?> request) {
|
||||
DcoParent parent = (DcoParent) request.bean();
|
||||
if (writeOnPreInsert) {
|
||||
request.database().save(new DcoAudit("inserting " + parent.getName()), request.transaction());
|
||||
}
|
||||
if (sqlUpdateOnPreInsert) {
|
||||
request.database().sqlUpdate("update dco_audit set message = ? where id = ?")
|
||||
.setParameter(1, "inserting " + parent.getName())
|
||||
.setParameter(2, -1L)
|
||||
.usingTransaction(request.transaction())
|
||||
.execute();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.tests.model.deleteorder;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Self referencing tree, as reported on #1852.
|
||||
*/
|
||||
@Entity
|
||||
public class DcoTree {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
@ManyToOne
|
||||
DcoTree parent;
|
||||
|
||||
@ManyToOne
|
||||
DcoTreeContainer container;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "parent")
|
||||
List<DcoTree> children = new ArrayList<>();
|
||||
|
||||
public DcoTree(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public List<DcoTree> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public DcoTree addChild(String name) {
|
||||
DcoTree child = new DcoTree(name);
|
||||
child.parent = this;
|
||||
children.add(child);
|
||||
return child;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.tests.model.deleteorder;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Holds the roots of a {@link DcoTree}, as reported on #1852.
|
||||
*/
|
||||
@Entity
|
||||
public class DcoTreeContainer {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
Long id;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
List<DcoTree> trees = new ArrayList<>();
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public List<DcoTree> getTrees() {
|
||||
return trees;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user