JPA project using Hibernate and Maven

How to create a JPA project with Hibernate and Maven in Eclipse. Presented on MySQL database.

If you want to use Hibernate with Maven, do the following:

Create a new Maven project and skip archetype selection. Add following dependencies: hibernate-core, hibernate-entitymanager and your JDBC driver.

Select project properties, Project Facets, choose JPA and edit JPA configuration: Select Hibernate, disable library configuration and select your database connection in Eclipse. This will create META-INF/persistence.xml file. Goto Connection tab, choose transaction type "Resource Local" and populate configuration from your Eclipse connection.

Now you have your project fully configured for work with JPA.

comments powered by Disqus


Free online Java web application examples

Want to develop whole web applications which use database, security and more? See my github account, where are lot's of example projects: