Orcale Presentation
-
Upload
sanjeev-kulkarni -
Category
Technology
-
view
2.034 -
download
1
Transcript of Orcale Presentation
![Page 1: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/1.jpg)
![Page 2: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/2.jpg)
EclipseLink JPA in GlassFish™ Doug ClarkeDirector of Product ManagementOracle
![Page 3: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/3.jpg)
Eclipse Persistence Services “EclipseLink”
Eclipse Persistence Services Project (EclipseLink)
DBWSDBWS
SDOSDO
EISEIS
MOXyMOXy
JPAJPA
XML Data Legacy SystemsDatabases
Java SEJava SE Java EEJava EE OSGiOSGi SpringSpring ADFADF
![Page 4: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/4.jpg)
History of EclipseLink
1996 2008
TopLinkEssentials
![Page 5: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/5.jpg)
Significance of EclipseLink
• First comprehensive open source persistence solution• Object-Relational and much more
• Based upon product with 12 years of commercial usage
• Shared infrastructure• Easily share the same domain model with multiple
persistence technologies• Leverage metadata for multiple services
• Important part of the GlassFish and Eclipse Ecosystems
![Page 6: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/6.jpg)
EclipseLink JPA
• JPA 1.0 compliant implementation • Java EE, Java SE, Web, Spring, and OSGi• Any JDBC/SQL compliant database
• Advanced database extensions: stored procedures, native SQL, …• Key infrastructure:
• Caching, Locking, Query Framework, Mapping, …• JDBC connection pooling• Diagnostics: Logging, Profiling• DDL Generation • Customization callbacks
• Highly Extensible• … plus many valuable advanced features
![Page 7: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/7.jpg)
Caching
• Hold objects in-memory to avoid unnecessary database trips and object construction
• Cache manages “identity” to support bidirectional and cyclical relationships
• Flexible caching options ensure that you get maximum performance
• Numerous locking, refreshing, and synchronization options are available to minimize cache staleness
• Queries can be run in-memory only against the cache• Cache Coordination supports clustering
![Page 8: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/8.jpg)
Cache Configuration
• Cache Shared (L2)/Isolated (L1 only)• Entity cache—not data cache
• <property name=“eclipselink.cache.shared.default“value="true"/>
• Cache Type & Size• Soft/Hard Weak• Weak• Full• None
• <propertyname=“eclipselink.cache.type.default“value="Full"/>
@Cache(type = CacheType.HARD_WEAK, size = 500, isolated = true, coordinationType = INVALIDATE_CHANGED_OBJECTS)
![Page 9: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/9.jpg)
EclipseLink JPA Caching
EntityManager EntityManagerFactory
L2 Cache
(Shared )
L1 Cache
Cache Coordination
![Page 10: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/10.jpg)
Minimize stale cache
• Configure the cache relative to application data’s usage• Is the data shared between users/processes?• Is the data volatile?
• Only through JPA application?• Through direct DB modification?
• Ensure you protect any data that can be concurrently modified with a locking strategy• Must handle optimistic lock failures on flush/commit
• Use query refreshing to minimize optimistic lock failures
![Page 11: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/11.jpg)
Leveraging the Shared Cache: Reading
Client-2Client-1
EntityManager-1
EntityManagerFactoryL2 Cache Connection Pool
ConnectionConnectionConnection
Connection
EntityManager-2
L1 CacheL1 Cache
Connection
1
23
5
6
7
84
![Page 12: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/12.jpg)
EntityManager-2
L1 Cache
EntityManagerFactoryConnection Pool
ConnectionConnectionConnection
ConnectionConnection
Leveraging the Shared Cache: Writing
Client-2
L2 Cache
1
2
3
4
![Page 13: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/13.jpg)
EntityManagerFactoryConnection Pool
ConnectionConnectionConnection
ConnectionConnection
Leveraging the Shared Cache: Writing
L2 Cache
![Page 14: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/14.jpg)
Advanced Mappings
• @Converter• @BasicMap and @BasicCollection• Mapping to database structures
• @StructConverter – Structs, ADTs• XML types, PL/SQL Records
• Mapping features• Private Owned• Join/Batch Fetch• Returning
![Page 15: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/15.jpg)
@Entity
public class Employee {@Idprivate int id;
private String name;
@OneToMany(mappedBy=“owner”)private List<PhoneNumbers> phones;
private Money salary…
}
@Cache(type=SOFT_WEAK, coordinationType=SEND_OBJECT_CHANGES)
@Converter(name=“money”, converterClass=MoneyConverter.class)@OptimisticLocking(type=CHANGED_COLUMNS)
Advanced Mapping Example
@Convert(“money”)
![Page 16: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/16.jpg)
Advanced Querying
• Support for supplying customizing queries • Native SQL• @NamedStoredProcQuery
• Graph Loading Optimizations• Join and Batch Fetch – multi-level
• Cache Usage: In-memory• Result caching
![Page 17: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/17.jpg)
Transactions
• Java apps typically support many clients sharing small number of db connections
• Ideally would like to minimize length of transaction on database
Tim
e
Begin Txn
Commit TxnBegin Txn
Commit Txn
![Page 18: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/18.jpg)
Transaction Features
• Minimizes database interactions• Only the minimal updates are sent to the database
• Respect database integrity• Orders INSERT, UPDATE and DELETE statements
• JTA and RESOURCE_LOCAL support• Attribute-level change tracking• EntityManager flush SQL prior to commit• Bulk Update and Delete
• Cached entities effected
![Page 19: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/19.jpg)
Concurrency Protection - Locking
• Optimistic concurrency included in JPA 1.0, but no support for pessimistic locking is specified
• EclipseLink has advanced optimistic locking strategies• Numeric, Timestamp, All fields, Selected fields, Changed field
• EntityManager lock() method can be used with optimistic locking, and error handling
• EclipseLink supports pessimistic locking through query hints
query.setHint(PESSIMISTIC_LOCK, LockNoWait);
![Page 20: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/20.jpg)
Weaving
• EclipseLink makes use of Weaving (ASM) to introduce additional functionality into the JPA entity classes• Needed for M:1 and 1:1 lazy fetching• Integrated with Java EE compliant App Servers and Spring
2.0• Available for Java SE using JDK/JRE’s –javaagent:• Optional• Static weaving also supported
• Weaving of .class files before deployment
![Page 21: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/21.jpg)
JPA Configuration Options
• Annotations• JPA• EclipseLink
• ORM.XML• JPA• EclipseLink• JPA + EclipseLink
• Defaults – Configuration by Exception
![Page 22: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/22.jpg)
Database Platform
XML:<properties><property name=“eclipselink.target-database"
value="Derby"/></properties>
API:properties.put( EclipseLinkProperties.TARGET_DATABASE, TargetDatabase.ORACLE);
![Page 23: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/23.jpg)
Target Database Platform
• TargetDatabase (org.eclipse.persistence.jpa.config)• Auto (Default)• Oracle, Oracle8i, Oracle9i, Oracle10g, Oracle11, TimesTen• DB2, DB2Mainframe• Derby, JavaDB, MySQL• Informix• HSQL, PointBase• PostgreSQL• SQLAnyWhere• SQLServer, DBase• Sybase
![Page 24: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/24.jpg)
Server Platform
• Enables simplified configuration of the target application server
• Used to enable integration with:• JTA transaction manager• Logging• JDBC connection un-wrapping
• <property name=“eclipselink.target-server" value=“SunAS9"/>
![Page 25: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/25.jpg)
Target Server Options
• TargetServer (org.eclipse.persistence.jpa.config)• None (Default)• OC4J, OC4J_10_1_3, OC4J_11_1_1• SunAS9• WebSphere• WebSphere_6_1• WebLogic, WebLogic_9, WebLogic_10• JBoss
![Page 26: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/26.jpg)
JDBC Connection Settings
<properties>...<property name=“eclipselink.jdbc.driver” value=“oracle.jdbc.Driver”/>
<property name=“eclipselink.jdbc.url” value=“jdbc:oracle:thin:@localhost:1521:XE”/>
<property name=“eclipselink.jdbc.user” value=“scott”/>
<property name=“eclipselink.jdbc.password” value=“tiger”/>
![Page 27: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/27.jpg)
Logging
<properties> ...
<property name=“eclipselink.logging.level" value="FINE"/>...
</properties>
![Page 28: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/28.jpg)
DDL Generation
• Standard enables it but does not currently dictate that providers support it
• Mapping metadata specifies how DDL should be generated
• Vendors may offer differing levels of support, including:• Generating DDL to a file only• Generating and executing DDL in DB• Dropping existing tables before creating new ones
![Page 29: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/29.jpg)
DDL Generation
<properties> ...<property name=“eclipselink.ddl-generation"
value="create-tables"/> ...</properties>
![Page 30: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/30.jpg)
Customization Using Properties
<properties> ...<property
name="eclipselink.session.customizer" value="acme.MySessionCustomizer"/> <property name="eclipselink.descriptor.customizer.Employee"
value="acme.MyDescriptorCustomizer"/> ...</properties>
![Page 31: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/31.jpg)
Descriptor & Session Customizers
public class MySessionCustomizer implements SessionCustomizer {
public void customize(Session session) { session.setProfiler(new PerformanceProfiler()); }}
public class MyDescriptorCustomizer implements DescriptorCustomizer {
public void customize(ClassDescriptor desc) { desc.disableCacheHits(); }}
![Page 32: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/32.jpg)
Performance and Tuning
• Highly configurable and tunable• Guiding principle – minimize and optimize database
interactions• No two applications are the same, EclipseLink allows for
decisions on what specific behavior needs to be configurable depending on situation
• Flexibility of EclipseLink allows efficient business models and relational schemas to be used
• Leverages underlying performance tuning features• Java, JDBC and the underlying database technology• Batch Writing• Parameter Binding• Statement Caching
![Page 33: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/33.jpg)
Performance and Tuning
Minimal Writes, Updates Batch Reading, Writing SQL ordering Transformation support Existence checks Stored procedures Statement Caching Scrolling cursors Projection Queries Partial Attribute Queries
“Just in Time” reading Automatic change detectionCaching policies and sizesParameterized SQL (binding)Pre-allocation of sequence numbersCache CoordinationOptimistic, Pessimistic lockingJoining object retrieval optimizationIn memory queryingDynamic queries
AND MUCH MORE!
![Page 34: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/34.jpg)
EclipseLink Status
• Incubating Technology Project• Initial contribution of Oracle TopLink complete• Full documentation available on Wiki• Producing Monthly Milestone builds• Milestones included in GlassFish V3 Milestones
• 1.0 release planned for July 2008• JPA 1.0, SDO 2.1, JAXB• Simplified XML and annotation config of advanced features• Packaged for Java SE/EE and OSGi bundles
• Beyond 1.0• JPA 2.0 (Reference Implementation)• Database Web Services• Data Access Service (DAS) 1.0• and much more …
![Page 35: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/35.jpg)
Getting Started with EclipseLink JPA
• EclipseLink Projecthttp://www.eclipse.org/eclipselinkEclipse newsgroup: eclipse.technology.eclipselink
• GlassFish V3https://glassfish.dev.java.net/
• Open Source JPA Tools• NetBeans—http://www.netbeans.org
• Dali JPA Tools—http://www.eclipse.org/dali
![Page 36: Orcale Presentation](https://reader035.fdocuments.in/reader035/viewer/2022070316/555a76ebd8b42a972b8b5372/html5/thumbnails/36.jpg)