JPA: persistence with EclipseLink
Today we will see how to make the persistence in a Eclipse project with EclipseLink JPA implementation.
We will base in the last post Eclipse project. In the project properties (right buton) we will add the power to manage JPA entities, adding the facet:
We will ue EclipseLink 1.1.2, it is the JPA implementation by defect in WebLogic 11g.
Generating entities from tables
Over the project, in the contextual menu (right button), JPA > Generate Entities from Tables… We choose the conection SCHOOL, created in other posts, and tables REGISTRY and SCHOOLCERTIFICATES. Generating the entities in the package lebrijo.school.model:
To maintain the JPA coherence we must add an Identifier on every classes, Registry has one, but we must add one to SchoolCertificates:

You may see the file src/META-INF/persistence.xml, how it configures the connection and map the entities.
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="school" transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <class>lebrijo.school.model.Registry</class> <class>lebrijo.school.model.Schoolcertificate</class> <properties> <property name="eclipselink.target-server" value="WebLogic_10"/> <property name="eclipselink.jdbc.driver" value="oracle.jdbc.OracleDriver"/> <property name="eclipselink.jdbc.url" value="jdbc:oracle:thin:@192.168.0.7:1521:xe"/> <property name="eclipselink.jdbc.user" value="school"/> <property name="eclipselink.jdbc.password" value="school"/> <property name="eclipselink.logging.level" value="FINEST"/> </properties> </persistence-unit> </persistence>
here I leaveth eclipse zip project after these steps.
This entry was posted on Tuesday, July 13th, 2010 - 7:00 and is filed under Eclipse, Java, Data Bases. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


Have your say
Fields in bold are required. Email addresses are never published or distributed.
Some HTML code is allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>URIs must be fully qualified (eg: http://www.domainname.com) and all tags must be properly closed.
Line breaks and paragraphs are automatically converted.
Please keep comments relevant. Off-topic, offensive or inappropriate comments may be edited or removed.