Introduction
In this article/tutorial we will see complete guide on JPA Entity class. JPA Entity class is a POJO class to map database table with java object nature which is called as ORM. Entity class is different than normal java class. Entity class is the object based representation of database table.Rules to create Entity class
We must use @Entity annotation to create Entity class
Entity class must have public or protected zero-arguments constructor, entity class may contains other constructors
Entity class can not be final class and entity class must not have final methods and fields
Entity class can extend another entity class and non entity classes too
Any non entity class can extends entity class
To use Entity class object as a parameter to any method, Entity class must be serialised
Entity class fields or properties of entity class
Now we will see what are type of fields can be created in Entity class.Java primitive types
java.lang.String
Other serializable types, including:
Wrappers of Java primitive types
java.math.BigInteger
java.math.BigDecimal
java.util.Date
java.util.Calendar
java.sql.Date
java.sql.Time
java.sql.TimeStamp
User-defined serializable types
byte[]
Byte[]
char[]
Character[]
Enumerated types
Other entities and/or collections of entities
Embeddable classes
Post a Comment
Post a Comment