• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
2008.07.17 발표
 

2008.07.17 발표

on

  • 820 views

 

Statistics

Views

Total Views
820
Views on SlideShare
819
Embed Views
1

Actions

Likes
1
Downloads
8
Comments
0

1 Embed 1

http://www.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    2008.07.17 발표 2008.07.17 발표 Presentation Transcript

    • Oracle TopLink & JPA
      • Sunjoo Park
      • [email_address]
      • 2008.07.17
    • 오늘 이야기할 사항
      • Oracle TopLink 소개
      • JPA in JEUS와 TopLink
    • ￵ TopLink 가 하는 일
      • Java objects 를 Relational data 혹은 XML element 등과 Mapping 해주는 기능
    • TopLink Key Features
      • Nonintrusive, flexible, metadata-based architecture
      • Comprehensive visual TopLink Workbench
      • Advanced mapping support and flexibility
      • Object caching support
      • Query flexibility
      • Just-in-time reading
      • Caching
      • Object-level transaction support and integration
      • Locking
      • Multiple performance tuning options
      • Architectural flexibility
    • TopLink 구성요소 Standalone J2SE application Environment TopLink Workbench (GUI Tool)
    • TopLink Application Packaging
      • File List
        • Java classes that represent the objects mapped
        • sessions.xml
          • The information required to access a data source
        • project.xml
          • Object’s mapping information
      You can use those through TopLink API! sessions.xml project.xml
    •  
    • TopLink 의 기능 (1)
      • Object-XML Mapping
        • Conversions between
          • Java objects
          • XML Documents
        • Using JAXB
        • TopLink JAXB compiler
          • To generate TopLink XML projects
          • To generate JAXB-compliant object model classes
      Client JAXB XML TopLink Layer
    • TopLink 의 기능 (1) <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <toplink-sessions version=&quot;10g Release 3 (10.1.3.3.0)&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;> <session xsi:type=&quot;database-session&quot;> <name>examples.ox.model</name> <event-listener-classes/> <primary-project xsi:type=&quot;xml&quot;>/home/all4you/tmp/xmlmapping/classes/CustomerProject.xml</primary-project> <login xsi:type=&quot;xml-login&quot;/> </session> </toplink-sessions>~ <opm:class-mapping-descriptor xsi:type=&quot;toplink:xml-class-mapping-descriptor&quot;> <opm:class>examples.ox.model.Address</opm:class> <opm:alias>Address</opm:alias> <opm:events xsi:type=&quot;toplink:event-policy&quot;/> <opm:querying xsi:type=&quot;toplink:query-policy&quot;/> <opm:attribute-mappings> ............................................ <opm:attribute-mapping xsi:type=&quot;toplink:xml-direct-mapping&quot;> <opm:attribute-name>province</opm:attribute-name> <opm:field name=&quot;state/text()&quot; xsi:type=&quot;toplink:node&quot;/> <opm:converter xsi:type=&quot;toplink:object-type-converter&quot;> <toplink:type-mappings> <toplink:type-mapping> <toplink:object-value xsi:type=&quot;xsd:string&quot;>Alaska</toplink:object-value> <toplink:data-value xsi:type=&quot;xsd:string&quot;>AK</toplink:data-value> </toplink:type-mapping> <toplink:type-mapping> <toplink:object-value xsi:type=&quot;xsd:string&quot;>Arkansas</toplink:object-value> <toplink:data-value xsi:type=&quot;xsd:string&quot;>AR</toplink:data-value> </toplink:type-mapping> </toplink:type-mappings> </opm:converter> </opm:attribute-mapping> </opm:attribute-mappings> Project myProject = session.getProject(); XMLContext context = new XMLContext(myProject); XMLMarshaller marshaller = context.createMarshaller(); marshaller.marshal(myObject, outputStream); marshaller.setFormattedOutput(true); XMLUnmarshaller unmarshaller = context.createUnmarshaller(); Employee emp = (Employee)unmarshaller.unmarshal(new File(&quot;employee.xml&quot;)); XMLValidator validator = context.createValidator(); boolean isValid = validator.validate(emp);
    • TopLink 의 기능 (2)
      • Object-Relational Mapping
        • Convertions between
          • Java objects
          • Relational database
        • Object, Relation, Constraints, Inheritances
        • To access a database using JDBC
        • TopLink Essentials - JPA
    • TopLink 의 기능 (2) <session xsi:type=&quot;database-session&quot;> <name>advancedtutorial</name> <event-listener-classes/> <primary-project xsi:type=&quot;xml&quot;>/home/all4you/tmp/adtutorial/src/META-INF/project.xml</primary-project> <login xsi:type=&quot;database-login&quot;> <platform-class>oracle.toplink.platform.database.oracle.Oracle10Platform</platform-class> <user-name>scott</user-name> <password>3E20F8982C53F4ABA825E30206EC8ADE</password> <sequencing> <default-sequence xsi:type=&quot;table-sequence&quot;> <name>Default</name> </default-sequence> </sequencing> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <connection-url>jdbc:oracle:thin:@192.168.1.43:1532:ora10g</connection-url> </login> </session> </toplink-sessions> <opm:class-mapping-descriptors> <opm:class-mapping-descriptor xsi:type=&quot;toplink:relational-class-mapping-descriptor&quot;> <opm:class>example.model.PhoneNumber</opm:class> <opm:alias>PhoneNumber</opm:alias> <opm:primary-key> <opm:field table=&quot;PHONE&quot; name=&quot;EMP_ID&quot; xsi:type=&quot;opm:column&quot;/> <opm:field table=&quot;PHONE&quot; name=&quot;TYPE&quot; xsi:type=&quot;opm:column&quot;/> </opm:primary-key> UnitOfWork uow = session.acquireUnitOfWork(); try { Employee employee = createEmployee(first, last, salary); Address address = createAddress(city, street); employee.setAddress(address); uow.registerNewObject(employee); uow.commit(); } finally { uow.release(); }
    • TopLink 의 기능 (3)
      • Conversions between
        • Java objects
        • Nonrelational data source(EIS records)
      • Using J2EE Connector Architecture
      • JCA adapter must support the JCA CCI interface
    • TopLink Essentials - JPA
      • What is 'TopLink Essentials'?
        • The open source reference implementation of the Java Persistence API (JPA) focused on standardized object-relational persistence and valuable extensions.
      EJB 3.0 TopLink Essentials glassfish JEUS
    • How to Use JPA
      • Configuration
        • Annotations
          • Table mapping, Transactions attributes, etc.
        • persistence.xml
          • Persistence units, Data Sources
            • In JavaEE ; using <jta-data-source>
            • In J2SE ; using a direct connection to a data source through TopLink Essentials
          • Locations
            • META-INF/persistence.xml in your classpath
    • How to Use JPA @Entity @NamedQuery(name=&quot;findAllProducts&quot;, query=&quot;SELECT p FROM Product p&quot;) public class Product implements Serializable { @Id private String productId; private double price; private String description; public Product() { } public Product(String productId, double price, String description){ this.productId = productId; this.price = price; this.description = description; } public String getProductId() { return productId; } public void setProductId(String id) { this.productId = id; } <persistence version=&quot;1.0&quot; xmlns=&quot;http://java.sun.com/xml/ns/persistence&quot;> <persistence-unit name=&quot;hellojpa&quot; transaction-type=&quot;JTA&quot;> <jta-data-source>datasource1</jta-data-source> <!--<jta-data-source>jdbc/sample</jta-data-source>--> <properties/> </persistence-unit> </persistence> @PersistenceContext private EntityManager em; ..... public Product createProduct(String productId, double price, String desc){ Product product = new Product(productId, price, desc); em.persist(product); return product; } public Product getProduct(String productId){ return (Product) em.find(Product.class, productId); }
    • XML Mapping Relational Mapping EIS Mapping Oracle TopLink TopLink Essentials glassfish jeus-toplink-essentials.jar JEUS 6
    •