logo

How to create a Hibernate project in Eclipse

How to create a Hibernate project in Eclipse using Hibernate Tools (part of JBoss Tools) Presented on MySQL database.

First you must download Hibernate libraries. I already done that and unzipped them. Next create your own User library in Eclipse and put inside jars in folders "jpa" and "required". Also create library with your JDBC driver. It is unnecessary in this step, but we'll need it later. You must also have active database connection.

Next create a new JPA project, choose your JRE, choose Hibernate, add library with Hibernate and your JDBC library and select your database connection. This created file persistence.xml in META-INF directory.

Notice that you won't see connection properties inside this file. By default JPA depends on JTA. We don't have that right now, so choose Connection tab, change Transaction type to "Resource Local" and set connection properties using alredy defined connection to database in Eclipse.

Now you are ready to work with JPA using Hibernate.


comments powered by Disqus

rss

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:
github

Search