Home » Tag Archives: JPA

Tag Archives: JPA

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 »

OpenLiberty: Error on Injection, works on TomEE and Wildfly

While I was working on this blog, I encountered this error: [INFO ] DSRA8203I: Database product name : MySQL [INFO ] DSRA8204I: Database product version : 8.0.11 [INFO ] DSRA8205I: JDBC driver name : MySQL Connector/J [INFO ] DSRA8206I: JDBC driver version : mysql-connector-java-8.0.11 (Revision: 6d4eaa273bc181b4cf1c8ad0821a2227f116fedf) [INFO ] CWWJP9990I: test/wsjpa:wsjar:file:/home/dwuysan/dev/appservers/wlp/usr/servers/test/apps/expanded/test.war/WEB-INF/lib/d9f2b261-b3c6-4001-8a61-0aaebe46aa99.jar!/_testPU login successful [INFO ] WELD-000900: 2.4.5 (Final) [INFO ] FFDC1015I: ...

Read More »

Exact Matching of a String Containing a Wild Card in QueryDSL

On one of our recent projects, our client asked for a single search field that would be able to search on first name, last name and email address, with the only wildcard being an asterix ‘*’ for partial matches. Sounds simple, but it threw us for a little loop. In our project, we used QueryDSL in combination with JPA and ...

Read More »

Spring Data JPA Tutorial

java-interview-questions-answers

Managing data between java classes or objects and the relational database is a very cumbersome and tricky task. The DAO layer usually contains a lot of boilerplate code that should be simplified in order to reduce the number of lines of code and make the code reusable. In this tutorial, we will discuss spring data’s implementation of JPA. 1. Introduction ...

Read More »

Automatic save of managed JPA entities outside of transaction

java-interview-questions-answers

Repositories and transactions in Spring go hand in hand. All database access in Spring should be run inside a transaction, and you typically have @Transactional somewhere to enforce this. However, this is not always necessary. For example, when using Spring Data your repositories use SimpleJPARepository for CRUD functionality. The SimpleJPARepository uses @Transactional so when you perform CRUD operations, transactions are ...

Read More »