0
Oracle TopLink & JPA <ul><li>Sunjoo Park </li></ul><ul><li>[email_address] </li></ul><ul><li>2008.07.17 </li></ul>
오늘 이야기할 사항 <ul><li>Oracle TopLink 소개 </li></ul><ul><li>JPA in JEUS와 TopLink </li></ul>
￵ TopLink 가 하는 일 <ul><li>Java objects 를 Relational data 혹은 XML  element 등과 Mapping 해주는 기능 </li></ul>
TopLink Key Features <ul><li>Nonintrusive, flexible, metadata-based architecture  </li></ul><ul><li>Comprehensive visual T...
TopLink 구성요소 Standalone J2SE  application Environment TopLink Workbench (GUI Tool)
TopLink Application Packaging <ul><li>File List </li></ul><ul><ul><li>Java classes that represent the objects mapped </li>...
 
TopLink 의 기능 (1) <ul><li>Object-XML Mapping </li></ul><ul><ul><li>Conversions between </li></ul></ul><ul><ul><ul><li>Java ...
TopLink 의 기능 (1) <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <toplink-sessions version=&quot;10g Release 3 ...
TopLink 의 기능 (2) <ul><li>Object-Relational Mapping </li></ul><ul><ul><li>Convertions between </li></ul></ul><ul><ul><ul><l...
TopLink 의 기능 (2) <session xsi:type=&quot;database-session&quot;> <name>advancedtutorial</name> <event-listener-classes/> <...
TopLink 의 기능 (3) <ul><li>Conversions between </li></ul><ul><ul><li>Java objects </li></ul></ul><ul><ul><li>Nonrelational d...
TopLink Essentials - JPA <ul><li>What is 'TopLink Essentials'? </li></ul><ul><ul><li>The open source reference implementat...
How to Use JPA <ul><li>Configuration </li></ul><ul><ul><li>Annotations   </li></ul></ul><ul><ul><ul><li>Table mapping, Tra...
How to Use JPA @Entity @NamedQuery(name=&quot;findAllProducts&quot;, query=&quot;SELECT p FROM Product p&quot;) public cla...
XML Mapping Relational Mapping EIS Mapping Oracle TopLink TopLink Essentials glassfish jeus-toplink-essentials.jar JEUS 6
 
Upcoming SlideShare
Loading in...5
×

2008.07.17 발표

579

Published on

Published in: Education, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
579
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "2008.07.17 발표"

  1. 1. Oracle TopLink & JPA <ul><li>Sunjoo Park </li></ul><ul><li>[email_address] </li></ul><ul><li>2008.07.17 </li></ul>
  2. 2. 오늘 이야기할 사항 <ul><li>Oracle TopLink 소개 </li></ul><ul><li>JPA in JEUS와 TopLink </li></ul>
  3. 3. ￵ TopLink 가 하는 일 <ul><li>Java objects 를 Relational data 혹은 XML element 등과 Mapping 해주는 기능 </li></ul>
  4. 4. TopLink Key Features <ul><li>Nonintrusive, flexible, metadata-based architecture </li></ul><ul><li>Comprehensive visual TopLink Workbench </li></ul><ul><li>Advanced mapping support and flexibility </li></ul><ul><li>Object caching support </li></ul><ul><li>Query flexibility </li></ul><ul><li>Just-in-time reading </li></ul><ul><li>Caching </li></ul><ul><li>Object-level transaction support and integration </li></ul><ul><li>Locking </li></ul><ul><li>Multiple performance tuning options </li></ul><ul><li>Architectural flexibility </li></ul>
  5. 5. TopLink 구성요소 Standalone J2SE application Environment TopLink Workbench (GUI Tool)
  6. 6. TopLink Application Packaging <ul><li>File List </li></ul><ul><ul><li>Java classes that represent the objects mapped </li></ul></ul><ul><ul><li>sessions.xml </li></ul></ul><ul><ul><ul><li>The information required to access a data source </li></ul></ul></ul><ul><ul><li>project.xml </li></ul></ul><ul><ul><ul><li>Object’s mapping information </li></ul></ul></ul>You can use those through TopLink API! sessions.xml project.xml
  7. 8. TopLink 의 기능 (1) <ul><li>Object-XML Mapping </li></ul><ul><ul><li>Conversions between </li></ul></ul><ul><ul><ul><li>Java objects </li></ul></ul></ul><ul><ul><ul><li>XML Documents </li></ul></ul></ul><ul><ul><li>Using JAXB </li></ul></ul><ul><ul><li>TopLink JAXB compiler </li></ul></ul><ul><ul><ul><li>To generate TopLink XML projects </li></ul></ul></ul><ul><ul><ul><li>To generate JAXB-compliant object model classes </li></ul></ul></ul>Client JAXB XML TopLink Layer
  8. 9. 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);
  9. 10. TopLink 의 기능 (2) <ul><li>Object-Relational Mapping </li></ul><ul><ul><li>Convertions between </li></ul></ul><ul><ul><ul><li>Java objects </li></ul></ul></ul><ul><ul><ul><li>Relational database </li></ul></ul></ul><ul><ul><li>Object, Relation, Constraints, Inheritances </li></ul></ul><ul><ul><li>To access a database using JDBC </li></ul></ul><ul><ul><li>TopLink Essentials - JPA </li></ul></ul>
  10. 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>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(); }
  11. 12. TopLink 의 기능 (3) <ul><li>Conversions between </li></ul><ul><ul><li>Java objects </li></ul></ul><ul><ul><li>Nonrelational data source(EIS records) </li></ul></ul><ul><li>Using J2EE Connector Architecture </li></ul><ul><li>JCA adapter must support the JCA CCI interface </li></ul>
  12. 13. TopLink Essentials - JPA <ul><li>What is 'TopLink Essentials'? </li></ul><ul><ul><li>The open source reference implementation of the Java Persistence API (JPA) focused on standardized object-relational persistence and valuable extensions. </li></ul></ul>EJB 3.0 TopLink Essentials glassfish JEUS
  13. 14. How to Use JPA <ul><li>Configuration </li></ul><ul><ul><li>Annotations </li></ul></ul><ul><ul><ul><li>Table mapping, Transactions attributes, etc. </li></ul></ul></ul><ul><ul><li>persistence.xml </li></ul></ul><ul><ul><ul><li>Persistence units, Data Sources </li></ul></ul></ul><ul><ul><ul><ul><li>In JavaEE ; using <jta-data-source> </li></ul></ul></ul></ul><ul><ul><ul><ul><li>In J2SE ; using a direct connection to a data source through TopLink Essentials </li></ul></ul></ul></ul><ul><ul><ul><li>Locations </li></ul></ul></ul><ul><ul><ul><ul><li>META-INF/persistence.xml in your classpath </li></ul></ul></ul></ul>
  14. 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;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); }
  15. 16. XML Mapping Relational Mapping EIS Mapping Oracle TopLink TopLink Essentials glassfish jeus-toplink-essentials.jar JEUS 6
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×