Skip to content

Commit a00262e

Browse files
mackerlmatriv
authored andcommitted
introduce CrateDbDialect ** specializing on differences to Postgres 14
** no sequences ** different timestamp creation (no prescision) ** map JSON as OBJECT(DYNAMIC) ** map array as array(elementTypeName) instead of ... elementTypeName array ** exclude unsupported features introduce CrateJsonType without casting (postgres default) show it on an example panache entity
1 parent 9fa73b8 commit a00262e

23 files changed

+1194
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!build/*-runner
3+
!build/*-runner.jar
4+
!build/lib/*
5+
!build/quarkus-app/*
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Gradle
2+
.gradle/
3+
build/
4+
5+
# Eclipse
6+
.project
7+
.classpath
8+
.settings/
9+
bin/
10+
11+
# IntelliJ
12+
.idea
13+
*.ipr
14+
*.iml
15+
*.iws
16+
17+
# NetBeans
18+
nb-configuration.xml
19+
20+
# Visual Studio Code
21+
.vscode
22+
.factorypath
23+
24+
# OSX
25+
.DS_Store
26+
27+
# Vim
28+
*.swp
29+
*.swo
30+
31+
# patch
32+
*.orig
33+
*.rej
34+
35+
# Local environment
36+
.env
37+
38+
# Plugin directory
39+
/.quarkus/cli/plugins/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
java=21.0.3-tem
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Crate JPA Panache usage
2+
3+
This project shows how crate can be utilized with Quarkus in a very intuitive way using Hibernate ORM deriving from postgres.
4+
Within the CrateDbDialect differences to postgres are treated - e.g. JSON, timestamp (no precission in crate), and the array differences in the ddl.
5+
Futhermore there is the CrateJsonJdbcType that overrides the default postgres driver handling which uses jsonb.
6+
7+
Finally things that crate does not support need to be addressed in the dialect (sequences, alter table if) ... with that adaptations it was possible to use crate in a native way for java development.
8+
9+
# code-with-quarkus
10+
11+
This project uses Quarkus, the Supersonic Subatomic Java Framework.
12+
13+
If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .
14+
15+
## Running the application in dev mode
16+
17+
You can run your application in dev mode that enables live coding using:
18+
19+
```shell script
20+
./gradlew quarkusDev
21+
```
22+
23+
> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
24+
25+
## Packaging and running the application
26+
27+
The application can be packaged using:
28+
29+
```shell script
30+
./gradlew build
31+
```
32+
33+
It produces the `quarkus-run.jar` file in the `build/quarkus-app/` directory.
34+
Be aware that it’s not an _über-jar_ as the dependencies are copied into the `build/quarkus-app/lib/` directory.
35+
36+
The application is now runnable using `java -jar build/quarkus-app/quarkus-run.jar`.
37+
38+
If you want to build an _über-jar_, execute the following command:
39+
40+
```shell script
41+
./gradlew build -Dquarkus.package.type=uber-jar
42+
```
43+
44+
The application, packaged as an _über-jar_, is now runnable using `java -jar build/*-runner.jar`.
45+
46+
## Creating a native executable
47+
48+
You can create a native executable using:
49+
50+
```shell script
51+
./gradlew build -Dquarkus.package.type=native
52+
```
53+
54+
Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
55+
56+
```shell script
57+
./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true
58+
```
59+
60+
You can then execute your native executable with: `./build/code-with-quarkus-1.0.0-SNAPSHOT-runner`
61+
62+
If you want to learn more about building native executables, please consult https://quarkus.io/guides/gradle-tooling.
63+
64+
## Related Guides
65+
66+
- Hibernate ORM with Panache ([guide](https://quarkus.io/guides/hibernate-orm-panache)): Simplify your persistence code for Hibernate ORM via the active record or the repository pattern
67+
- JDBC Driver - PostgreSQL ([guide](https://quarkus.io/guides/datasource)): Connect to the PostgreSQL database via JDBC
68+
69+
## Provided Code
70+
71+
### Hibernate ORM
72+
73+
Create your first JPA entity
74+
75+
[Related guide section...](https://quarkus.io/guides/hibernate-orm)
76+
77+
[Related Hibernate with Panache section...](https://quarkus.io/guides/hibernate-orm-panache)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
plugins {
2+
id 'java'
3+
id 'io.quarkus'
4+
}
5+
6+
repositories {
7+
mavenCentral()
8+
mavenLocal()
9+
}
10+
11+
dependencies {
12+
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
13+
implementation 'io.quarkus:quarkus-hibernate-orm-panache'
14+
implementation 'io.quarkus:quarkus-jdbc-postgresql'
15+
implementation 'io.quarkus:quarkus-arc'
16+
implementation 'io.quarkus:quarkus-hibernate-orm'
17+
implementation 'io.quarkus:quarkus-jackson' // needed for json serializing
18+
testImplementation 'io.quarkus:quarkus-junit5'
19+
testImplementation 'org.testcontainers:cratedb:1.19.7'
20+
testImplementation "org.testcontainers:junit-jupiter:1.19.7"
21+
}
22+
23+
group 'org.acme'
24+
version '1.0.0-SNAPSHOT'
25+
26+
java {
27+
sourceCompatibility = JavaVersion.VERSION_21
28+
targetCompatibility = JavaVersion.VERSION_21
29+
}
30+
31+
test {
32+
systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager"
33+
}
34+
compileJava {
35+
options.encoding = 'UTF-8'
36+
options.compilerArgs << '-parameters'
37+
}
38+
39+
compileTestJava {
40+
options.encoding = 'UTF-8'
41+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Gradle properties
2+
quarkusPluginId=io.quarkus
3+
quarkusPluginVersion=3.8.3
4+
quarkusPlatformGroupId=io.quarkus.platform
5+
quarkusPlatformArtifactId=quarkus-bom
6+
quarkusPlatformVersion=3.8.3
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)