DevOps Articles

Curated articles, resources, tips and trends from the DevOps World.

How to get Type-Safe and Intuitive Hibernate/JPA Queries

4 years ago dzone.com

Summary: This is a summary of an article originally published by the source. Read the full original article here →

Join the DZone community and get the full member experience. In short, we can query a database like this: This prints the title of the 15 longest films in the database.

In the examples below, we are using JPAstreamer to query the "Sakila" example database that is available for download directly from Oracle or as a Docker instance.

Here is a complete example of how we can use JPAstreamer to create a query that prints out the length and title of the 15 longest films in the database: This will print: As can be seen, queries are simple, concise, completely type-safe and follow the Java Stream standard API.

The background to JPAStreamer is that we have developed the stream-based ORM-tool Speedment, and we have come across many developers that want to use Java streams but are constrained to use Hibernate in their applications.

Made with pure grit © 2024 Jetpack Labs Inc. All rights reserved. www.jetpacklabs.com