Skip to content

rubenharo22/jpastreamer-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

JPAstreamer example

Introduction

In this simple example we are going to see how to use java streams with JPA thanks to JPAstreamer.

What is JPAstreamer

JPAstreamer is a library for expressing JPA/Hibernate/Spring queries using standard Java streams.

How does JPAstreamer work with Spring Boot?

To use JPAstreamer together with Spring Boot we need to add maven dependencies and inject as dependency JPAStreamer in every class that we want to use it.

To work with JPAstreamer in our classes we are going to use it as Java Stream. For example if we want to find all records of car entity we are going to do:

jpaStreamer.stream(Car.class)
              .collect(Collectors.toList());

We also have to keep in mind that we need spring-boot-starter-data-jpa.

How does it run?

This is a spring boot application so to run it you can run with maven:

mvn spring-boot:run

from your IDE running the class

JpastreamerExampleApplication

or running your *.jar

java -jar *.jar

How does it check?

We have some endpoints with GET to verify and check this example:

-Brand
http://localhost:8090/brand/
http://localhost:8090/brand/{id}
http://localhost:8090/brand?name={Name}
-Car
http://localhost:8090/car/{id}
http://localhost:8090/car
Examples:
http://localhost:8090/brand/2
http://localhost:8090/brand?name=Mercedes
http://localhost:8090/car/1

About

JPAStreamer example with H2 data base and spring boot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages