com.holon-platform.jdbc:holon-starter-jdbc-datastore-hikaricp

Holon Spring Boot JDBC Datastore starter using HikariCP DataSource

License

License

Categories

Categories

Data HikariCP Databases ORM
GroupId

GroupId

com.holon-platform.jdbc
ArtifactId

ArtifactId

holon-starter-jdbc-datastore-hikaricp
Last Version

Last Version

5.5.0
Release Date

Release Date

Type

Type

jar
Description

Description

com.holon-platform.jdbc:holon-starter-jdbc-datastore-hikaricp
Holon Spring Boot JDBC Datastore starter using HikariCP DataSource
Project URL

Project URL

https://holon-platform.com
Project Organization

Project Organization

The Holon Platform

Download holon-starter-jdbc-datastore-hikaricp

How to add to project

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

Dependencies

compile (2)

Group / Artifact Type Version
com.holon-platform.jdbc : holon-starter-jdbc-hikaricp jar 5.5.0
com.holon-platform.jdbc : holon-datastore-jdbc-spring-boot jar 5.5.0

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 JDBC Datastore

Latest release: 5.5.0

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

See the Datastore API documentation for information about the Holon Platform Datastore API.

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

  • The DataTarget name is interpreted as the database table (or view) name.
  • The Path name is interpreted as a table column name.

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

Transactions support is ensured through the Holon Platform Transactional API.

The JDBC Datastore leverages on dialects to transparently support different RDBMS vendors. Dialects for the following RDBMS are provided:

  • MySQL
  • MariaDB
  • Oracle Database
  • Microsoft SQL Server
  • PostgreSQL
  • IBM DB2
  • IBM Informix
  • SAP HANA
  • H2
  • HSQLDB
  • Derby
  • SQLite

A complete Spring and Spring Boot support is provided for JDBC 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

JDBC Datastore operations:

Datastore datastore = JdbcDatastore.builder().dataSource(myDataSource).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());

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;
});

JDBC Datastore extension:

// Function definition
class IfNull<T> implements QueryFunction<T, T> {
  /* content omitted */		
}

// Function resolver
class IfNullResolver implements ExpressionResolver<IfNull, SQLFunction> {

  @Override
  public Optional<SQLFunction> resolve(IfNull expression, ResolutionContext context) {
    return Optional.of(SQLFunction.create(args ->  "IFNULL(" + args.get(0) + "," + args.get(1) + ")"));
  }
	
}

// Datastore integration
Datastore datastore = JdbcDatastore.builder().withExpressionResolver(new IfNullResolver()).build();

Stream<String> values = datastore.query(TARGET).stream(new IfNull<>(VALUE, "(fallback)"));

JDBC Datastore configuration using Spring:

@EnableJdbcDatastore
@Configuration
class Config {

  @Bean
  public DataSource dataSource() {
    return buildDataSource();
  }

}

@Autowired
Datastore datastore;

JDBC 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.

A JDBC driver which supports the JDBC API version 4.x or above is reccomended to use all the functionalities of the JDBC 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.jdbc and a BOM (Bill of Materials) is provided to obtain the module artifacts:

Maven BOM:

<dependencyManagement>
    <dependency>
        <groupId>com.holon-platform.jdbc</groupId>
        <artifactId>holon-datastore-jdbc-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

NOTE: The holon-datastore-jdbc-composer artifact requires the Oracle JDBC driver as optional dependency to compile the Oracle SQLDialect class. Since the Oracle JDBC driver is not available from Maven Central, to compile the project you should manually download and install it in your local Maven repository or follow the Oracle Maven repository setup instructions here.

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.jdbc

Artifact id Description
holon-datastore-jdbc JDBC Datastore API implementation
holon-datastore-jdbc-composer The SQL composer engine based on the Java JDBC API
holon-datastore-jdbc-spring Spring integration using the @EnableJdbcDatastore annotation
holon-datastore-jdbc-spring-boot Spring Boot integration for JDBC Datastore auto-configuration
holon-starter-jdbc-datastore Spring Boot starter for the JDBC Datastore auto-configuration
holon-starter-jdbc-datastore-hikaricp Spring Boot starter for the JDBC Datastore auto-configuration using the HikariCP pooling DataSource
holon-datastore-jdbc-bom Bill Of Materials
documentation-datastore-jdbc Documentation
com.holon-platform.jdbc

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.5
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.3
5.1.2
5.1.1
5.1.0
5.0.5
5.0.4
5.0.3
5.0.2
5.0.1
5.0.0