Your SlideShare is downloading. ×
2008.07.17 발표
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

2008.07.17 발표


Published on

Published in: Education, Technology

1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Oracle TopLink & JPA
    • Sunjoo Park
    • [email_address]
    • 2008.07.17
  • 2. 오늘 이야기할 사항
    • Oracle TopLink 소개
    • JPA in JEUS와 TopLink
  • 3. ￵ TopLink 가 하는 일
    • Java objects 를 Relational data 혹은 XML element 등과 Mapping 해주는 기능
  • 4. 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
  • 5. TopLink 구성요소 Standalone J2SE application Environment TopLink Workbench (GUI Tool)
  • 6. 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
  • 7.  
  • 8. 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
  • 9. TopLink 의 기능 (1) <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <toplink-sessions version=&quot;10g Release 3 (; xmlns:xsd=&quot;; xmlns:xsi=&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);
  • 10. TopLink 의 기능 (2)
    • Object-Relational Mapping
      • Convertions between
        • Java objects
        • Relational database
      • Object, Relation, Constraints, Inheritances
      • To access a database using JDBC
      • TopLink Essentials - JPA
  • 11. 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></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:@</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(); }
  • 12. TopLink 의 기능 (3)
    • Conversions between
      • Java objects
      • Nonrelational data source(EIS records)
    • Using J2EE Connector Architecture
    • JCA adapter must support the JCA CCI interface
  • 13. 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
  • 14. 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
  • 15. 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;;> <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); }
  • 16. XML Mapping Relational Mapping EIS Mapping Oracle TopLink TopLink Essentials glassfish jeus-toplink-essentials.jar JEUS 6
  • 17.