Related differences

JDBC vs JPAJPA vs Hibernate

Ques 6. What is an Entity?

A class which should be persisted in a database it must be annotated with javax.persistence.EntitySuch a class is called Entity. 

An instances of the class will be a row in the person table. So, the columns in the person table will be mapped to the Person java object annotated as @Entity.
While insert, update or fetch record to or from the database we use entity as mapping with relational tables.

Is it helpful? Add Comment View Comments
 

Ques 7. What is the difference between persistence.xml and hibernate.cfg.xml?

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.

Is it helpful? Add Comment View Comments
 

Ques 8. What is the difference between JPA and 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.

Is it helpful? Add Comment View Comments
 

Ques 9. What are the two types of elements in Entity classes?

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.

Is it helpful? Add Comment View Comments
 

Ques 10. What types of connections (relationships) between Entities?

There are four types of connections

  1. One-To-One: one-to-one connection, that is, one Entity object can be associated with no more than one object of another Entity
  2. One-To-Many: one-to-many connection, one Entity object can be associated with a whole collection of Entity
  3. Many-To-One: A relationship where one entity (column or set of columns) is/are referenced with another entity (column or set of columns) that contains unique values. In relational databases, these relations are applicable by using foreign key/primary key between tables.
  4. Many-To-Many: A relationship is a connection between two types of entities. In the case of a many-to-many relationship, both sides can relate to multiple instances of the other side. Note that it's possible for entity types to be in a relationship with themselves.

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.

Is it helpful? Add Comment View Comments
 

Most helpful rated by users: