0% found this document useful (0 votes)
58 views

Tutorial - Set Up A Web Dynamic Project As JPA

This tutorial describes how to convert an existing Dynamic Web project into a JPA project in Eclipse. It involves: 1. Right clicking the project and selecting "Configure -> JPA project" 2. Selecting Payara as the runtime and JPA implementation 3. Generating a persistence.xml file and configuring it to use an existing DataSource 4. Entities added to the project will be listed in the persistence.xml file

Uploaded by

Ryan Blake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Tutorial - Set Up A Web Dynamic Project As JPA

This tutorial describes how to convert an existing Dynamic Web project into a JPA project in Eclipse. It involves: 1. Right clicking the project and selecting "Configure -> JPA project" 2. Selecting Payara as the runtime and JPA implementation 3. Generating a persistence.xml file and configuring it to use an existing DataSource 4. Entities added to the project will be listed in the persistence.xml file

Uploaded by

Ryan Blake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

TUTORIAL: Set up a Web Dynamic project as JPA

When creating a JPA project we have two options:

a) Create it as “JPA Project” from start


b) Take an existing “Dynamic Web” project and add it a JPA facet

In this tutorial we are going to follow the steps required for the second option: we will
take an existing “Dynamic Web” project and we will convert it into a JPA project. We
will use a DataSource previously created to connect with the database.
otherwise, once created, right click on the project and click on properties>Project Facets
1. Right click on the laboratories project and select : Configure-> JPA project to
convert ...
2. In the dialog that appears make sure that Payara is selected as Runtime

3. Press Next in the following screen select in JPA implementation: Payara System
Library
Window>Perspective>Open Perspective>JPA
4. Press Finish and it will generate a new persistence.xml descriptor within a
META-INF directory. Open it with a double click.
it's in the JPA Content dir

5. In the window that appears change these values:


• Name: laboratoriosPU (or any other name you choose)

6. At the bottom of the editor changes the Connection tab and apply the following
values
Nombre del
DataSource

name in JDBC Resources


in Payara admin console
(port 4848)

7. Save changes

You should have a code that looks like the following (by clicking on the source tab):

<?xml version="1.0" encoding="UTF-8"?>


<persistence version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="JPAExample">
<jta-data-source>TIWDS</jta-data-source>
</persistence-unit>
</persistence>

Now you can start adding entities to your project. You will see that as you add them
they name will appear in the file persistence.xml.

<?xml version="1.0" encoding="UTF-8"?>


<persistence version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="JPAExample">
<jta-data-source>TIWDS</jta-data-source>
<class>entities.Usuario</class>
</persistence-unit>
</persistence>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy