JPA Tip: How to map entity attributes of type java.time.Duration

Опубликовано: 01 Октябрь 2024
на канале: Thorben Janssen
1,660
42

Get more recipes like this one in my new book Hibernate Tips: More than 70 solutions to common Hibernate problems: https://goo.gl/XfywNk

In today’s video, I want to answer the following question: JPA 2.2 didn’t add support for java.time.Duration. How can I map an attribute of that type with JPA?
Unfortunately, JPA 2.2 only supports some of the classes of the Date and Time API and java.time.Duration isn’t one of them. If you are limited to plain JPA, you need to implement a custom mapping for attributes of type Duration. As you will see, that is not as complicated as it might seem.
But before we dive into any details, please don’t forget to subscribe to get new videos every week.

If you like this video, please give me your thumbs up and share it with your friends and co-workers.

Like my channel? Subscribe!
➜ http://bit.ly/2cUsid8

Join the free Member Library:
https://goo.gl/dtyIIC

Read the accompanying post: https://www.thoughts-on-java.org/jpa-...

Want to connect with me?
Blog: http://www.thoughts-on-java.org/
Twitter:   / thjanssen123  
Facebook:   / thoughtsonjava