0

I can see similar question in stackoverflow but example he quoted is quite different and answers were given in relation to same.

In our project i have JPA annotations

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

In Persistance.xml i have hibernate properties too:

<persistence-unit name="IntegratorMasterdataDS" transaction-type="JTA" >
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
<!--            <jta-data-source>java:/datasources/Ifs9ErgointDS1</jta-data-source>  -->
                <jta-data-source>java:/datasources/IfsDS</jta-data-source>
        <properties>
            <property name="hibernate.archive.autodetection" value="class" />
            <property name="hibernate.show_sql" value="false" />
         <property name="hibernate.hbm2ddl.auto" value="create" />
        </properties>
    </persistence-unit>

   @PersistenceContext(unitName = "IntegratorMasterdataDS")
   protected EntityManager em;
   em.persist
   em.save
   em.flush
   em.find
   em.merge

I deploy in Wildfly which uses Hibernate as JPA implementation.

When i am being asked are you using JPA or Hibernate what should i reply?

As per current understanding if we are using single Hibernate property in code or persistance.xml then we can say that we are using Hibernate as it makes project hibernate dependent. Is this understanding fine?

If not, then what more should i add in project to say that i am using hibernate?

fatherazrael
  • 5,511
  • 16
  • 71
  • 155

2 Answers2

1

The Java Persistence API (JPA) is a Java specification for accessing, persisting, and managing data between Java objects/classes and a relational database

Whereas, hibernate is a concrete implementation of the JPA.

As an analogy, consider JPA as an interface and hibernate as its one of the concrete implementation. So, you can say that you are using the hibernate implementation of the JPA.

Check out this link to see other implementations of the JPA.

Yogesh Badke
  • 4,249
  • 2
  • 15
  • 23
  • I understand that but in vary use case i mentioned about can i say that i am using Hibernate? or is there minimum usage or org.hibernate defined to say that yes i am using hibernate – fatherazrael Dec 17 '19 at 06:13
  • 1
    In your persistance.xml, checkout ``. Whatever value is there, is your provider. For example currently its `org.hibernate.ejb.HibernatePersistence`. Meaning your provider is Hibernate and hence you can say you use hibernate – Yogesh Badke Dec 17 '19 at 07:10
1

When i am being asked are you using JPA or Hibernate what should i reply?

I'm using JPA with Hibernate as the implementation.

As per current understanding if we are using single Hibernate property in code or persistance.xml then we can say that we are using Hibernate as it makes project hibernate dependent. Is this understanding fine?

I would say: no. You are using standard JPA Annotations. The properties provided in persistence.xml are optional. You dont need them for your application to work properly. For example you dont need show_sql. hbm2ddl.auto can be replaced with standard JPA properties: https://docs.oracle.com/javaee/7/tutorial/persistence-intro005.htm

Robert Niestroj
  • 15,299
  • 14
  • 76
  • 119