com.holon-platform.jpa:holon-datastore-jpa-spring

Holon JPA Datastore Spring integration

License

License

Categories

Categories

Data ORM
GroupId

GroupId

com.holon-platform.jpa
ArtifactId

ArtifactId

holon-datastore-jpa-spring
Last Version

Last Version

5.5.0
Release Date

Release Date

Type

Type

jar
Description

Description

com.holon-platform.jpa:holon-datastore-jpa-spring
Holon JPA Datastore Spring integration
Project URL

Project URL

https://holon-platform.com
Project Organization

Project Organization

The Holon Platform

Download holon-datastore-jpa-spring

How to add to project

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

Dependencies

compile (6)

Group / Artifact Type Version
com.holon-platform.jdbc : holon-jdbc-spring jar 5.5.0
com.holon-platform.jpa : holon-datastore-jpa jar 5.5.0
org.springframework : spring-orm jar
net.bytebuddy : byte-buddy jar 1.10.13
org.hibernate : hibernate-core Optional jar 5.4.18.Final
org.eclipse.persistence : org.eclipse.persistence.jpa Optional jar 2.7.7

provided (1)

Group / Artifact Type Version
javax.persistence : javax.persistence-api jar 2.2

test (6)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.2.3
com.zaxxer : HikariCP jar 3.4.5
com.h2database : h2 jar 1.4.198
org.springframework : spring-test jar
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