JPA is the Java Persistence API, a specification handling the mapping of Java objects and their relationships to a relational database. This is called an object-relational mapper (ORM). It is an alternative for (or supplement to) the more low-level JDBC. It is most useful when pursuing a Java-oriented approach and when complex object graphs need to be persisted.
JPA in itself is not an implementation. You will need a persistence provider for that (see examples). Current implementations of the latest JPA 2.1 standard are EclipseLink (also the reference implementation for JPA 2.1, which means "proof that the spec can be implemented"); Hibernate, and DataNucleus.
The mapping between Java objects and database tables is defined via persistence metadata. The JPA provider will use the persistence metadata information to perform the correct database operations. JPA typically defines the metadata via annotations in the Java class.
The entity architecture is composed of:
There always needs to be a default constructor, that is, the parameterless one. In the basic example, there was no constructor specified, so Java added one; but if you add a constructor with arguments, be sure to add the parameterless constructor, too.
Full example can be found here
The advantage of single table strategy is it does not require complex joins for retrieval and insertion of entities, but on the other hand it wastes database space as many columns need to be nullable and there isn’t any data for them.
Complete example and article can be found here
A foreign key can be one or more columns that reference a unique key, usually the primary key, in another table.
A foreign key and the primary parent key it references must have the same number and type of fields.
Foreign keys represents relationships from a column or columns in one table to a column or columns in another table.
Full example can be referred here