An open API service indexing awesome lists of open source software.

https://github.com/bernardo-mg/jpa-example

An example showing how to set up and test JPA classes.
https://github.com/bernardo-mg/jpa-example

criteria-api example jpa persistence

Last synced: 11 months ago
JSON representation

An example showing how to set up and test JPA classes.

Awesome Lists containing this project

README

          

# JPA Example

An example showing how to set up and test JPA classes.

[![Release docs](https://img.shields.io/badge/docs-release-blue.svg)][site-release]
[![Development docs](https://img.shields.io/badge/docs-develop-blue.svg)][site-develop]

[![Release javadocs](https://img.shields.io/badge/javadocs-release-blue.svg)][javadoc-release]
[![Development javadocs](https://img.shields.io/badge/javadocs-develop-blue.svg)][javadoc-develop]

## Features

The project offers examples showing how to set up and test JPA classes, covering the following cases:

- Collection and map fields
- Converters
- Date, time and timestamp fields
- Embedded objects
- Enumeration fields
- Inheritance schemes (discriminator, table per class, joined, mapped super class)
- Id fields (class id, composite, embeddable composite)
- Large object fields
- Relationships (many to many, many to one, one to one)
- Sequences (auto generated, generated identity, sequence, table)
- Secondary table

## Documentation

Documentation is always generated for the latest release, kept in the 'master' branch:

- The [latest release documentation page][site-release].
- The [the latest release Javadoc site][javadoc-release].

Documentation is also generated from the latest snapshot, taken from the 'develop' branch:

- The [the latest snapshot documentation page][site-develop].
- The [the latest snapshot Javadoc site][javadoc-develop].

The documentation site sources come along the source code (as it is a Maven site), so it is always possible to generate them using the following Maven command:

```
mvn verify site -P h2,eclipselink
```

The verify phase is required, as otherwise some of the reports won't be created.

## Usage

The application is coded in Java, using Maven to manage the project.

### Profiles

Maven profiles are included for setting up the database and JPA provider.

| Profile | Database |
|----------|---------------------------|
| h2 | H2 in-memory database |
| hsqldb | HSQLDB in-memory database |
| mysql | MySQL database |
| postgres | PostgreSQL database |

| Profile | Provider |
|-------------|-------------|
| hibernate | Hibernate |
| eclipselink | Eclipselink |

### Running the tests

The project requires a database and a JPA provider for being able to run the integration tests:

```
mvn verify -P h2,eclipselink
```

### Missing JPA metadata

Currently there are some problems when generating the JPA metadata classes automatically. Mainly that they are not generated when trying to refresh the Maven project on Eclipse.

To fix this just package the project:

```
mvn package
```

## Collaborate

Any kind of help with the project will be well received, and there are two main ways to give such help:

- Reporting errors and asking for extensions through the issues management
- or forking the repository and extending the project

### Issues management

Issues are managed at the GitHub [project issues tracker][issues], where any Github user may report bugs or ask for new features.

### Getting the code

If you wish to fork or modify the code, visit the [GitHub project page][scm], where the latest versions are always kept. Check the 'master' branch for the latest release, and the 'develop' for the current, and stable, development version.

## License

The project has been released under the [MIT License][license].

[issues]: https://github.com/bernardo-mg/jpa-example/issues
[javadoc-develop]: http://docs.bernardomg.com/development/maven/jpa-example/apidocs/
[javadoc-release]: http://docs.bernardomg.com/maven/jpa-example/apidocs
[license]: http://www.opensource.org/licenses/mit-license.php
[scm]: https://github.com/bernardo-mg/jpa-example
[site-develop]: http://docs.bernardomg.com/development/maven/jpa-example
[site-release]: http://docs.bernardomg.com/maven/jpa-example