JPA Annotation

AnnotationDescription
@EntityDeclares the class as an entity or a table.
@TableDeclares table name.
@BasicSpecifies non-constraint fields explicitly.
@EmbeddedSpecifies the properties of class or an entity whose value is an instance of an embeddable class.
@IdSpecifies the property, use for identity (primary key of a table) of the class.
@GeneratedValueSpecifies how the identity attribute can be initialized such as automatic, manual, or value taken from a sequence table.
@TransientSpecifies the property that is not persistent, i.e., the value is never stored in the database.
@ColumnSpecifies the column attribute for the persistence property.
@SequenceGeneratorSpecifies the value for the property that is specified in the @GeneratedValue annotation. It creates a sequence.
@TableGeneratorSpecifies the value generator for the property specified in the @GeneratedValue annotation. It creates a table for value generation.
@AccessTypeThis type of annotation is used to set the access type. If you set @AccessType(FIELD), then access occurs Field wise. If you set @AccessType(PROPERTY), then access occurs Property wise.
@JoinColumnSpecifies an entity association or entity collection. This is used in many- to-one and one-to-many associations.
@UniqueConstraintSpecifies the fields and the unique constraints for the primary or the secondary table.
@ColumnResultReferences the name of a column in the SQL query using select clause.
@ManyToManyDefines a many-to-many relationship between the join Tables.
@ManyToOneDefines a many-to-one relationship between the join Tables.
@OneToManyDefines a one-to-many relationship between the join Tables.
@OneToOneDefines a one-to-one relationship between the join Tables.
@NamedQueriesspecifies list of named queries.
@NamedQuerySpecifies a Query using static name.

Leave a Comment