What is JPA?
The JPA (Java Persistence API) is a Java EE and Java SE specification that describes the management system for saving java objects to relational database tables in a convenient way. Java itself does not contain JPA implementation, but there are many implementations of this specification from different companies (open and not). This is not the only way to save java objects to databases (ORM systems), but one of the most popular in the Java world.
What is the difference between JPA and Hibernate?
Hibernate is one of the most popular open implementations of the latest version of the specification (JPA 2.1). Even more likely the most popular, almost standard de facto. That is, JPA only describes rules and APIs, and Hibernate implements these descriptions, although Hibernate (as well as many other JPA implementations) has additional features not described in JPA (and not portable to other JPA implementations).
Can I use JPA with NoSQL databases?
In general, the JPA specification only refers to the mapping of Java objects to relational database tables, but there are a number of implementations of this standard for NoSQL databases: Kundera, DataNucleus, ObjectDB, and a number of others. Naturally, in this case, not all relational database-specific features of the specification are transferred to the NoSQL database completely.
What is the difference between JPA and JDO?
JPA (Java Persistence API) and Java Data Objects (JDO) two specifications for saving java objects in databases. If JPA is concentrated only on relational databases, then JDO is a more general specification that describes ORM for any possible databases and repositories. In principle, you can view JPA as a specialised part of the JDO specification for relational databases, even though the API of these two specifications does not completely match. Also, the “developers” of specifications are different – if JPA is developed as JSR, then JDO was first developed as JSR, now it is developed as an Apache JDO project.
What is Entity?
The entity is a lightweight persistent domain object. The main program entity is an entity class, which can also use additional classes that can be used as helper classes or to preserve the state of the entity.
Can Entity be an abstract class?
Maybe, in doing so, it saves all Entity properties, except that it can not be directly initialized.
What JPA requirements for Entity classes you can list (at least six requirements)?
1) The Entity class must be marked with the Entity annotation or described in the XML configuration file of the JPA,
2) The Entity class must contain a public or protected constructor with no arguments (it can also have constructors with arguments),
3) The Entity class must be a top-level class (top-level class),
4) Entity class cannot be enum or interface,
5) Entity class cannot be a final class,
6) Entity class cannot contain final fields or methods if they participate in mapping (persistent final methods or persistent final instance variables),
7) If the Entity object of the class is passed by value as a detached object, for example through the remote interface, it must also implement the Serializable interface,
8) Entity fields must be directly accessible only to the methods of Entity itself class and should not be directly accessible to other classes that use this Entity. Such classes should only refer to methods (getter/setter methods or other methods of business logic in the Entity class),
9) The Entity class must contain the primary key, that is, the attribute or attribute group that uniquely identifies the record of this Entity class in the database.
What are the two types of elements that Entity classes have? Or in other words, list two kinds of access to the Entity classes.
JPA indicates that it can work as with properties of classes (property), designed in the style of JavaBeans, or with fields (field), that is, class variables (instance variables). Accordingly, the access type will be either property access or field access.
What is the Entity attribute of the class in the terminology of JPA?
JPA indicates that it can work as with properties of classes (property), designed in the style of JavaBeans, or with fields (field), that is, class variables (instance variables). Both types of Entity class elements are called Entity attributes of the class.
What types of data are allowed in the Entity attributes of the class (fields or properties)?
Valid types of attributes for Entity classes are:
- Primitive types and their Java wrappers,
- Any Java serializable types (implementing Serializable interface),
- entity types;
- embeddable classes
- and collections of types 1-6