Javatpoint Logo
Javatpoint Logo

JPA Creating an Entity

A Java class can be easily transformed into an entity. For transformation the basic requirements are: -

  • No-argument Constructor
  • Annotation

Here, we will learn how to transform a regular Java class into an entity class with the help of an example: -

Simple Student class

Above class is a regular java class having three attributes id, name and fees. To transform this class into an entity add @Entity and @Id annotation in it.

  • @Entity - This is a marker annotation which indicates that this class is an entity. This annotation must be placed on the class name.
  • @Id - This annotation is placed on a specific field that holds the persistent identifying properties. This field is treated as a primary key in database.

Simple Entity Class

Next TopicJPA Entity Manager

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA