From the course: Java Persistence API (JPA): 1 The Basics
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Advanced mapping using annotations - Java Tutorial
From the course: Java Persistence API (JPA): 1 The Basics
Advanced mapping using annotations
- When working with JPA, default attribute mapping is provided out of the box to help you save time. But did you know that you can customize the default mapping rules to your liking. Let's learn how the default mapping strategy works for JPA, and how to add customizations. In order for a class to be considered a JPA entity at a minimum it needs the @Entity annotation, a public or protected no argument constructor, and the class must not be declared final, and no methods or persistent instance variables must be declared final. The @Entity annotation identifies that this job or class can be assisted to the database. Also, every entity must have a primary key. The @Id annotation identifies the unique identifier for the object. JPA is all about mapping Java objects to database tables. But how does the mapping work? There is an out-of-the-box default mapping which promotes configuration by exception, or convention over configuration. The default mapping strategy has the persistent provider…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.