Hibernate and PostgreSQL configuration using persistence.xml and EntityManager

In this tutorial I am going to show you how to use Hibernate with Entity Manager. It is based on my previous tutorial and it is an enhancement of this code. In previous tutorial I was using “hibernate-entitymanager” dependency, so there is no need to do any modifications in pom.xml now.

1. Create persistence.xml file in src/main/resources/META-INF directory. You can also remove hibernate.cfg.xml, but it is not mandatory.

Read more

Hibernate and PostgreSQL configuration with Maven

In this tutorial I am going to show you how to configure connection between Hibernate and PostgreSQL in Java application using Maven.


I am using:

JDK 1.7.0_72
Apache Maven 3.2.1
PostgreSQL 9.3.5
Hibernate 4.2.15.Final


1. Generate maven project from archetype


2. Add fallowing dependencies to you pom.xml file

Read more