Skip to content

About

Modern Gradle plugins for effortless Hibernate and EclipseLink bytecode enhancement.

Topics

Resources

Code of conduct

Contributing

Security policy

Accessibility

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

264 Commits

Folders and files

πŸ“¦ JPersist: Zero-Boilerplate JPA Build Automation for Gradle

Java Gradle CI GitHub Release GitHub License

πŸ“Š Component Status Matrices

Component Release Version Quality Gate Code Coverage
πŸ”Œ Gradle Plugins Gradle Plugin Portal Version Quality gate status Coverage
πŸ“¦ Core Libraries Maven Central Quality gate status Coverage

🧩 What is JPersist?

JPersist is a suite of modern, high-performance, and Gradle Configuration Cache-compliant plugins that completely automates the tedious boilerplate configuration of enterprise Jakarta Persistence API (JPA) environments.

It handles everything a JPA developer needs at build time β€” from persistence.xml descriptor generation and merge to bytecode enhancement, metamodel generation, schema validation, GraalVM native image metadata, and compile-time named query linting β€” so you can focus on writing entities and queries instead of fighting build scripts.


πŸ† Why JPersist is the Ultimate JPA Development Tool for Gradle

Standard Gradle setups require verbose XML overrides, break incremental compilation states during bytecode manipulation, and crash with complex classpath decoration proxy loops. JPersist fixes this permanently.

Standard Gradle Setup The JPersist Advantage
❌ Manual <class> tagging required βœ… ASM-powered bytecode scanning auto-detects entities
❌ Hardcoded schema structures βœ… Strategy-driven polymorphism supports JPA 2.0 to 3.2 dynamically
❌ Rigid monolithic output paths βœ… Declarative attributes route individual JAR locations via the DSL
❌ Broken workspace sync mappings βœ… Automated IDE indexing hooks into Buildship and IntelliJ out-of-the-box
❌ Named query errors only at runtime βœ… Compile-time query linting catches JPQL/HQL syntax errors before deployment
❌ Manual GraalVM reflection config βœ… Automatic reflect-config.json generation for native images

⚑ Key Features

  • Descriptor Generation & Merging β€” Generates or intelligently merges persistence.xml descriptors per source set using ASM bytecode scanning for automatic entity class discovery.
  • Hibernate Bytecode Enhancement β€” Compile-time enhancement for lazy initialization, dirty tracking, and association management without runtime agents.
  • EclipseLink Static Weaving β€” Compile-time static weaving fully isolated from the Gradle daemon classpath.
  • OpenJPA Bytecode Enhancement (new in v1.8.0) β€” Compile-time PCEnhancer-based bytecode enhancement for OpenJPA entities, forked in an isolated JVM process.
  • JPA Static Metamodel Generation β€” Automatic annotation processor setup for type-safe Criteria API queries (Hibernate, EclipseLink, and OpenJPA).
  • Schema Validation β€” Validates entity mappings against a database schema at build time using an isolated Gradle Worker process.
  • Multi-Tenant Schema Validation (new in v1.7.0) β€” Extends schema validation with named tenant profiles, each carrying its own JDBC connection properties for validating against multiple database tenants in a single build.
  • GraalVM Native Image Metadata β€” Generates reflect-config.json for all discovered JPA entities, enabling ahead-of-time reflection registration. (v1.8.0: new reflectConfigFile property; outputFile deprecated)
  • Consolidated Reporting (new in v1.8.0) β€” All verification reports (schema validation, query linting) are written to a unified ${buildDir}/reports/persistence/ directory for streamlined CI/CD artifact collection.
  • Lint Named Queries β€” Static, compile-time AST verification of @NamedQuery and @NamedStoredProcedureQuery definitions with JPQL/HQL syntax and parameter naming validation.

πŸš€ Getting Started

Apply the plugin matching your JPA provider. The jpa dependency configuration centralizes version management via a BOM platform across all standard Java compilation scopes.

Hibernate Hibernate Setup

Groovy DSL
plugins {
    id 'io.github.jpersist.hibernate-persistence' version '1.8.0'
}

