JPA Interview Questions and Answers
Prepare for your Interview today!
A class which should be persisted in a database it must be annotated with javax.persistence.Entity. Such a class is called Entity.
When using JPA need persistence.xml and while using Hibernate API need hibernate.cfg.xml. When using JPA or Hibernate not needed both xmls, need the xml configuration file according to JPA or Hibernate.
Hibernate is one of the most popular open-source implementations of the latest specification (JPA 3.0). Even more likely the most popular, almost standard de facto.
That is, JPA only describes rules and APIs, and Hibernate implements these descriptions, however Hibernate (like many other JPA implementations) has additional features not described in JPA (and is not portable to other JPA implementations).
For solid differences, check JPA vs Hibernate.
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). Accordingly, the type of access will be either property access or field access.
There are four types of connections
Bi-directional: A mapping is the most common way to model this relationship with JPA and Hibernate. It uses an attribute on the Order and the OrderItem entity. This allows you to navigate the association in both directions in your domain model and your JPQL queries.
Uni-directional: A mapping is an association between one persistence object and another one related persistence object. If one persistence object uses another and in back if other is not using the first persistence object then it becomes unidirectional.
Most helpful rated by users: