Home » JPA

Tag Archives: JPA

How to get Type-Safe and Intuitive Hibernate/JPA Queries by Leveraging Java Streams

A large proportion of Java database applications are using Hibernate/JPA to bridge the gap between Java and SQL. Until recently, we were forced to mix Java and JPQL or to use complex imperative criteria builders to create database queries. Both of these methods are inherently neither type-safe nor very intuitive. The newly launched open-source library JPAstreamer addresses these issues by allowing you ...

Read More »

Spring boot data JPA – Query for nested object

spring-interview-questions-answers

Nowadays spring boot and spring data are widely used frameworks. If you are building web application in java, spring boot is the first choice. If you have Database then spring data JPA is best choice. In spring boot spring data is the default implementation for database interaction. Spring boot using spring data JPA even creates nested object query from method ...

Read More »

Spring Boot Data JPA – beginner guide

spring-interview-questions-answers

Databases form an integral part of computer applications. With it comes considerable amount of database operations and the corresponding code. For huge applications which have large number of tables/entities, these operations or the code is repeated and duplicated to a large extent. Eventually a programmer would like to reduce this duplicate code. Spring framework took up the challenge and provided ...

Read More »

JPA @Embeddable and @Embedded

java-interview-questions-answers

Introduction: As an object-oriented developer, we want to avoid having larger classes with tons of unrelatable fields. And so, we might often feel the need to represent a JPA Entity using multiple objects. In this quick tutorial, we’ll learn how to achieve it using @Embedded and @Embeddable annotations in JPA or Hibernate. Context Buildup: Let’s say we have a person table with ...

Read More »

Pagination and Sorting with Spring Data JPA

java-interview-questions-answers

Learn Pagination and Sorting with Spring Data JPA with code examples. Understand how to get Paginated and Sorted results using Springs PagingAndSortingRepository interface. 1 Overview While dealing with large amount of data the lazy processing is often essential. Even if a service returns a huge amount of data the consumer is less likely using it. Consider a shopping website, where ...

Read More »

How to map PostgreSQL Enums to JPA entity properties using Hibernate

Introduction The open-source hibernate-types project allows you to map JSON, ARRAY, YearMonth, Month or database-specific columns (e.g. INET addresses). In this article, we are going to see how you can map a PostgreSQL Enum type to a Java array when using JPA and Hibernate. Maven dependency First of all, you need to set up the following Maven dependency in your ...

Read More »