JPA Interview Questions and Answers
Prepare for your Interview today!
JPA (Java Persistence API) and Java Data Objects (JDO) are two specifications for storing java objects in databases.
If JPA is concentrated only on relational databases, then JDO is a more general specification that describes the ORM for any possible bases and repositories.
In principle, JPA can be viewed as part of the JDO specification specialized in relational databases, even though the API of these two specifications does not completely match.
The “developers” of specifications also differ – if JPA is developed as JSR, then JDO was first developed as JSR, and now it is developed as an Apache JDO project.
JPA indicates that it can work both with properties of classes (property), designed in the style of JavaBeans, or with fields (field), that is, class variables (instance variables). Both types of elements of the Entity class are called attributes of the Entity class.
Valid attribute types for Entity classes are:
A mapped Superclass is a class from which Entity is inherited, it may contain JPA annotations, however, such a class is not Entity, it does not have to fulfill all the requirements set for Entity (for example, it may not contain a primary key).
Such a class cannot be used in EntityManager or Query operations. Such a class should be marked with the MappedSuperclass annotation or, respectively, described in the XML file.
Most helpful rated by users: