Agenda:
1. Creating JPA project and generating entities.
2. Configuring persistence properties and JPA project
3. Testing the JPA project
4. Update database when entity changed.
5. Setting up load balance database connection.
6. Setting Cache Coordination in Eclipselink
1. Creating JPA project and generating entities.
2. Configuring persistence properties and JPA project
3. Testing the JPA project
4. Update database when entity changed.
5. Setting up load balance database connection.
6. Setting Cache Coordination in Eclipselink
The purpose of this post is to show detail steps on how to setting up JPA project and generate entities for the JPA Project
Required Software/Tool
1. Eclipse
2. JDBC jar file for the target database
Steps:
1. Create JPA Project
p/s: if JPA Project previously created by other team member, step 1 can be skipped.
a. File > New > Other > JPA > JPA Project, Next
b. Fill in project details > Finish
c. project created.
2. Setting up JPA Connection
a. open the JPA perspective, if it is not open yet. => Windows > Perspective > JPA
b. R-click on Database Connections > New
c. Choose you database, Enter Database Name > Next
d. Enter connection details
e. configure jdbc driver by clicking on the red highlighted box
- choose appropriate driver version
f. locate jdbc jar file
- click on the jar name > Edit JAR/Zip
- browse the jar file
- OK
g. Test Connection, if following screen appears, the connection is properly configured. > Finish.
h. connected datasource
3. Generate entities
a. R-click on JPA Project > JPA Tools > Generate Entities From Tables
b. choose Connection
c. choose Schema
d. choose Tables
e. Next > Next
f. Enter Pakage, Superclass, Interfaces (Optional)
g. Configure Key Generator for selected tables
- Click on 1st table, select Key Generator, sequence (if required)
- repeat the above step for all tables that are having Key Generator
h. Finish
i. Verify the generated entities in the defined package.
At this stage, Eclipse will still shows us a lots of compilation errors.
Follow NEXT STEP to configure the JPA project.
Done!!
No comments:
Post a Comment