WebLogic Developer Webcast 1: JPA 2.0

15
1 Series Overview 1. Data Access with JPA 2. Distributed Caching with Coherence 3. Message Driven and Web Services with Spring 4. RESTful Web Services with JAX-RS and Javascript UI with JQuery 5. Troubleshooting and tuning ©2010 Oracle Corporation 1

description

 

Transcript of WebLogic Developer Webcast 1: JPA 2.0

Page 1: WebLogic Developer Webcast 1: JPA 2.0

1

Series Overview

1. Data Access with JPA

2. Distributed Caching with Coherence

3. Message Driven and Web Services with Spring

4. RESTful Web Services with JAX-RS and Javascript UI with JQuery

5. Troubleshooting and tuning

©2010 Oracle Corporation

1

Page 2: WebLogic Developer Webcast 1: JPA 2.0

2

Next Session: Distributed Caching with Coherence

Learn how to:• Integrate Coherence with JPA• Manage Coherence Servers and Clusters from

WebLogic Admin Console

©2010 Oracle Corporation

2

Page 3: WebLogic Developer Webcast 1: JPA 2.0

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions.

The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

3

Page 4: WebLogic Developer Webcast 1: JPA 2.0

WebLogic Java Developer Webcast1. Data Access with JPA

Shaun Smith Product Manager—Oracle TopLinkSohail Dadani Sr. Sales Consultant

Page 5: WebLogic Developer Webcast 1: JPA 2.0

5

Java Persistence API (JPA)—in a Nutshell

• Defines:– How Java objects are

stored in relational– A programmer API for

reading, writing, and querying persistent Java objects (“Entities”)

– A full featured query language in JP QL

– a container contract that supports plugging any JPA runtime in to any compliant container

Java Classes

Database Schema

Application

JDBC Driver

JPA Provider

PersistenceDescriptors

Java SE/EE

Page 6: WebLogic Developer Webcast 1: JPA 2.0

6

JPA—Background

• A standardization of industry practices for Java POJO Object Relational Persistence

• Developed as part of the EJB 3.0 specification but now spun off into its own specification (JSR 317)• Suitable for use in different modes– Standalone in Java SE environment– Hosted within a Java EE Container

• Merging of expertise from persistence vendors and communities including: TopLink, Hibernate, JDO, EJB vendors and individuals

Page 7: WebLogic Developer Webcast 1: JPA 2.0

7

Oracle TopLink 11gR1

• Oracle’s Enterprise Java Persistence Framework– Includes open source EclipseLink with Commercial Support– Certified on and part of the Oracle WebLogic application

server– Includes TopLink Grid: JPA integration with Coherence• Supports scaling JPA applications into very large clusters

– Development tool support in Eclipse OEPE, JDeveloper, and NetBeans

Page 8: WebLogic Developer Webcast 1: JPA 2.0

8

Object-Relational Mapping

• The activity of ‘Mapping’ is the process of connecting objects/attributes to tables/columns

ID

CUST

NAME C_RATING

Customer

id: intname: StringcreditRating: int

Page 9: WebLogic Developer Webcast 1: JPA 2.0

9

Mapping with Annotations

@Entity public class Customer {

@Idprivate String name;@OneToOne private Account account;

public String getName() { return name; }public void setName(String name) { this.name = name;}public Account getAccount() { return account; }public void setAccount(Account account) { this.account = account;}}

Page 10: WebLogic Developer Webcast 1: JPA 2.0

10

Mappings with XML

<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"

… <entity class=“Customer"> <attributes> <id name=“name“/> <one-to-one name=“account“/> </attributes> </entity>…</entity-mappings>

Page 11: WebLogic Developer Webcast 1: JPA 2.0

11

Typical Development Approaches

• Bottom Up– Start from a database schema and generate JPA entities– A good way to bootstrap a project if you’re building on an

existing database

• Top Down– Generate database schema from JPA entities– A good way to get started in a green field development—

focus on developing a good Java domain model

• Meet in the Middle– Map Java classes to an existing database schema– Maps optimized Java domain model to an optimized

database schema—typically follows Bottom Up and Top Down

Page 12: WebLogic Developer Webcast 1: JPA 2.0

12

Our Development Scenario

• Building a simple JAX-RS fronted Java application that interacts with a relational database• Starting from an XSD that describes the documents

the system must support• Technologies we’ll use: JPA, JAXB, and JAX-RS• Development Approach:– Use JAXB Schema compiler to generate JAXB annotated

POJOS– Follow JPA “Top Down” approach by defining JPA mappings

for generated classes and then generating a database schema from those mapped classes.

Page 13: WebLogic Developer Webcast 1: JPA 2.0

13

JPA in Java EE

Page 14: WebLogic Developer Webcast 1: JPA 2.0

14

JPA in EJB

Page 15: WebLogic Developer Webcast 1: JPA 2.0

15

OracleWebLogic YouTube Channelwww.YouTube.com/OracleWebLogic

©2010 Oracle Corporation

15