A JDK 8 wrapper on top of Hibernate Query API
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
codequality
gradle
src
.gitignore
.java-version
.travis.yml
LICENSE
README.md
api.adoc
build.gradle
gradle.properties
gradlew
gradlew.bat
libraries.gradle

README.md

Hibernate Streams

A JDK 8 wrapper on top of Hibernate Query API

Build Status

Features

  • Retrieval of Optional query results
  • Query to stream conversion
  • Typed queries

Current compatibility: Hibernate 4.3.x / Hibernate 5.x

See the document that summarizes the introduced API changes

Setup

In order to start and running simply add the artifact to your Maven/Gradle build.

<dependency>
    <groupId>com.github.jmnarloch</groupId>
    <artifactId>hstreams43</artifactId>
    <version>1.0.2</version>
</dependency>

Example

SessionFactory originalFactory = ...;

StreamSessionFactory factory = Streams.wrap(originalFactory);
StreamSession session = factory.getCurrentSession();

long count = session.createQuery("from User")
        .stream()
        .count();

Optional<User> admin = session.createTypedQuery("from User where id = :id", User.class)
        .setParameter("id", 1l)
        .stream()
        .findFirst();

Optional<User> user = session.getOptional("User", 1l);

Todo

  • LocalDate and LocalTime support - will be natively supported through Hibernate 5
  • Optional<?> custom type handler/converter