Quantcast
Channel: Vlad Mihalcea
Viewing all articles
Browse latest Browse all 176

How to map polymorphic JSON objects with JPA and Hibernate

$
0
0

Introduction In this article, I’m going to show you how you can map polymorphic JSON objects when using JPA and Hibernate. Since Hibernate doesn’t support JSON natively, I’m going to use the Hibernate Types library to achieve this goal. Polymorphic Types Let’s assume we have the following DiscountCoupon class hierarchy: The DiscountCoupon is the base class of the AmountDiscountCoupon and PercentageDiscountCoupon concrete classes, which define two specific ways of discounting the price of a given Book entity. The Book entity is mapped as follows: Note that we want to map the List... Read More

The post How to map polymorphic JSON objects with JPA and Hibernate appeared first on Vlad Mihalcea.


Viewing all articles
Browse latest Browse all 176

Trending Articles