com.github.gentity:gentity-lib

JPA Entity class generator from DBSchema (*.dbs) database models (see https://www.dbschema.com)

License

License

GroupId

GroupId

com.github.gentity
ArtifactId

ArtifactId

gentity-lib
Last Version

Last Version

0.26
Release Date

Release Date

Type

Type

jar
Description

Description

JPA Entity class generator from DBSchema (*.dbs) database models (see https://www.dbschema.com)
Project Organization

Project Organization

The Gentity Project

Download gentity-lib

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.gentity/gentity-lib/ -->
<dependency>
    <groupId>com.github.gentity</groupId>
    <artifactId>gentity-lib</artifactId>
    <version>0.26</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.gentity/gentity-lib/
implementation 'com.github.gentity:gentity-lib:0.26'
// https://jarcasting.com/artifacts/com.github.gentity/gentity-lib/
implementation ("com.github.gentity:gentity-lib:0.26")
'com.github.gentity:gentity-lib:jar:0.26'
<dependency org="com.github.gentity" name="gentity-lib" rev="0.26">
  <artifact name="gentity-lib" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.gentity', module='gentity-lib', version='0.26')
)
libraryDependencies += "com.github.gentity" % "gentity-lib" % "0.26"
[com.github.gentity/gentity-lib "0.26"]

Dependencies

test (3)

Group / Artifact Type Version
junit : junit jar 4.13.1
org.hamcrest : hamcrest-core jar 1.3
javax.persistence : javax.persistence-api jar 2.2

Project Modules

There are no modules declared in this project.

gentity Build Status Maven

JPA Entity class generator from MySQL Workbench (.mwb) and DBSchema (.dbs) database models.

The Workflow:

  1. Create/modify database model in modeller tool (MySQL Workbench / DbSchema)
  2. Run gentity from Maven or directly from command line to generate entity classes

So, Gentity doesn't need a running database; entity classes are generated directly from the modeller file. Perfect for build automation!

Documentation

  • The Wiki contains an in-depth discussion on usage and concepts
  • Keep on reading below for a quick start!

Features

  • Automatic entity generation from table schema
  • Automatically derives:
    • Entity fields from column definitions
    • OneToMany / OneToOne / ManyToMany relations from foreign key and index definitions
    • Non-Entity collections (@ElementCollection / @Embeddable)
  • Additional mapping definition file, to
    • Override derived definitions from database modeller file
    • Define inheritance hierarchies (supported strategies are JOINED and SINGLE_TABLE)
  • Bidirectional and unidirectional relationships are supported
  • Mutual update of bidirectional relations (when one side is updated, the other is updated automagically)
  • External (non-generated) superclasses and superinterfaces for generated entities
  • Supported database modellers:

Quick Start

Add this to your pom.xml's <build>/<plugins> section:

<plugin>
    <groupId>com.github.gentity</groupId>
    <artifactId>gentity-maven-plugin</artifactId>
    <version>0.17</version>  <!-- replace with newest release version -->
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputDbsFile>my-db-model.dbs</inputDbsFile>
            </configuration>
        </execution>
    </executions>
</plugin>

You'll also need the gentity library (gentity-lib):

<dependency>
    <groupId>com.github.gentity</groupId>
    <artifactId>gentity-lib</artifactId>
    <version>0.17</version>  <!-- must match the gentity plugin version -->
</dependency>

Note that you'll also need your ORM's libraries (EclipseLink, Hibernate, etc.), or at least the JPA API:

TODO

  • Support for unidirectional OneToMany (this has issues attached, as standard JPA defaulting requires a join table - however, JPA 2.2 also supports them without one, but that has implications)
  • Per Class inheritance
  • Provide better error output, especially for the mapping config file explaining where in the file to look for errors. See this post on how to do this for our deserialized mapping config info: https://stackoverflow.com/questions/7079796/jaxb-location-in-file-for-unmarshalled-objects

Maven Central shield image from shields.io

Versions

Version
0.26
0.25
0.24
0.23
0.22
0.21
0.20
0.19
0.18
0.17
0.16
0.15
0.14
0.13