Category: JPA 2

JPA Caching

Let us understand how jpa caching method is divided in different layers. JPA Caching: Although JPA Caching includes two levels, i.e. Persistence context and shared level, roughly an application can have different levels. Let us understand the diagram which I’ve…

creating custom constraints

We’ve seen how to use constraints in bean validation in previous post. But what if we want some constraints which validate our own requirement? Java provides a way of creating custom constraints for bean validation. Creating Custom Constraints: While creating…

JPA Bean Validation

This article demonstrates how ┬áconstraints can be used along with jpa bean validation and how constraints can be retrieved when doing jpa bean validation. JPA Bean Validation: JPA bean validation isn’t directly related to JPA itself. Package javax.validation.constraints provides a…

JPA constraints

Till now we have not validated any entities and its fields, when we wanted some value to be not-null, then not null constraint was applied on database side, i.e. checking of a value being null or not was from database…

JPA EntityListeners

In previous article, we learned how jpa lifecycle call methods are used to listen to events about entities, but these methods need to be implemented in entity class itself. What if we don’t want to include callback methods in entity…

JPA Lifecycle callback methods

As of now we have learned about entities, relationships, inheritance and how entity manager performs operations on them. Till now, entities played a passive part. What if we want entities to perform something when some operations are performed on them?…

JPA table per concrete class example

Continuing with our jpa inheritance strategies, this article provides jpa table per concrete class example and explains it using Vehicle model from previous article about joined inheritance. JPA Table Per Concrete Class Example: Object model used here is as below.…

JPA Joined Inheritance Example

While studying inheritance in JPA entities, we have seen about JPA Single Table Inheritance in previous post. This will deal with another way of accomplishing it using jpa joined table inheritance example. JPA Joined Inheritance Example: Taking same example from…

JPA @EmbeddedId example

Hello, in previous article we have seen how compound primary keys can be generated using @IdClass annotation. This article gives JPA @EmbeddedId example i.e. another way of creating compound primary keys.   JPA @EmbeddedId example: Consider Employee entity such that.…