Home » JPA Creating an Entity

JPA Creating an Entity

by Online Tutorials Library

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

You may also like