How to create JPA project with EclipseLink

How to create a JPA project in Eclipse with EclipseLink library, which is JPA 2.0 implementation. Presented on MySQL database.

First you must download Eclipselink libraries. I already done that and unzipped them. Next create your own User library in Eclipse and put inside ecipselink.jar and this javax.persitence_2 jar in directory jpa. 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, EclipseLink version you downloaded, add library with EclipseLink 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.

I will also add JDBC library to classpath.

And finally now you are ready to work with JPA.