com.holon-platform.jpa:holon-starter-jpa-hibernate

Holon Spring Boot JPA starter using Hibernate and HikariCP datasource

License

License

Categories

Categories

ORM Data Hibernate
GroupId

GroupId

com.holon-platform.jpa
ArtifactId

ArtifactId

holon-starter-jpa-hibernate
Last Version

Last Version

5.5.0
Release Date

Release Date

Type

Type

jar
Description

Description

com.holon-platform.jpa:holon-starter-jpa-hibernate
Holon Spring Boot JPA starter using Hibernate and HikariCP datasource
Project URL

Project URL

https://holon-platform.com
Project Organization

Project Organization

The Holon Platform

Download holon-starter-jpa-hibernate

How to add to project

<!-- https://jarcasting.com/artifacts/com.holon-platform.jpa/holon-starter-jpa-hibernate/ -->
<dependency>
    <groupId>com.holon-platform.jpa</groupId>
    <artifactId>holon-starter-jpa-hibernate</artifactId>
    <version>5.5.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.holon-platform.jpa/holon-starter-jpa-hibernate/
implementation 'com.holon-platform.jpa:holon-starter-jpa-hibernate:5.5.0'
// https://jarcasting.com/artifacts/com.holon-platform.jpa/holon-starter-jpa-hibernate/
implementation ("com.holon-platform.jpa:holon-starter-jpa-hibernate:5.5.0")
'com.holon-platform.jpa:holon-starter-jpa-hibernate:jar:5.5.0'
<dependency org="com.holon-platform.jpa" name="holon-starter-jpa-hibernate" rev="5.5.0">
  <artifact name="holon-starter-jpa-hibernate" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.holon-platform.jpa', module='holon-starter-jpa-hibernate', version='5.5.0')
)
libraryDependencies += "com.holon-platform.jpa" % "holon-starter-jpa-hibernate" % "5.5.0"
[com.holon-platform.jpa/holon-starter-jpa-hibernate "5.5.0"]

Dependencies

compile (5)

Group / Artifact Type Version
com.holon-platform.core : holon-starter jar 5.5.0
com.holon-platform.jpa : holon-datastore-jpa-spring-boot jar 5.5.0
com.zaxxer : HikariCP jar 3.4.5
org.hibernate : hibernate-core jar 5.4.18.Final
org.hibernate.validator : hibernate-validator jar 6.1.5.Final

test (2)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.6.2
org.junit.jupiter : junit-jupiter-engine jar 5.6.2

Project Modules

There are no modules declared in this project.

Holon platform JPA Datastore

Latest release: 5.5.0

This is the reference JPA Datastore implementation of the Holon Platform, using the Java JPA API for data access and manipulation.

The JPA Datastore relies on the following conventions regarding DataTarget and Path naming strategy:

  • The DataTarget name is interpreted as the JPA entity name.
  • The Path name is interpreted as a JPA entity attribute name, supporting nested classes through the conventional dot notation.

As a relational Datastore, standard relational expressions are supported (alias, joins and sub-queries).

The JPA Datastore supports any standard JPA ORM library, altough is tested and optimized specifically for:

A complete Spring and Spring Boot support is provided for JPA Datastore integration in a Spring environment and for auto-configuration facilities.

See the module documentation for details.

Just like any other platform module, this artifact is part of the Holon Platform ecosystem, but can be also used as a stand-alone library.

See Getting started and the platform documentation for further details.

At-a-glance overview

JPA Datastore operations:

DataTarget<MyEntity> TARGET = JpaTarget.of(MyEntity.class);
		
Datastore datastore = JpaDatastore.builder().entityManagerFactory(myEntityManagerFactory).build();

datastore.save(TARGET, PropertyBox.builder(TEST).set(ID, 1L).set(VALUE, "One").build());

Stream<PropertyBox> results = datastore.query().target(TARGET).filter(ID.goe(1L)).stream(TEST);

List<String> values = datastore.query().target(TARGET).sort(ID.asc()).list(VALUE);

Stream<String> values = datastore.query().target(TARGET).filter(VALUE.startsWith("prefix")).restrict(10, 0).stream(VALUE);

long count = datastore.query(TARGET).aggregate(QueryAggregation.builder().path(VALUE).filter(ID.gt(1L)).build()).count();

