diff --git a/.github/renovate.json b/.github/renovate.json
new file mode 100644
index 0000000..9995802
--- /dev/null
+++ b/.github/renovate.json
@@ -0,0 +1,4 @@
+{
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
+ "extends": ["config:recommended"]
+}
\ No newline at end of file
diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
new file mode 100644
index 0000000..3a64c11
--- /dev/null
+++ b/.github/workflows/gradle.yml
@@ -0,0 +1,91 @@
+name: "Java CI"
+on:
+ push:
+ branches:
+ - master
+ - '[0-9]+.x'
+ pull_request:
+ branches:
+ - master
+ - '[0-9]+.x'
+ workflow_dispatch:
+permissions:
+ packages: read
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: false
+jobs:
+ tests:
+ if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }}
+ name: "Test"
+ runs-on: ubuntu-24.04
+ container: ubuntu
+ services:
+ postgres:
+ image: postgres
+ env:
+ POSTGRES_DB: pg_extensions_test
+ POSTGRES_USER: postgres_extensions
+ POSTGRES_PASSWORD: postgres_extensions
+ ports:
+ - 5432:5432
+ options: >-
+ --health-cmd "pg_isready -U postgres_extensions -d pg_extensions_test"
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+ steps:
+ - name: Install psql client
+ env:
+ DEBIAN_FRONTEND: noninteractive
+ run: |
+ apt-get update
+ apt-get install -y --no-install-recommends postgresql-client
+ - name: Create extensions
+ env:
+ PGPASSWORD: postgres_extensions
+ run: |
+ until pg_isready -h postgres -p 5432 -U postgres_extensions -d pg_extensions_test; do sleep 1; done
+ psql -h postgres -U postgres_extensions -d pg_extensions_test -c "CREATE EXTENSION IF NOT EXISTS hstore;"
+ - name: "📥 Checkout repository"
+ uses: actions/checkout@v5
+ - name: "☕️ Setup JDK"
+ uses: actions/setup-java@v5
+ with:
+ java-version: 17
+ distribution: liberica
+ - name: "🐘 Setup Gradle"
+ uses: gradle/actions/setup-gradle@v4
+ with:
+ develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
+ - name: "🏃♂️ Run Checks"
+ id: build
+ env:
+ POSTGRES_HOST: postgres
+ POSTGRES_PORT: 5432
+ run: ./gradlew check --continue
+ publish_snapshot:
+ needs: tests
+ if: ${{ always() && github.repository_owner == 'gpc' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (needs.tests.result == 'success' || needs.tests.result == 'skipped') }}
+ runs-on: ubuntu-24.04
+ permissions:
+ contents: write
+ steps:
+ - name: "📥 Checkout repository"
+ uses: actions/checkout@v4
+ - name: "☕️ Setup JDK"
+ uses: actions/setup-java@v4
+ with:
+ java-version: 17
+ distribution: liberica
+ - name: "🐘 Setup Gradle"
+ uses: gradle/actions/setup-gradle@v4
+ with:
+ develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
+ - name: "📤 Publish Snapshot Artifacts"
+ env:
+ GRAILS_PUBLISH_RELEASE: 'false'
+ MAVEN_PUBLISH_URL: ${{ secrets.MAVEN_PUBLISH_SNAPSHOT_URL }}
+ MAVEN_PUBLISH_USERNAME: ${{ secrets.MAVEN_PUBLISH_USERNAME }}
+ MAVEN_PUBLISH_PASSWORD: ${{ secrets.MAVEN_PUBLISH_PASSWORD }}
+ run: ./gradlew --no-build-cache publish
\ No newline at end of file
diff --git a/.github/workflows/release-notes.yml b/.github/workflows/release-notes.yml
new file mode 100644
index 0000000..2ae8559
--- /dev/null
+++ b/.github/workflows/release-notes.yml
@@ -0,0 +1,24 @@
+name: "Release Drafter"
+on:
+ issues:
+ types: [closed, reopened]
+ push:
+ branches:
+ - 'master'
+ - '[0-9]+.x'
+ pull_request:
+ types: [opened, reopened, synchronize]
+ pull_request_target:
+ types: [opened, reopened, synchronize]
+ workflow_dispatch:
+jobs:
+ update_release_draft:
+ permissions:
+ contents: write
+ pull-requests: write
+ runs-on: ubuntu-24.04
+ steps:
+ - name: "📝 Update Release Draft"
+ uses: release-drafter/release-drafter@v6
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..9cc7c12
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,135 @@
+name: Release
+on:
+ release:
+ types: [ published ]
+env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ JAVA_VERSION: '17.0.15' # this must be a specific version for reproducible builds
+ RELEASE_TAG_PREFIX: 'v'
+jobs:
+ publish:
+ permissions:
+ packages: read # pre-release workflow
+ contents: write # to create release
+ issues: write # to modify milestones
+ runs-on: ubuntu-24.04
+ outputs:
+ release_version: ${{ steps.release_version.outputs.value }}
+ extract_repository_name: ${{ steps.extract_repository_name.outputs.repository_name }}
+ steps:
+ - name: "📝 Store the current release version"
+ id: release_version
+ run: |
+ export RELEASE_VERSION="${{ github.ref_name }}"
+ export RELEASE_VERSION=${RELEASE_VERSION:${#RELEASE_TAG_PREFIX}}
+ echo "Found Release Version: ${RELEASE_VERSION}"
+ echo "value=${RELEASE_VERSION}" >> $GITHUB_OUTPUT
+ - name: "Extract repository name"
+ id: extract_repository_name
+ run: |
+ echo "repository_name=${GITHUB_REPOSITORY##*/}" >> $GITHUB_OUTPUT
+ - name: "📥 Checkout the repository"
+ uses: actions/checkout@v4
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+ ref: v${{ steps.release_version.outputs.value }}
+ - name: 'Ensure Common Build Date' # to ensure a reproducible build
+ run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> "$GITHUB_ENV"
+ - name: "Ensure source files use common date"
+ run: |
+ find . -depth \( -type f -o -type d \) -exec touch -d "@${SOURCE_DATE_EPOCH}" {} +
+ - name: "☕️ Setup JDK"
+ uses: actions/setup-java@v4
+ with:
+ distribution: liberica
+ java-version: ${{ env.JAVA_VERSION }}
+ - name: "🐘 Setup Gradle"
+ uses: gradle/actions/setup-gradle@v4
+ with:
+ develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
+ - name: "⚙️ Run pre-release"
+ uses: apache/grails-github-actions/pre-release@asf
+ env:
+ RELEASE_VERSION: ${{ steps.release_version.outputs.value }}
+ - name: "🔐 Generate key file for artifact signing"
+ env:
+ SECRING_FILE: ${{ secrets.SECRING_FILE }}
+ run: |
+ printf "%s" "$SECRING_FILE" | base64 -d > "${{ github.workspace }}/secring.gpg"
+ - name: "🧩 Run Assemble"
+ id: assemble
+ run: |
+ ./gradlew -U assemble -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg -Psigning.keyId=${{ secrets.SIGNING_KEY }}
+ env:
+ GRAILS_PUBLISH_RELEASE: 'true'
+ SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
+ SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
+ - name: "📤 Publish to Maven Central"
+ env:
+ GRAILS_PUBLISH_RELEASE: 'true'
+ NEXUS_PUBLISH_USERNAME: ${{ secrets.NEXUS_PUBLISH_USERNAME }}
+ NEXUS_PUBLISH_PASSWORD: ${{ secrets.NEXUS_PUBLISH_PASSWORD }}
+ NEXUS_PUBLISH_URL: ${{ secrets.NEXUS_PUBLISH_RELEASE_URL }}
+ NEXUS_PUBLISH_DESCRIPTION: '${{ steps.extract_repository_name.outputs.repository_name }}:${{ steps.release_version.outputs.value }}'
+ SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
+ SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
+ run: >
+ ./gradlew
+ -Psigning.keyId=${{ secrets.SIGNING_KEY }}
+ -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg
+ publishMavenPublicationToSonatypeRepository
+ closeSonatypeStagingRepository
+ - name: "Generate Build Date file"
+ run: echo "$SOURCE_DATE_EPOCH" >> build/BUILD_DATE.txt
+ - name: "Upload Build Date file"
+ uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631
+ with:
+ tag_name: ${{ github.event.release.tag_name }}
+ files: build/BUILD_DATE.txt
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ release:
+ needs: publish
+ runs-on: ubuntu-24.04
+ environment: release
+ permissions:
+ contents: write
+ issues: write
+ pull-requests: write
+ steps:
+ - name: "📥 Checkout repository"
+ uses: actions/checkout@v4
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+ ref: v${{ needs.publish.outputs.release_version }}
+ - name: "☕️ Setup JDK"
+ uses: actions/setup-java@v4
+ with:
+ distribution: liberica
+ java-version: ${{ env.JAVA_VERSION }}
+ - name: "🐘 Setup Gradle"
+ uses: gradle/actions/setup-gradle@v4
+ - name: "📤 Release staging repository"
+ env:
+ GRAILS_PUBLISH_RELEASE: 'true'
+ NEXUS_PUBLISH_USERNAME: ${{ secrets.NEXUS_PUBLISH_USERNAME }}
+ NEXUS_PUBLISH_PASSWORD: ${{ secrets.NEXUS_PUBLISH_PASSWORD }}
+ NEXUS_PUBLISH_URL: ${{ secrets.NEXUS_PUBLISH_RELEASE_URL }}
+ NEXUS_PUBLISH_DESCRIPTION: '${{ needs.publish.outputs.extract_repository_name }}:${{ needs.publish.outputs.release_version }}'
+ run: >
+ ./gradlew
+ findSonatypeStagingRepository
+ releaseSonatypeStagingRepository
+ - name: "📖 Generate Documentation"
+ if: ${{ hashFiles('src/main/asciidoc/**') != '' }}
+ run: ./gradlew docs
+ - name: "📤 Publish Documentation to Github Pages"
+ uses: apache/grails-github-actions/deploy-github-pages@asf
+ if: ${{ hashFiles('src/main/asciidoc/**') != '' }}
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GRADLE_PUBLISH_RELEASE: 'true'
+ SOURCE_FOLDER: build/docs
+ VERSION: ${{ needs.publish.outputs.release_version }}
+ - name: "⚙️ Run post-release"
+ uses: apache/grails-github-actions/post-release@asf
diff --git a/.gitignore b/.gitignore
index db7d75a..bae7029 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,9 @@ plugin.xml
grails-postgresql-extensions-*.zip
grails-postgresql-extensions-*.zip.sha1
/.idea
+!/.idea/codeStyles
+!.idea/codeStyles/Project.xml
+!.idea/codeStyles/codeStyleConfig.xml
*.iml
*.swp
*.ids
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..3f19036
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..52768fe
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.sdkmanrc b/.sdkmanrc
new file mode 100644
index 0000000..48cc71b
--- /dev/null
+++ b/.sdkmanrc
@@ -0,0 +1,2 @@
+# Enable auto-env through the sdkman_auto_env config - https://sdkman.io/usage#env
+java=17.0.15-librca
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 4ceeff3..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,39 +0,0 @@
-dist: precise
-sudo: required
-language: groovy
-jdk:
- - oraclejdk8
-
-env:
- global:
- - GIT_NAME="Iván López"
- - GIT_EMAIL="lopez.ivan@gmail.com"
- - secure: qdvGtJFbtvTJPZ9HbBC4DtPGLAeWQq5A1gX7u4xxfPBNw/Mkd7Z0/OrWiMuNMccDvqhiPAbauZRb3ZSE/KOWhqSKg6EAMeQpBgGUOrjXNBH6x0m2BthFkQhEVWrDVqGx+AuEbm7kRsNw6ec+kJ6oaBPjnHOfbPnGVro+4sGWSck=
- - secure: ZYo6fjlQNV1Oyc+fcINeISvR3pUAQG/V9I28v0xs2hjDiAug4gPnaQgxhmpa1SfRo5vwk+Oi+eNG22K2ePmUqARz2K5REahEPvocRZwrEow7pvJGvsLwiDcJk/o20fLPcUJlxgAyJeOQYR+exg35TlfHQ0ZWPVj07HO/A+1KTeM=
-
-addons:
- postgresql: "9.4"
-
-sudo: false
-
-before_script:
- - psql -d template1 -c 'create extension hstore;' -U postgres
- - psql -c 'create database pg_extensions_test;' -U postgres
- - psql -c "create user postgres_extensions with password 'postgres_extensions';" -U postgres
- - psql -c "grant all privileges on database pg_extensions_test to postgres_extensions;" -U postgres
- - rm -rf target
-
-script:
- - ./travis-build.sh
-
-notifications:
- email:
- recipients:
- - lopez.ivan@gmail.com
- - alonso.javier.torres@gmail.com
-
- on_success: change
- on_failure: change
-
-#after_success:
-# - ./gradlew cobertura coveralls
diff --git a/Makefile b/Makefile
deleted file mode 100644
index eee89a1..0000000
--- a/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-.PHONY: test
-
-image :
- docker build -f Dockerfile -t grails/postgres-extensions .
-
-clean :
- docker rmi -f grails/postgres-extensions
-
-test :
- ./gradlew clean
- docker run --rm --name pg_extensions_test -p 5432:5432 -d grails/postgres-extensions
- ./gradlew check
- docker container kill pg_extensions_test
-
-all : image test
\ No newline at end of file
diff --git a/README.md b/README.md
index dd931b4..17ffe9a 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,13 @@
-# ⚠️ This plugin is not maintained anymore ⚠️
+# Grails PostgreSQL Extensions
-## Grails Postgresql Extensions
+This is a Grails plugin that provides Hibernate user types to use PostgreSQL native types such as Array, Hstore, Json,
+Jsonb, ..., from a Grails application. It also provides new criteria to query these new native types.
-#### THIS BRANCH (master) IS FOR GRAILS 4 AND HIBERNATE 5.4 ####
-
-This is a grails plugin that provides hibernate user types to use Postgresql native types such as Array, Hstore, Json,
-Jsonb... from a Grails application. It also provides new criterias to query this new native types.
-
-Currently the plugin supports array, hstore, json and jsonb fields as well as some query methods.
+Currently, the plugin supports array, hstore, json and jsonb fields as well as some query methods.
More native types and query methods will be added in the future.
* [Installation](#installation)
- * [Postgresql driver](#postgresql-driver)
+ * [PostgreSQL driver](#postgresql-driver)
* [Hibernate plugin](#hibernate-plugin)
* [Configuration](#configuration)
* [Native Types](#native-types)
@@ -46,90 +42,26 @@ More native types and query methods will be added in the future.
* [Order](#order)
* [Random order](#random-order)
* [Sql formula](#sql-formula)
-* [Authors](#authors)
* [Release Notes](#release-notes)
## Installation
-The Grails 3 version supports both Hibernate 4.X (versions 4.x.x of the plugin) and Hibernate 5.X (versions 5.x.x of the
-plugin). In `build.gradle` add the `jcenter` repository and the following dependency to install the plugin:
-
+The Grails 7 version of this plugin supports Hibernate 5.
+In `build.gradle` add the following dependencies to install the plugin:
```groovy
-repositories {
- ...
- jcenter()
- ...
-}
-
dependencies {
- ...
- compile 'org.grails.plugins:postgresql-extensions:'
- ...
-}
-```
-
-### Postgresql driver
-
-You also need to install the Postgresql jdbc driver. You can see all available Postgresql jdbc libraries versions at
-[MVN Repository](http://mvnrepository.com/artifact/org.postgresql/postgresql).
-
-```groovy
-dependencies {
- ...
- provided 'org.postgresql:postgresql:9.4.1211.jre7'
- ...
-}
-```
-
-### Hibernate plugin
-
-It's also necessary to install the Grails-Hibernate plugin. Depending if you use Hibernate 4 or Hibernate 5 you'll need
-different dependencies. Please make sure you use the latest versions of the plugin and the hibernate dependencies
-
-
-```groovy
-// Hibernate 4
-buildscript {
- ...
- dependencies {
- ...
- classpath "org.grails.plugins:hibernate4:6.0.3"
- }
-}
-
-dependencies {
- ...
- compile "org.grails.plugins:hibernate4"
- compile "org.hibernate:hibernate-core:4.3.11.Final"
- compile "org.hibernate:hibernate-ehcache:4.3.11.Final"
- ...
-}
-```
-
-```groovy
-// Hibernate 5
-buildscript {
- ...
- dependencies {
- ...
- classpath "org.grails.plugins:hibernate5:6.0.3"
- }
-}
-
-dependencies {
- ...
- compile "org.grails.plugins:hibernate5"
- compile "org.hibernate:hibernate-core:5.1.1.Final"
- compile "org.hibernate:hibernate-ehcache:5.1.1.Final"
- ...
+ //...
+ implementation 'io.github.gpc:grails-postgresql-extensions:'
+ implementation 'org.apache.grails:grails-data-hibernate5'
+ //...
}
```
## Configuration
-After install the plugin you have to use a new Postgresql Hibernate Dialect in your application. Add it to the
+After installing the plugin you have to use a new PostgreSQL Hibernate Dialect in your application. Add it to the
`grails-app/conf/application.yml` file:
```yaml
@@ -144,24 +76,16 @@ dataSource:
dbCreate: update
hibernate:
- dialect: net.kaleidos.hibernate.PostgresqlExtensionsDialect
+ dialect: gpc.pgext.hibernate.PostgresqlExtensionsDialect
```
-If you just only add the dialect, hibernate will create a new sequence for every table to generate the sequential ids
+If you just add the dialect, hibernate will create a new sequence for every table to generate the sequential ids
used for the primary keys instead of a global sequence for all your tables.
-If you're using Hibernate 4 you can also deactivate this behaviour and create only one unique sequence for all the tables with the following
+You can also deactivate this behavior and create only one unique sequence for all the tables with the following
property in your datasource definition:
-```yaml
-dataSource:
- postgresql:
- extensions:
- sequence_per_table: false
-}
-```
-
-For Hibernate 5 add the following to `grails-app/conf/application.groovy`:
+Add the following to `grails-app/conf/application.groovy`:
```groovy
grails.gorm.default.mapping = {
@@ -182,14 +106,14 @@ The plugin supports the definition of `Integer`, `Long`, `Float`, `Double`, `Str
classes.
The `Enum` arrays behaves almost identical to `Integer` arrays in that they store and retrieve an array of ints. The
-difference, however, is that this is used with an Array of Enums, rather than Ints. The Enums are serialized to their
+difference, however, is that this is used with an Array of Enums, rather than ints. The Enums are serialized to their
ordinal value before persisted to the database. On retrieval, they are then converted back into their original `Enum`
type.
#### Example
```groovy
-import net.kaleidos.hibernate.usertype.ArrayType
+import gpc.pgext.hibernate.usertype.ArrayType
class Like {
Integer[] favoriteNumbers = []
@@ -244,11 +168,11 @@ And now, with `psql`:
1 | {123,239,3498239,2344235} | {0.3,0.1} | {100.33,44.11} | {Spiderman,"Blade Runner",Starwars} | {5,17,9,6} | {0,2}
```
-#### Criterias
+#### Criteria
-The plugin also includes some hibernate criterias to use in your queries. Please check the
-[services](https://github.com/kaleidos/grails-postgresql-extensions/tree/master/grails-app/services/test/criteria/array)
-and the [tests](https://github.com/kaleidos/grails-postgresql-extensions/tree/master/src/integration-test/groovy/net/kaleidos/hibernate/array)
+The plugin also includes some Hibernate criteria to use in your queries. Please check the
+[services](https://github.com/gpc/grails-postgresql-extensions/tree/master/test-apps/app1/grails-app/services/app/criteria/array)
+and the [tests](https://github.com/gpc/grails-postgresql-extensions/tree/master/test-apps/app1/src/integration-test/groovy/array)
created to see all usage examples.
You can also check the official [Postgresql Array operators](http://www.postgresql.org/docs/9.4/static/functions-array.html#ARRAY-OPERATORS-TABLE).
@@ -729,16 +653,6 @@ It's important to note that the "raw" sql is appended to the criteria, so you ne
if not you'll get a sql error during runtime.
-## Authors
-
-You can send any questions to:
-
-- Iván López: lopez.ivan@gmail.com ([@ilopmar](https://twitter.com/ilopmar))
-- Alonso Torres: alonso.javier.torres@gmail.com ([@alotor](https://twitter.com/alotor))
-
-Collaborations are appreciated :-)
-
-
## Release Notes
Version | Date | Comments
diff --git a/build.gradle b/build.gradle
index 19ec900..299bdf4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,119 +1,24 @@
-buildscript {
- ext {
- grailsVersion = project.grailsVersion
- gormVersion = project.gormVersion
- }
- repositories {
- mavenLocal()
- mavenCentral()
- jcenter()
- maven { url 'https://repo.grails.org/grails/core' }
- }
- dependencies {
- classpath "org.grails:grails-gradle-plugin:$grailsVersion"
- classpath "org.grails.plugins:hibernate5:7.0.0"
- classpath 'net.saliman:gradle-cobertura-plugin:2.5.4'
- classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2'
- classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0"
- }
-}
-
-version '7.0.0'
-group 'org.grails.plugins'
-
-apply plugin: 'eclipse'
-apply plugin: 'idea'
-apply plugin: 'org.grails.grails-plugin'
-apply plugin: 'org.grails.grails-plugin-publish'
-apply plugin: 'cobertura'
-apply plugin: 'com.github.kt3k.coveralls'
-apply plugin: 'com.jfrog.bintray'
-
-ext {
- gradleWrapperVersion = project.gradleWrapperVersion
- grailsVersion = project.grailsVersion
- gormVersion = project.gormVersion
- hibernateVersion = project.hibernateVersion
-}
-
-sourceCompatibility = 1.8
-targetCompatibility = 1.8
-
-cobertura {
- coverageExcludes = ['.*BootStrap.*', '.*test.*']
- coverageFormats = ['html', 'xml']
-}
-
-jar {
- exclude 'test/**'
- exclude 'UrlMappings.groovy'
- exclude 'error.gsp'
- exclude 'messages.properties'
- exclude 'hibernate/**'
- exclude 'layouts/**'
- exclude 'spring/**'
-}
-
-repositories {
- mavenLocal()
- mavenCentral()
- jcenter()
- maven { url 'https://repo.grails.org/grails/core' }
-}
-
-dependencies {
- // Grails deps
- compile 'org.springframework.boot:spring-boot-starter-logging'
- compile 'org.springframework.boot:spring-boot-autoconfigure'
- compile 'org.grails:grails-core'
- compile 'org.springframework.boot:spring-boot-starter-actuator'
- compile 'org.springframework.boot:spring-boot-starter-tomcat'
- compile 'org.grails:grails-dependencies'
- compile 'org.grails:grails-web-boot'
- console 'org.grails:grails-console'
-
- profile 'org.grails.profiles:web-plugin'
- provided 'org.grails:grails-plugin-services'
- provided 'org.grails:grails-plugin-domain-class'
- testCompile 'org.grails:grails-gorm-testing-support'
-
- provided 'org.postgresql:postgresql:42.2.6'
-
- // plugins
- provided 'org.grails.plugins:hibernate5'
+// Workaround needed for nexus publishing bug
+// version and group must be specified in the root project
+// https://github.com/gradle-nexus/publish-plugin/issues/310
+version = projectVersion
+group = 'this.will.be.overridden'
- // libraries
- provided "org.hibernate:hibernate-core:$hibernateVersion"
- provided("org.hibernate:hibernate-ehcache:$hibernateVersion") {
- exclude group: 'net.sf.ehcache', module: 'ehcache'
- }
- compile 'com.google.code.gson:gson:2.8.4'
-}
+subprojects {
-bintray {
- pkg {
- userOrg = 'kaleidos'
- name = 'postgresql-extensions'
- issueTrackerUrl = 'https://github.com/kaleidosnet/grails-grails-postgresql-extensions/issues'
- vcsUrl = 'https://github.com/kaleidosnet/grails-grails-postgresql-extensions/issues'
+ repositories {
+ mavenCentral()
+ maven { url = 'https://repo.grails.org/grails/restricted' }
+ maven {
+ url = 'https://repository.apache.org/content/groups/snapshots'
+ content {
+ includeVersionByRegex('org[.]apache[.](grails|groovy).*', '.*', '.*-SNAPSHOT')
+ }
+ }
}
-}
-
-grailsPublish {
- user = System.getenv("BINTRAY_USER") ?: ''
- key = System.getenv("BINTRAY_KEY") ?: ''
- userOrg = 'kaleidos'
- repo = 'plugins'
- websiteUrl = 'https://github.com/kaleidos/grails-postgresql-extensions'
- license {
- name = 'Apache-2.0'
+ if (name == 'grails-postgresql-extensions') {
+ // This has to be applied here in the root project due to the nexus plugin requirements
+ apply plugin: 'org.apache.grails.gradle.grails-publish'
}
- issueTrackerUrl = 'https://github.com/kaleidosnet/grails-grails-postgresql-extensions/issues'
- vcsUrl = 'https://github.com/kaleidos/grails-postgresql-extensions.git'
- title = 'PostgreSQL Extensions'
- desc = 'This is a grails plugin that provides hibernate user types to use Postgresql native types. It also provides new criterias to query this new native types.'
- developers = [ivan: 'Iván López']
}
-
-apply from: "${rootProject.projectDir}/gradle/testVerbose.gradle"
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
new file mode 100644
index 0000000..56437fb
--- /dev/null
+++ b/buildSrc/build.gradle
@@ -0,0 +1,24 @@
+plugins {
+ id 'groovy-gradle-plugin'
+}
+
+def versions = new Properties()
+file('../gradle.properties').withInputStream {
+ versions.load(it)
+}
+
+repositories {
+ maven { url = 'https://repo.grails.org/grails/restricted' }
+ maven {
+ url = 'https://repository.apache.org/content/groups/snapshots'
+ content {
+ includeVersionByRegex('org[.]apache[.](grails|groovy).*', '.*', '.*-SNAPSHOT')
+ }
+ mavenContent { snapshotsOnly() }
+ }
+}
+
+dependencies {
+ implementation platform("org.apache.grails:grails-bom:${versions['grailsVersion']}")
+ implementation 'org.apache.grails:grails-gradle-plugins'
+}
diff --git a/gradle.properties b/gradle.properties
index bbc3fbc..5293811 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,4 +1,14 @@
-gradleWrapperVersion=5.1.1
-grailsVersion=4.0.0
-hibernateVersion=5.4.0.Final
-gormVersion=7.0.2.RELEASE
+projectVersion=8.0.0-SNAPSHOT
+
+grailsVersion=7.0.0-RC2
+javaVersion=17
+
+hibernate5Version=5.6.15.Final
+
+# This prevents the Grails Gradle Plugin from unnecessarily excluding slf4j-simple in the generated POMs
+# https://github.com/grails/grails-gradle-plugin/issues/222
+slf4jPreventExclusion=true
+
+org.gradle.caching=true
+org.gradle.daemon=true
+org.gradle.parallel=true
diff --git a/gradle/test-config.gradle b/gradle/test-config.gradle
new file mode 100644
index 0000000..f31b098
--- /dev/null
+++ b/gradle/test-config.gradle
@@ -0,0 +1,39 @@
+dependencies {
+ add('testRuntimeOnly', 'org.junit.platform:junit-platform-launcher')
+}
+
+tasks.withType(Test).configureEach {
+
+ useJUnitPlatform()
+
+ afterTest { desc, result ->
+ logger.quiet(
+ ' -- Executed test {} [{}] with result: {}',
+ desc.name, desc.className, result.resultType
+ )
+ }
+ testLogging {
+ events('passed', 'skipped', 'failed') // 'standardOut'
+ showExceptions = true
+ exceptionFormat = 'full'
+ showCauses = true
+ showStackTraces = true
+
+ // set options for log level DEBUG and INFO
+ debug {
+ events('passed', 'skipped', 'failed')//, 'started', 'standardOut', 'standardError'
+ exceptionFormat = 'full'
+ }
+ info.events = debug.events
+ info.exceptionFormat = debug.exceptionFormat
+ }
+
+ afterSuite { desc, result ->
+ if (!desc.parent) { // will match the outermost suite
+ def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
+ def startItem = '| ', endItem = ' |'
+ def repeatLength = startItem.length() + output.length() + endItem.length()
+ logger.quiet "\n${'-' * repeatLength}\n${startItem}${output}${endItem}\n${'-' * repeatLength}"
+ }
+ }
+}
\ No newline at end of file
diff --git a/gradle/testVerbose.gradle b/gradle/testVerbose.gradle
deleted file mode 100644
index a1149ee..0000000
--- a/gradle/testVerbose.gradle
+++ /dev/null
@@ -1,29 +0,0 @@
-tasks.withType(Test) {
- afterTest { desc, result ->
- //logger.quiet " -- Executed test ${desc.name} [${desc.className}] with result: ${result.resultType}"
- }
- testLogging {
- events "passed", "skipped", "failed"//, "standardOut"
- showExceptions true
- exceptionFormat "full"
- showCauses true
- showStackTraces true
-
- // set options for log level DEBUG and INFO
- debug {
- events "passed", "skipped", "failed"//, "started", "standardOut", "standardError"
- exceptionFormat "full"
- }
- info.events = debug.events
- info.exceptionFormat = debug.exceptionFormat
-
- afterSuite { desc, result ->
- if (!desc.parent) { // will match the outermost suite
- def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
- def startItem = '| ', endItem = ' |'
- def repeatLength = startItem.length() + output.length() + endItem.length()
- logger.quiet "\n${'-' * repeatLength}\n${startItem}${output}${endItem}\n${'-' * repeatLength}"
- }
- }
- }
-}
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 94336fc..1b33c55 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 558870d..d4081da 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index cccdd3d..23d15a9 100755
--- a/gradlew
+++ b/gradlew
@@ -1,78 +1,129 @@
-#!/usr/bin/env sh
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
##############################################################################
-##
-## Gradle start up script for UN*X
-##
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
##############################################################################
# Attempt to set APP_HOME
+
# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
+MAX_FD=maximum
warn () {
echo "$*"
-}
+} >&2
die () {
echo
echo "$*"
echo
exit 1
-}
+} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
esac
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+CLASSPATH="\\\"\\\""
+
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
+ JAVACMD=$JAVA_HOME/jre/sh/java
else
- JAVACMD="$JAVA_HOME/bin/java"
+ JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -81,92 +132,120 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
+ fi
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
fi
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
fi
- i=$((i+1))
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
fi
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
fi
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index e95643d..5eed7ee 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,4 +1,22 @@
-@if "%DEBUG%" == "" @echo off
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -9,25 +27,29 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if %ERRORLEVEL% equ 0 goto execute
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
@@ -35,48 +57,36 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+set CLASSPATH=
+
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
+if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/grails-app/conf/application.yml b/grails-app/conf/application.yml
deleted file mode 100644
index 9be0559..0000000
--- a/grails-app/conf/application.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-grails:
- profile: web-plugin
- codegen:
- defaultPackage: grails.postgresql.extensions
-info:
- app:
- name: '@info.app.name@'
- version: '@info.app.version@'
- grailsVersion: '@info.app.grailsVersion@'
-spring:
- groovy:
- template:
- check-template-location: false
-
-
----
-dataSource:
- pooled: true
- jmxExport: true
- driverClassName: org.postgresql.Driver
- dialect: net.kaleidos.hibernate.PostgresqlExtensionsDialect
- username: postgres_extensions
- password: postgres_extensions
- url: jdbc:postgresql://localhost/pg_extensions_test
- dbCreate: create-drop
-
-hibernate:
- dialect: net.kaleidos.hibernate.PostgresqlExtensionsDialect
diff --git a/grails-app/conf/logback.groovy b/grails-app/conf/logback.groovy
deleted file mode 100644
index 647d141..0000000
--- a/grails-app/conf/logback.groovy
+++ /dev/null
@@ -1,30 +0,0 @@
-import grails.util.BuildSettings
-import grails.util.Environment
-
-// See http://logback.qos.ch/manual/groovy.html for details on configuration
-appender('STDOUT', ConsoleAppender) {
- encoder(PatternLayoutEncoder) {
- pattern = "%level %logger - %msg%n"
- }
-}
-
-def targetDir = BuildSettings.TARGET_DIR
-if (Environment.isDevelopmentMode() && targetDir != null) {
- appender("FULL_STACKTRACE", FileAppender) {
- file = "${targetDir}/stacktrace.log"
- append = true
- encoder(PatternLayoutEncoder) {
- pattern = "%level %logger - %msg%n"
- }
- }
- logger("StackTrace", ERROR, ['FULL_STACKTRACE'], false)
- root(ERROR, ['STDOUT', 'FULL_STACKTRACE'])
-} else {
- root(ERROR, ['STDOUT'])
-}
-
-logger('org.hibernate.SQL', DEBUG)
-
-logger('org.hibernate.type', TRACE)
-
-logger('org.hibernate.tool.hbm2ddl', DEBUG)
diff --git a/grails-app/domain/test/array/TestDouble.groovy b/grails-app/domain/test/array/TestDouble.groovy
deleted file mode 100644
index 841b25a..0000000
--- a/grails-app/domain/test/array/TestDouble.groovy
+++ /dev/null
@@ -1,19 +0,0 @@
-package test.array
-
-import groovy.transform.ToString
-import net.kaleidos.hibernate.usertype.ArrayType
-
-@ToString
-class TestDouble {
-
- Double[] doubleNumbers
-
- static mapping = {
- doubleNumbers type: ArrayType, params: [type: Double]
- }
-
- static constraints = {
- doubleNumbers nullable: true
- }
-
-}
diff --git a/grails-app/domain/test/array/TestFloat.groovy b/grails-app/domain/test/array/TestFloat.groovy
deleted file mode 100644
index 3f5ef76..0000000
--- a/grails-app/domain/test/array/TestFloat.groovy
+++ /dev/null
@@ -1,20 +0,0 @@
-package test.array
-
-import groovy.transform.ToString
-import net.kaleidos.hibernate.usertype.ArrayType
-
-
-@ToString
-class TestFloat {
-
- Float[] floatNumbers
-
- static mapping = {
- floatNumbers type: ArrayType, params: [type: Float]
- }
-
- static constraints = {
- floatNumbers nullable: true
- }
-
-}
diff --git a/grails-app/domain/test/array/TestInteger.groovy b/grails-app/domain/test/array/TestInteger.groovy
deleted file mode 100644
index 8237f24..0000000
--- a/grails-app/domain/test/array/TestInteger.groovy
+++ /dev/null
@@ -1,19 +0,0 @@
-package test.array
-
-import groovy.transform.ToString
-import net.kaleidos.hibernate.usertype.ArrayType
-
-@ToString
-class TestInteger {
-
- Integer[] integerNumbers
-
- static mapping = {
- integerNumbers type: ArrayType, params: ["type": Integer]
- }
-
- static constraints = {
- integerNumbers nullable: true
- }
-
-}
diff --git a/grails-app/domain/test/array/TestLong.groovy b/grails-app/domain/test/array/TestLong.groovy
deleted file mode 100644
index a123e04..0000000
--- a/grails-app/domain/test/array/TestLong.groovy
+++ /dev/null
@@ -1,19 +0,0 @@
-package test.array
-
-import groovy.transform.ToString
-import net.kaleidos.hibernate.usertype.ArrayType
-
-@ToString
-class TestLong {
-
- Long[] longNumbers
-
- static mapping = {
- longNumbers type: ArrayType, params: [type: Long]
- }
-
- static constraints = {
- longNumbers nullable: true
- }
-
-}
diff --git a/grails-app/domain/test/array/TestString.groovy b/grails-app/domain/test/array/TestString.groovy
deleted file mode 100644
index 0d84b7b..0000000
--- a/grails-app/domain/test/array/TestString.groovy
+++ /dev/null
@@ -1,19 +0,0 @@
-package test.array
-
-import groovy.transform.ToString
-import net.kaleidos.hibernate.usertype.ArrayType
-
-@ToString
-class TestString {
-
- String[] stringArray
-
- static mapping = {
- stringArray type: ArrayType, params: [type: String]
- }
-
- static constraints = {
- stringArray nullable: true
- }
-
-}
diff --git a/grails-app/domain/test/array/TestUuid.groovy b/grails-app/domain/test/array/TestUuid.groovy
deleted file mode 100644
index bc02d1a..0000000
--- a/grails-app/domain/test/array/TestUuid.groovy
+++ /dev/null
@@ -1,19 +0,0 @@
-package test.array
-
-import groovy.transform.ToString
-import net.kaleidos.hibernate.usertype.ArrayType
-
-@ToString
-class TestUuid {
-
- UUID[] uuidArray
-
- static mapping = {
- uuidArray type: ArrayType, params: [type: UUID]
- }
-
- static constraints = {
- uuidArray nullable: true
- }
-
-}
diff --git a/grails-app/domain/test/criteria/array/User.groovy b/grails-app/domain/test/criteria/array/User.groovy
deleted file mode 100644
index 3144234..0000000
--- a/grails-app/domain/test/criteria/array/User.groovy
+++ /dev/null
@@ -1,16 +0,0 @@
-package test.criteria.array
-
-class User {
-
- String name
- Like like
-
- static mapping = {
- table "pg_extensions_user"
- }
-
- String toString() {
- name
- }
-
-}
diff --git a/grails-app/domain/test/hstore/TestHstoreMap.groovy b/grails-app/domain/test/hstore/TestHstoreMap.groovy
deleted file mode 100644
index 66890c3..0000000
--- a/grails-app/domain/test/hstore/TestHstoreMap.groovy
+++ /dev/null
@@ -1,25 +0,0 @@
-package test.hstore
-
-import groovy.transform.ToString
-import net.kaleidos.hibernate.usertype.HstoreMapType
-
-@ToString
-class TestHstoreMap {
-
- String name
- Integer luckyNumber
-
- Map testAttributes
-
- static constraints = {
- name nullable: true
- luckyNumber nullable: true
- }
-
- static mapping = {
- testAttributes type: HstoreMapType
- }
-
-}
-
-
diff --git a/grails-app/domain/test/json/TestMapJson.groovy b/grails-app/domain/test/json/TestMapJson.groovy
deleted file mode 100644
index 2028fb8..0000000
--- a/grails-app/domain/test/json/TestMapJson.groovy
+++ /dev/null
@@ -1,18 +0,0 @@
-package test.json
-
-import groovy.transform.ToString
-import net.kaleidos.hibernate.usertype.JsonMapType
-
-@ToString
-class TestMapJson {
-
- Map data
-
- static constraints = {
- data nullable: true
- }
-
- static mapping = {
- data type: JsonMapType
- }
-}
\ No newline at end of file
diff --git a/grails-app/domain/test/json/TestMapJsonb.groovy b/grails-app/domain/test/json/TestMapJsonb.groovy
deleted file mode 100644
index aadcef3..0000000
--- a/grails-app/domain/test/json/TestMapJsonb.groovy
+++ /dev/null
@@ -1,19 +0,0 @@
-package test.json
-
-import groovy.transform.ToString
-import net.kaleidos.hibernate.usertype.JsonbMapType
-
-@ToString
-class TestMapJsonb {
-
- Map data
-
- static constraints = {
- data nullable: true
- }
-
- static mapping = {
- data type: JsonbMapType
- }
-
-}
\ No newline at end of file
diff --git a/grails-app/services/test/criteria/array/PgArrayTestSearchService.groovy b/grails-app/services/test/criteria/array/PgArrayTestSearchService.groovy
deleted file mode 100644
index e850fe5..0000000
--- a/grails-app/services/test/criteria/array/PgArrayTestSearchService.groovy
+++ /dev/null
@@ -1,58 +0,0 @@
-package test.criteria.array
-
-class PgArrayTestSearchService {
-
- static transactional = false
-
- List search(String field, String criteriaName, value) {
- Like.withCriteria {
- "${criteriaName}" field, value
- }
- }
-
- List search(String field, String criteriaName) {
- Like.withCriteria {
- "${criteriaName}" field
- }
- }
-
- List searchWithJoin(String field, String criteriaName, value) {
- User.withCriteria {
- like {
- "${criteriaName}" field, value
- }
- }
- }
-
- List searchWithJoin(String field, String criteriaName) {
- User.withCriteria {
- like {
- "${criteriaName}" field
- }
- }
- }
-
- List searchWithJoinByStringOrInteger(Map params, String criteriaName) {
- User.withCriteria {
- like {
- or {
- params.each { entry->
- "${criteriaName}" (entry.key, entry.value)
- }
- }
- }
- }
- }
-
- List searchWithJoinAnd(Map params, String criteriaName) {
- User.withCriteria {
- like {
- and {
- params.each { entry->
- "${criteriaName}" (entry.key, entry.value)
- }
- }
- }
- }
- }
-}
diff --git a/grails-app/services/test/criteria/hstore/PgHstoreTestSearchService.groovy b/grails-app/services/test/criteria/hstore/PgHstoreTestSearchService.groovy
deleted file mode 100644
index 8c7676d..0000000
--- a/grails-app/services/test/criteria/hstore/PgHstoreTestSearchService.groovy
+++ /dev/null
@@ -1,13 +0,0 @@
-package test.criteria.hstore
-
-import test.hstore.TestHstoreMap
-
-class PgHstoreTestSearchService {
- static transactional = false
-
- List search(String field, String criteriaName, value) {
- TestHstoreMap.withCriteria {
- "${criteriaName}" field, value
- }
- }
-}
diff --git a/grails-app/services/test/criteria/json/PgJsonTestSearchService.groovy b/grails-app/services/test/criteria/json/PgJsonTestSearchService.groovy
deleted file mode 100644
index f2f5b2a..0000000
--- a/grails-app/services/test/criteria/json/PgJsonTestSearchService.groovy
+++ /dev/null
@@ -1,19 +0,0 @@
-package test.criteria.json
-
-import test.json.TestMapJson
-
-class PgJsonTestSearchService {
- static transactional = false
-
- List search(String criteriaName, String field, String jsonAttribute, value) {
- TestMapJson.withCriteria {
- "${criteriaName}" field, jsonAttribute, value.toString()
- }
- }
-
- List search(String criteriaName, String field, String jsonOp, String jsonAttribute, String sqlOp, value) {
- TestMapJson.withCriteria {
- "${criteriaName}" field, jsonOp, jsonAttribute, sqlOp, value.toString()
- }
- }
-}
diff --git a/grails-app/services/test/criteria/json/PgJsonbTestSearchService.groovy b/grails-app/services/test/criteria/json/PgJsonbTestSearchService.groovy
deleted file mode 100644
index 34e8f66..0000000
--- a/grails-app/services/test/criteria/json/PgJsonbTestSearchService.groovy
+++ /dev/null
@@ -1,25 +0,0 @@
-package test.criteria.json
-
-import test.json.TestMapJsonb
-
-class PgJsonbTestSearchService {
- static transactional = false
-
- List search(String criteriaName, String field, value) {
- TestMapJsonb.withCriteria {
- "${criteriaName}" field, value
- }
- }
-
- List search(String criteriaName, String field, String jsonAttribute, value) {
- TestMapJsonb.withCriteria {
- "${criteriaName}" field, jsonAttribute, value.toString()
- }
- }
-
- List search(String criteriaName, String field, String jsonOp, String jsonAttribute, String sqlOp, value) {
- TestMapJsonb.withCriteria {
- "${criteriaName}" field, jsonOp, jsonAttribute, sqlOp, value.toString()
- }
- }
-}
diff --git a/grails-app/services/test/order/PgOrderService.groovy b/grails-app/services/test/order/PgOrderService.groovy
deleted file mode 100644
index 3108958..0000000
--- a/grails-app/services/test/order/PgOrderService.groovy
+++ /dev/null
@@ -1,21 +0,0 @@
-package test.order
-
-import static net.kaleidos.hibernate.order.OrderByRandom.byRandom
-import static net.kaleidos.hibernate.order.OrderBySqlFormula.sqlFormula
-
-import test.json.TestMapJsonb
-
-class PgOrderService {
-
- List orderByJson() {
- return TestMapJsonb.withCriteria {
- order sqlFormula("(data->'name') desc")
- }
- }
-
- List orderByRandom() {
- return TestMapJsonb.withCriteria {
- order byRandom()
- }
- }
-}
diff --git a/plugin/build.gradle b/plugin/build.gradle
new file mode 100644
index 0000000..de5f5d3
--- /dev/null
+++ b/plugin/build.gradle
@@ -0,0 +1,76 @@
+plugins {
+ id 'java-library'
+ id 'org.apache.grails.gradle.grails-plugin'
+}
+
+version = projectVersion
+group = 'io.github.gpc'
+
+grailsPublish {
+ artifactId = 'grails-postgresql-extensions'
+ githubSlug = 'gpc/grails-postgresql-extensions'
+ license.name = 'Apache-2.0'
+ title = 'Grails PostgreSQL Extensions Plugin'
+ desc = 'A Grails plugin that adds Hibernate UserTypes for PostgreSQL native types, ' +
+ 'like Array, HStore, JSON, JSONB, ..., and GORM criteria extensions to query them.'
+ developers = [
+ ilopmar: 'Iván López',
+ alotor: 'Alonso Torres',
+ mattfeury: 'Matt Feury',
+ alvarosanchez: 'Alvaro Sanchez-Mariscal',
+ aeischeid: 'Aaron Eischeid',
+ mkobel: 'Moritz Kobel',
+ manuelvio: 'Manuel Unno Vio',
+ bameda: 'David Barragán Merino',
+ nobeans: 'Yasuharu Nakano',
+ burtbeckwith: 'Burt Beckwith',
+ timic: 'Timur Salyakhutdinov',
+ zlegein: 'Zach Legein',
+ tmarthal: 'Tom Marthaler',
+ pabloalba: 'Pablo Alba',
+ cornercase: 'Eamon Doyle',
+ poundex: 'Adam Pounder',
+ gregopet: 'Gregor Petrin',
+ unknown: 'Tom Potts',
+ sabst: 'Sabst',
+ donbeave: 'Alexey Zhokov',
+ jglapa: 'Jakub Glapa',
+ jamesdh: 'James Hardwick',
+ butters16: 'John Keith',
+ erichelgeson: 'Eric Helgeson',
+ albertop19: 'albertop19',
+ gtors: 'Andrey T',
+ matrei: 'Mattias Reichel',
+ ]
+}
+
+dependencies {
+
+ implementation platform("org.apache.grails:grails-bom:$grailsVersion")
+
+ compileOnly 'org.apache.grails:grails-core', { // Provided
+ // impl: Plugin
+ }
+ compileOnly 'org.apache.grails:grails-data-hibernate5', {
+ // Must be provided by the Grails application
+ }
+ compileOnly 'org.springframework:spring-core', { // Provided
+ // impl: Assert
+ }
+
+ implementation 'com.google.code.gson:gson'
+ implementation "org.hibernate:hibernate-core-jakarta:$hibernate5Version"
+ implementation 'org.postgresql:postgresql'
+
+ testImplementation 'org.spockframework:spock-core'
+
+ testRuntimeOnly 'org.springframework:spring-core', {
+ // Assert
+ }
+}
+
+compileJava.options.release = javaVersion.toInteger()
+
+apply {
+ from rootProject.layout.projectDirectory.file('gradle/test-config.gradle')
+}
\ No newline at end of file
diff --git a/plugin/src/main/groovy/gpc/pgext/GrailsPostgresqlExtensionsGrailsPlugin.groovy b/plugin/src/main/groovy/gpc/pgext/GrailsPostgresqlExtensionsGrailsPlugin.groovy
new file mode 100644
index 0000000..b578b83
--- /dev/null
+++ b/plugin/src/main/groovy/gpc/pgext/GrailsPostgresqlExtensionsGrailsPlugin.groovy
@@ -0,0 +1,57 @@
+package gpc.pgext
+
+import groovy.transform.CompileStatic
+
+import grails.plugins.Plugin
+
+@CompileStatic
+class GrailsPostgresqlExtensionsGrailsPlugin extends Plugin {
+
+ def grailsVersion = '7.0.0-SNAPSHOT > *'
+ def title = 'Grails PostgreSQL Extensions Plugin'
+ def author = 'Iván López'
+ def description = 'Provides Hibernate user types supporting PostgreSQL Native Types ' +
+ 'like Array, HStore, JSON, JSONB,... as well as new criteria to query ' +
+ 'these native types.'
+ def documentation = 'https://github.com/gpc/grails-postgresql-extensions'
+ def license = 'APACHE'
+ def organization = [
+ name: 'GPC',
+ url: 'https://github.com/gpc'
+ ]
+ def developers = [
+ [name: 'Alonso Torres'],
+ [name: 'Matt Feury'],
+ [name: 'Alvaro Sanchez-Mariscal'],
+ [name: 'Aaron Eischeid'],
+ [name: 'Moritz Kobel'],
+ [name: 'Manuel Unno Vio'],
+ [name: 'David Barragán Merino'],
+ [name: 'Yasuharu Nakano'],
+ [name: 'Burt Beckwith'],
+ [name: 'Timur Salyakhutdinov'],
+ [name: 'Zach Legein'],
+ [name: 'Tom Marthaler'],
+ [name: 'Pablo Alba'],
+ [name: 'Eamon Doyle'],
+ [name: 'Adam Pounder'],
+ [name: 'Gregor Petrin'],
+ [name: 'Tom Potts'],
+ [name: 'Sabst'],
+ [name: 'Alexey Zhokov'],
+ [name: 'Jakub Glapa'],
+ [name: 'James Hardwick'],
+ [name: 'John Keith'],
+ [name: 'Eric Helgeson'],
+ [name: 'albertop19'],
+ [name: 'Andrey T'],
+ [name: 'Mattias Reichel'],
+ ]
+ def issueManagement = [
+ system: 'GITHUB',
+ url: 'https://github.com/gpc/grails-postgresql-extensions/issues'
+ ]
+ def scm = [
+ url: 'https://github.com/gpc/grails-postgresql-extensions'
+ ]
+}
diff --git a/src/main/groovy/net/kaleidos/hibernate/PostgresqlExtensionsDialect.groovy b/plugin/src/main/groovy/gpc/pgext/hibernate/PostgresqlExtensionsDialect.groovy
similarity index 81%
rename from src/main/groovy/net/kaleidos/hibernate/PostgresqlExtensionsDialect.groovy
rename to plugin/src/main/groovy/gpc/pgext/hibernate/PostgresqlExtensionsDialect.groovy
index 0edb9d3..f5d8a50 100644
--- a/src/main/groovy/net/kaleidos/hibernate/PostgresqlExtensionsDialect.groovy
+++ b/plugin/src/main/groovy/gpc/pgext/hibernate/PostgresqlExtensionsDialect.groovy
@@ -1,13 +1,15 @@
-package net.kaleidos.hibernate
+package gpc.pgext.hibernate
+
+import java.sql.Types
import groovy.transform.CompileStatic
-import net.kaleidos.hibernate.usertype.ArrayType
-import net.kaleidos.hibernate.usertype.HstoreMapType
-import net.kaleidos.hibernate.usertype.JsonMapType
-import net.kaleidos.hibernate.usertype.JsonbMapType
+
import org.hibernate.dialect.PostgreSQL95Dialect
-import java.sql.Types
+import gpc.pgext.hibernate.usertype.ArrayType
+import gpc.pgext.hibernate.usertype.HstoreMapType
+import gpc.pgext.hibernate.usertype.JsonMapType
+import gpc.pgext.hibernate.usertype.JsonbMapType
@CompileStatic
class PostgresqlExtensionsDialect extends PostgreSQL95Dialect {
diff --git a/src/main/groovy/net/kaleidos/hibernate/criterion/array/PgArrayExpression.groovy b/plugin/src/main/groovy/gpc/pgext/hibernate/criterion/array/PgArrayExpression.groovy
similarity index 50%
rename from src/main/groovy/net/kaleidos/hibernate/criterion/array/PgArrayExpression.groovy
rename to plugin/src/main/groovy/gpc/pgext/hibernate/criterion/array/PgArrayExpression.groovy
index 2bf1046..f2a1832 100644
--- a/src/main/groovy/net/kaleidos/hibernate/criterion/array/PgArrayExpression.groovy
+++ b/plugin/src/main/groovy/gpc/pgext/hibernate/criterion/array/PgArrayExpression.groovy
@@ -1,16 +1,16 @@
-package net.kaleidos.hibernate.criterion.array
+package gpc.pgext.hibernate.criterion.array
import groovy.transform.CompileStatic
-import net.kaleidos.hibernate.usertype.ArrayType
-import net.kaleidos.hibernate.utils.PgArrayUtils
+
import org.hibernate.Criteria
import org.hibernate.HibernateException
-import org.hibernate.annotations.common.util.StringHelper
import org.hibernate.criterion.CriteriaQuery
import org.hibernate.criterion.Criterion
import org.hibernate.engine.spi.TypedValue
import org.hibernate.type.CustomType
-import org.hibernate.type.Type
+
+import gpc.pgext.hibernate.usertype.ArrayType
+import gpc.pgext.hibernate.utils.PgArrayUtils
@CompileStatic
class PgArrayExpression implements Criterion {
@@ -21,7 +21,7 @@ class PgArrayExpression implements Criterion {
private final Object value
private final String op
- protected PgArrayExpression(String propertyName, Object value, String op) {
+ PgArrayExpression(String propertyName, Object value, String op) {
this.propertyName = propertyName
this.value = value
this.op = op
@@ -29,47 +29,37 @@ class PgArrayExpression implements Criterion {
@Override
String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
- ArrayType arrayType = checkAndGetArrayType(criteria, criteriaQuery)
-
- String postgresArrayType = PgArrayUtils.getNativeSqlType(arrayType.getTypeClass()) + "[]"
-
- return StringHelper.join(
- " and ",
- StringHelper.suffix(criteriaQuery.findColumns(propertyName, criteria), " ${op} CAST(? as ${postgresArrayType})")
- )
+ def arrayType = checkAndGetArrayType(criteria, criteriaQuery)
+ def postgresArrayType = PgArrayUtils.getNativeSqlType(arrayType.getTypeClass()) + '[]'
+ criteriaQuery.findColumns(propertyName, criteria)
+ .collect {"$it $op CAST(? as $postgresArrayType)" }
+ .join(' and ')
}
@Override
TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
- ArrayType arrayType = checkAndGetArrayType(criteria, criteriaQuery)
-
- Object[] arrValue
- if (arrayType.typeClass.isEnum()) {
- arrValue = PgArrayUtils.getValueAsArrayOfType(value, Integer, mapValueToEnumOrdinal())
- } else {
- arrValue = PgArrayUtils.getValueAsArrayOfType(value, arrayType.typeClass)
- }
-
- return criteriaQuery.getTypedValue(criteria, propertyName, arrValue) as TypedValue[]
+ def arrayType = checkAndGetArrayType(criteria, criteriaQuery)
+ def arrValue = arrayType.typeClass.isEnum() ?
+ PgArrayUtils.getValueAsArrayOfType(value, Integer, mapValueToEnumOrdinal()) :
+ PgArrayUtils.getValueAsArrayOfType(value, arrayType.typeClass)
+ criteriaQuery.getTypedValue(criteria, propertyName, arrValue) as TypedValue[]
}
private PgArrayUtils.MapFunction mapValueToEnumOrdinal() {
- { Object o ->
+ return { Object o ->
try {
return (o as Enum).ordinal()
} catch (ClassCastException e) {
- throw new HibernateException("Unable to cast object ${o} to Enum", e)
+ throw new HibernateException("Unable to cast object $o to Enum", e)
}
} as PgArrayUtils.MapFunction
}
private ArrayType checkAndGetArrayType(Criteria criteria, CriteriaQuery criteriaQuery) {
- Type propertyType = criteriaQuery.getType(criteria, propertyName)
-
+ def propertyType = criteriaQuery.getType(criteria, propertyName)
if (!(propertyType instanceof CustomType) || !((propertyType as CustomType).userType instanceof ArrayType)) {
- throw new HibernateException("Property is not an instance of the postgres type ArrayType. Type is: ${propertyType.class}")
+ throw new HibernateException("Property is not an instance of the postgres type ArrayType. Type is: $propertyType.class")
}
-
- return (propertyType as CustomType).getUserType() as ArrayType
+ (propertyType as CustomType).userType as ArrayType
}
}
diff --git a/src/main/groovy/net/kaleidos/hibernate/criterion/array/PgArrayILikeFunction.groovy b/plugin/src/main/groovy/gpc/pgext/hibernate/criterion/array/PgArrayILikeFunction.groovy
similarity index 66%
rename from src/main/groovy/net/kaleidos/hibernate/criterion/array/PgArrayILikeFunction.groovy
rename to plugin/src/main/groovy/gpc/pgext/hibernate/criterion/array/PgArrayILikeFunction.groovy
index dbc4dc8..b680031 100644
--- a/src/main/groovy/net/kaleidos/hibernate/criterion/array/PgArrayILikeFunction.groovy
+++ b/plugin/src/main/groovy/gpc/pgext/hibernate/criterion/array/PgArrayILikeFunction.groovy
@@ -1,9 +1,9 @@
-package net.kaleidos.hibernate.criterion.array
+package gpc.pgext.hibernate.criterion.array
import groovy.transform.CompileStatic
+
import org.hibernate.Criteria
import org.hibernate.HibernateException
-import org.hibernate.annotations.common.util.StringHelper
import org.hibernate.criterion.CriteriaQuery
import org.hibernate.criterion.Criterion
import org.hibernate.engine.spi.TypedValue
@@ -17,18 +17,16 @@ class PgArrayILikeFunction implements Criterion {
private final String propertyName
private final String value
- protected PgArrayILikeFunction(String propertyName, String value) {
+ PgArrayILikeFunction(String propertyName, String value) {
this.propertyName = propertyName
this.value = value
}
@Override
String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
- String[] columns = StringHelper.suffix(criteriaQuery.findColumns(propertyName, criteria), "")
- for (int i = 0; i < columns.length; i++) {
- columns[i] = "text(${columns[i]}) ilike ?"
- }
- return StringHelper.join(" and ", columns)
+ criteriaQuery.findColumns(propertyName, criteria)
+ .collect { "text($it) ilike ?" }
+ .join(' and ')
}
@Override
diff --git a/src/main/groovy/net/kaleidos/hibernate/criterion/array/PgEmptinessExpression.groovy b/plugin/src/main/groovy/gpc/pgext/hibernate/criterion/array/PgEmptinessExpression.groovy
similarity index 71%
rename from src/main/groovy/net/kaleidos/hibernate/criterion/array/PgEmptinessExpression.groovy
rename to plugin/src/main/groovy/gpc/pgext/hibernate/criterion/array/PgEmptinessExpression.groovy
index b62c481..62a7de3 100644
--- a/src/main/groovy/net/kaleidos/hibernate/criterion/array/PgEmptinessExpression.groovy
+++ b/plugin/src/main/groovy/gpc/pgext/hibernate/criterion/array/PgEmptinessExpression.groovy
@@ -1,9 +1,9 @@
-package net.kaleidos.hibernate.criterion.array
+package gpc.pgext.hibernate.criterion.array
import groovy.transform.CompileStatic
+
import org.hibernate.Criteria
import org.hibernate.HibernateException
-import org.hibernate.annotations.common.util.StringHelper
import org.hibernate.criterion.CriteriaQuery
import org.hibernate.criterion.Criterion
import org.hibernate.engine.spi.TypedValue
@@ -18,17 +18,16 @@ class PgEmptinessExpression implements Criterion {
private static final TypedValue[] NO_VALUES = new TypedValue[0]
- protected PgEmptinessExpression(String propertyName, String op) {
+ PgEmptinessExpression(String propertyName, String op) {
this.propertyName = propertyName
this.op = op
}
@Override
String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
- StringHelper.join(
- " and ",
- StringHelper.suffix(criteriaQuery.findColumns(propertyName, criteria), " ${op} '{}'")
- )
+ criteriaQuery.findColumns(propertyName, criteria)
+ .collect { "$it $op '{}'" }
+ .join(' and ')
}
@Override
diff --git a/plugin/src/main/groovy/gpc/pgext/hibernate/criterion/hstore/PgHstoreILikeValueFunction.groovy b/plugin/src/main/groovy/gpc/pgext/hibernate/criterion/hstore/PgHstoreILikeValueFunction.groovy
new file mode 100644
index 0000000..24e9ea0
--- /dev/null
+++ b/plugin/src/main/groovy/gpc/pgext/hibernate/criterion/hstore/PgHstoreILikeValueFunction.groovy
@@ -0,0 +1,22 @@
+package gpc.pgext.hibernate.criterion.hstore
+
+import groovy.transform.CompileStatic
+
+import org.hibernate.Criteria
+import org.hibernate.HibernateException
+import org.hibernate.criterion.CriteriaQuery
+
+@CompileStatic
+class PgHstoreILikeValueFunction extends PgHstoreValueFunction {
+
+ PgHstoreILikeValueFunction(String propertyName, Object value) {
+ super(propertyName, value, '')
+ }
+
+ @Override
+ String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
+ criteriaQuery.findColumns(propertyName, criteria)
+ .collect { "text(avals($it)) ilike ?" }
+ .join(' and ')
+ }
+}
diff --git a/src/main/groovy/net/kaleidos/hibernate/criterion/hstore/PgHstoreOperatorExpression.groovy b/plugin/src/main/groovy/gpc/pgext/hibernate/criterion/hstore/PgHstoreOperatorExpression.groovy
similarity index 62%
rename from src/main/groovy/net/kaleidos/hibernate/criterion/hstore/PgHstoreOperatorExpression.groovy
rename to plugin/src/main/groovy/gpc/pgext/hibernate/criterion/hstore/PgHstoreOperatorExpression.groovy
index 9be43e9..19e4fef 100644
--- a/src/main/groovy/net/kaleidos/hibernate/criterion/hstore/PgHstoreOperatorExpression.groovy
+++ b/plugin/src/main/groovy/gpc/pgext/hibernate/criterion/hstore/PgHstoreOperatorExpression.groovy
@@ -1,16 +1,18 @@
-package net.kaleidos.hibernate.criterion.hstore
+package gpc.pgext.hibernate.criterion.hstore
import groovy.transform.CompileStatic
-import net.kaleidos.hibernate.usertype.HstoreHelper
+
import org.hibernate.Criteria
import org.hibernate.HibernateException
-import org.hibernate.annotations.common.util.StringHelper
import org.hibernate.criterion.CriteriaQuery
import org.hibernate.criterion.Criterion
import org.hibernate.engine.spi.TypedValue
+import gpc.pgext.hibernate.usertype.HstoreHelper
+
@CompileStatic
class PgHstoreOperatorExpression implements Criterion {
+
private static final long serialVersionUID = 2872183637309166619L
private final String propertyName
@@ -18,7 +20,11 @@ class PgHstoreOperatorExpression implements Criterion {
private final String operator
private static final TypedValue[] NO_VALUES = new TypedValue[0]
- protected PgHstoreOperatorExpression(String propertyName, Map