Category: JPA 2

Spring Data JPA Query Methods

We have learned about creating a simple hello world example in previous article. In this article we will learn about retrieving data from entities without really writing queries.   Spring Data JPA Query Methods: Pre-requisites: MySQL database installed on your…

Spring Data JPA Interfaces

This article will simply introduce spring data jpa interfaces. Here onwards, we are going to see JPA specific spring data implementation. Spring Data JPA Interfaces: In previous article we saw generic interfaces which abstract the functionality to provide repositories and common…

JPA MapsId example

MapsId annotation in JPA is used in ManyToOne or OneToOne relationships when mapping using EmbeddedId is involved. Let us see a JPA MapsId example to demonstrate the same. JPA MapsId Example: Consider we have following. Employee entity with fields idEmployee…

JPA Caching Example

Previously, we have seen the cocnept of JPA Caching. Let us now see a JPA Caching Example which shows how to configure JPA Cache and cache enttities using @Cacheable annotation. We know that EntityManager is first level cache and EntityManagerFactory…

JPA OrderColumn Example

Consider we want to maintain the persistent order of list when being inserted into the database and want to retrive the list in the order it was inserted. This JPA OrderColumn Example demonstrates how it can be done. JPA OrderColumn…

JPA MapKeyColumn Annotation Example

We have learned about Entity Relationships and their mappings. Till now we have simply used lists and maps in entities. The requirement may arise to use maps in these relationships. For example, Consider employees having multiple phones assignned to them.…