Stream<Integer> months = datastore.query().target(TARGET).distinct().stream(LOCAL_DATE.month());
		
List<MyEntity> entities = datastore.query().target(TARGET).list(BeanProjection.of(MyEntity.class));

datastore.bulkUpdate(TARGET).filter(ID.in(1L, 2L)).set(VALUE, "test").execute();

datastore.bulkDelete(TARGET).filter(ID.gt(0L)).execute();

Transaction management:

long updatedCount = datastore.withTransaction(tx -> {
	long updated = datastore.bulkUpdate(TARGET).set(VALUE, "test").execute().getAffectedCount();
			
	tx.commit();
			
	return updated;
});

JPA Datastore configuration using Spring:

@EnableJpaDatastore
@Configuration
class Config {

  @Bean
  public FactoryBean<EntityManagerFactory> entityManagerFactory(DataSource dataSource) {
      LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
      emf.setDataSource(dataSource);
      emf.setPackagesToScan("com.example.entities");
      return emf;
  }

}

@Autowired
Datastore datastore;

JPA Datastore auto-configuration using Spring Boot:

spring:
  datasource:
    url: "jdbc:h2:mem:test"
    username: "sa"
    
holon: 
  datastore:
    trace: true

See the module documentation for the user guide and a full set of examples.

Code structure

See Holon Platform code structure and conventions to learn about the "real Java API" philosophy with which the project codebase is developed and organized.

Getting started

System requirements

The Holon Platform is built using Java 8, so you need a JRE/JDK version 8 or above to use the platform artifacts.

The JPA API version 2.x or above is reccomended to use all the functionalities of the JPA Datastore.

Releases

See releases for the available releases. Each release tag provides a link to the closed issues.

Obtain the artifacts

The Holon Platform is open source and licensed under the Apache 2.0 license. All the artifacts (including binaries, sources and javadocs) are available from the Maven Central repository.

The Maven group id for this module is com.holon-platform.jpa and a BOM (Bill of Materials) is provided to obtain the module artifacts:

Maven BOM:

<dependencyManagement>
    <dependency>
        <groupId>com.holon-platform.jpa</groupId>
        <artifactId>holon-datastore-jpa-bom</artifactId>
        <version>5.5.0</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
</dependencyManagement>

See the Artifacts list for a list of the available artifacts of this module.

Using the Platform BOM

The Holon Platform provides an overall Maven BOM (Bill of Materials) to easily obtain all the available platform artifacts:

Platform Maven BOM:

<dependencyManagement>
    <dependency>
        <groupId>com.holon-platform</groupId>
        <artifactId>bom</artifactId>
        <version>${platform-version}</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
</dependencyManagement>

See the Artifacts list for a list of the available artifacts of this module.

Build from sources

You can build the sources using Maven (version 3.3.x or above is recommended) like this:

mvn clean install

Getting help

Examples

See the Holon Platform examples repository for a set of example projects.

Contribute

See Contributing to the Holon Platform.

Gitter chat Join the contribute Gitter room for any question and to contact us.

License

All the Holon Platform modules are Open Source software released under the Apache 2.0 license.

Artifacts list

Maven group id: com.holon-platform.jpa

Artifact id Description
holon-datastore-jpa JPA Datastore implementation
holon-datastore-jpa-spring Spring integration using the @EnableJpa and @EnableJpaDatastore annotations
holon-datastore-jpa-spring-boot Spring Boot integration for JPA stack and Datastore auto-configuration
holon-starter-jpa-hibernate Spring Boot starter for JPA stack and Datastore auto-configuration using Hibernate ORM
holon-starter-jpa-eclipselink Spring Boot starter for JPA stack and Datastore auto-configuration using EclipseLink ORM
holon-datastore-jpa-bom Bill Of Materials
documentation-datastore-jpa Documentation
com.holon-platform.jpa

Holon Platform

The Holon Platform is a Java development ecosystem to create and maintain high quality, enteprise-grade web applications and services.

Versions

Version
5.5.0
5.4.0
5.3.0
5.2.4
5.2.3
5.2.2
5.2.1
5.2.0
5.2.0-rc2
5.2.0-rc1
5.2.0-alpha2
5.2.0-alpha1
5.1.2
5.1.1
5.1.0
5.0.4
5.0.3
5.0.2
5.0.1
5.0.0