dependencies {
    jpa platform('org.hibernate.orm:hibernate-platform:6.6.56.Final')

    implementation 'org.hibernate.orm:hibernate-core'
}
Kotlin DSL
plugins {
    id("io.github.jpersist.hibernate-persistence") version "1.8.0"
}

dependencies {
    jpa(platform("org.hibernate.orm:hibernate-platform:6.6.56.Final"))

    implementation("org.hibernate.orm:hibernate-core")
}

EclipseLink EclipseLink Setup

Groovy DSL
plugins {
    id 'io.github.jpersist.eclipse-persistence' version '1.8.0'
}

dependencies {
    jpa platform('org.eclipse.persistence:org.eclipse.persistence.parent:4.0.9')

    compileOnly 'jakarta.persistence:jakarta.persistence-api'
    implementation 'org.eclipse.persistence:org.eclipse.persistence.core'
}
Kotlin DSL
plugins {
    id("io.github.jpersist.eclipse-persistence") version "1.8.0"
}

dependencies {
    jpa(platform("org.eclipse.persistence:org.eclipse.persistence.parent:4.0.9"))

    compileOnly("jakarta.persistence:jakarta.persistence-api")
    implementation("org.eclipse.persistence:org.eclipse.persistence.core")
}

OpenJPA OpenJPA Setup

Groovy DSL
plugins {
    id 'io.github.jpersist.openjpa-persistence' version '1.8.0'
}

dependencies {
    jpa 'org.apache.openjpa:openjpa:4.0.0'

    compileOnly 'jakarta.persistence:jakarta.persistence-api:3.1.0'
}
Kotlin DSL
plugins {
    id("io.github.jpersist.openjpa-persistence") version "1.8.0"
}

dependencies {
    jpa("org.apache.openjpa:openjpa:4.0.0")

    compileOnly("jakarta.persistence:jakarta.persistence-api:3.1.0")
}

That's it β€” no additional XML configuration or annotation processing setup is required. The plugin automatically detects your entity classes and generates the appropriate persistence.xml at build time.


πŸ—οΈ Repository Structure

Directory Description
plugins/jakarta-persistence-gradle-plugin Core plugin β€” generates/merges persistence.xml, validates schemas, generates GraalVM metadata, and lints named queries.
plugins/hibernate-persistence-gradle-plugin Hibernate aggregate plugin β€” metamodel generation and compile-time bytecode enhancement.
plugins/eclipse-persistence-gradle-plugin EclipseLink aggregate plugin β€” metamodel generation and compile-time static weaving.
plugins/openjpa-persistence-gradle-plugin OpenJPA aggregate plugin β€” metamodel generation and compile-time PCEnhancer bytecode enhancement.
libraries/persistence-tools-api SPI contract and core interfaces for the named query linter (io.github.jpersist.tools:persistence-tools-api).
libraries/persistence-tools-jakarta Jakarta Persistence (3.x) linter implementation (io.github.jpersist.tools:persistence-tools-jakarta).
libraries/persistence-tools-legacy Legacy JPA (2.x) linter implementation (io.github.jpersist.tools:persistence-tools-legacy).
libraries/persistence-tools-bom BOM (Bill of Materials) for aligning all persistence-tools library versions.
examples/ Runnable example projects for Hibernate, EclipseLink, and standalone Jakarta Persistence.

πŸ“š Further Information


βš™οΈ Requirements

  • Gradle: 7.4+ or 8.x+ / 9.x+
  • Java: JDK 17 or higher (required by modern Jakarta specifications)

πŸ’– Support the Project

If JPersist is saving your engineering team debugging hours, consider backing us!

πŸ‘‰ Become a GitHub Sponsor

πŸ“„ License

Distributed under the Apache License 2.0. See the LICENSE file for more information.

About

Modern Gradle plugins for effortless Hibernate and EclipseLink bytecode enhancement.

Topics

Resources

Code of conduct

Contributing

Security policy

Accessibility

Stars

2 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages