JPA EmbeddableId annotation

The EmbeddableId annotation is used to create a composite primary key. It can also be applied to a persistent field or property of an entity class or mapped superclass to denote a composite primary key that is an embeddable class. Example: @Embeddable public class Zipcode { protected String zip; protected String plusFour; }   @Embeddable … Read more

Categories JPA

JPA Embeddable annotation

It is used to define a class whose instances are stored as an intrinsic part of an owning entity and share the identity of the entity. Each of the persistent properties or fields of the embedded object is mapped to the database table for the entity. Example: @Embeddable public class Zipcode { protected String zip; … Read more

Categories JPA

JPA TableGenerator annotation

The TableGenerator defines a primary key generator that may be referenced by name when a generator element is specified for the GeneratedValue annotation. A table generator may be specified on the entity class or on the primary key field or property. The scope of the generator name is global to the persistence unit (across all … Read more

Categories JPA

JPA SequenceGenerator annotation

The SequenceGenerator annotation defines a primary key generator that may be referenced by name when a generator element is specified for the GeneratedValue annotation. A sequence generator may be specified on the entity class or on the primary key field or property. The scope of the generator name is global to the persistence unit (across … Read more

Categories JPA

JPA GeneratedValue annotation

The @GeneratedValue annotation provides the specification of generation strategies for the primary keys values. Example: @Id @GeneratedValue(strategy=GenerationType.TABLE , generator="student_generator")@Id @GeneratedValue(strategy=GenerationType.TABLE , generator="student_generator") Attributes: 1. Strategy: The strategy attribute is used to specify the primary key generation strategy that the persistence provider must use to generate the annotated entity primary key. It is an optional attribute. … Read more

Categories JPA

JPA id annotation

The @Id annotation is used to specify the primary key of an entity. The field or property to which the Id annotation is applied should be one of the following types: 1. Any Java primitive type 2. Any primitive wrapper type. 3. String 4. java.util.Date 5. java.sql.Date 6. java.math.BigDecimal 7. java.math.BigInteger It is contained in … Read more

Categories JPA

JPA Entity Annotation

The @Entity annotation is used to specify that the class is an entity. Attributes: Name: The Name attribute is used to specify the entity name. It is an optional attribute. Defaults to the unqualified name of the entity class. It is contained in the javax.persistence package. Note: If you are using Hibernate as the JPA … Read more

Categories JPA

JPA Persistence Unit

A persistence unit defines a set of all user defined persistable classes that are managed by EntityManager instances in an application. This set of entity classes represents the data contained within a single data store. . A Persistence each in turn containing a number of properties and attributes. Persistence units are defined in the persistence.xml … Read more

Categories JPA

JPA Architecture

Entity: A class which have to be stored in the database tables is known as an entity. They should follow some simple rules of Plain Old Java Object programming model (POJO). An entity must be annotated with javax.persistence.Entity. By default, the table name corresponds to the class name. We can provide user-defined table name by … Read more

Categories JPA