JEE-persistence API (JPA)

JEE/ Java enterprise edition

JPA Java persistence

@CollectionTable is used to mapping of collections of basic or embeddable types.@Entity is allows collections of simple objects to be easily defined.

The entity’s persistent state is defined by four field, the identity id defined by the field id and is annotated with @id. A composite primary key may also be defined where the primary key corresponds to ome or more fields of the entity class. 

the implements  Serializable interface, and that allows it to be passed by value through a remote interface.

The relationships between different entities are defined using @OneToOne, @OneToMany, @ManyToOne and @ManyToMany annotation on the corresponding field of the referencing entity.

Validating the Entities.

validation has some predefined constraints like @Min, @Max, @Pattern and @Size.

public class Student implements serializable {

private int id;

private String name;

@Size(min=3, max=10)
private String grade;

protected String email;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s