Related differences

JDBC vs JPAJPA vs Hibernate

Ques 16. What is the difference between JPA and JDO?

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.

Is it helpful? Add Comment View Comments
 

Ques 17. What is the attribute of the Entity class in JPA terminology?

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.

Is it helpful? Add Comment View Comments
 

Ques 18. What data types are allowed in the attributes of the Entity class (fields or properties)?

Valid attribute types for Entity classes are:

  1. primitive types and their Java wrappers,
  2. strings,
  3. any Java serializable types,
  4. enums;
  5. entity types;
  6. embeddable classes
  7. collection types

Is it helpful? Add Comment View Comments
 

Ques 19. What requirements does JPA set for Embeddable classes?

  1. Such classes must satisfy the same rules as the Entity classes, except that they do not have to contain a primary key and be marked with the Entity annotation.
  2. The Embeddable class must be marked with the Embeddable annotation or described in the XML configuration file JPA.

Is it helpful? Add Comment View Comments
 

Ques 20. What is a Mapped Superclass?

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.

Is it helpful? Add Comment View Comments
 

Most helpful rated by users: