Java Object Persistence Rakesh Vidyadharan rakesh@sptci.com - - PowerPoint PPT Presentation

java object persistence
SMART_READER_LITE
LIVE PREVIEW

Java Object Persistence Rakesh Vidyadharan rakesh@sptci.com - - PowerPoint PPT Presentation

Introduction Prevayler Object Databases Java Object Persistence Rakesh Vidyadharan rakesh@sptci.com 2008-05-20 Rakesh Vidyadharan Java Object Persistence Introduction Prevayler Object Databases Object Databases Object Databases are


slide-1
SLIDE 1

Introduction Prevayler Object Databases

Java Object Persistence

Rakesh Vidyadharan rakesh@sptci.com 2008-05-20

Rakesh Vidyadharan Java Object Persistence

slide-2
SLIDE 2

Introduction Prevayler Object Databases

Object Databases

Object Databases are systems that provide:

Persistent store for objects and object graphs. Transactional semantics for object storage and retrieval. Query mechanism to retrieve objects. Transparent handling of references.

Rakesh Vidyadharan Java Object Persistence

slide-3
SLIDE 3

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

What is Prevayler?

Not an object database.

Rakesh Vidyadharan Java Object Persistence

slide-4
SLIDE 4

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

What is Prevayler?

Not an object database. Transactional object serialization framework. Prevalent system is held entirely in memory. Prevalent system is updated through transactions. Transactions are serialized as journals. No rollback. Pre-check prior to updating system. Snapshot of entire object graph may be taken. System is restored by replaying journal files and snapshots in sequence. Prevalent system responsible for storage, indexing, . . . .

Rakesh Vidyadharan Java Object Persistence

slide-5
SLIDE 5

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

What is Prevayler?

Not an object database. Transactional object serialization framework. Prevalent system is held entirely in memory. Prevalent system is updated through transactions. Transactions are serialized as journals. No rollback. Pre-check prior to updating system. Snapshot of entire object graph may be taken. System is restored by replaying journal files and snapshots in sequence. Prevalent system responsible for storage, indexing, . . . . You implement an object database using Prevayler. Available for non-Java platforms.

Rakesh Vidyadharan Java Object Persistence

slide-6
SLIDE 6

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

Prevalent System

Prevalent System Business Object Business Object Business Object Business Object Business Object Business Object Business Object Business Object Business Object Controller Controller Controller Controller Controller Controller Query Add Query Update Delete Query

Rakesh Vidyadharan Java Object Persistence

slide-7
SLIDE 7

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

PrevalentSystem.java

t r y { f i n a l S t r i n g d i r e c t o r y = System . getProperty ( DATA DIRECTORY, DEFAULT DIRECTORY ) ; p r e v a y l e r = P r e v a y l e r F a c t o r y . c r e a t e P r e v a y l e r ( new TimeSystem () , d i r e c t o r y ) ; } catch ( Throwable t ) { throw new RuntimeException ( t ) ; }

Rakesh Vidyadharan Java Object Persistence

slide-8
SLIDE 8

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

TimeSystem.java

c l a s s TimeSystem implements S e r i a l i z a b l e { p r i v a t e long

  • b j e c t I d ;

p r i v a t e Map<Long , Time> map = new LinkedHashMap<Long , Time >(); p u b l i c Time add ( f i n a l Time time ) throws DuplicateException { check ( ) ; time . s e t O b j e c t I d (

  • b j e c t I d++ ) ;

map . put (

  • bjectId ,

time ) ; r e t u r n time ; } }

Rakesh Vidyadharan Java Object Persistence

slide-9
SLIDE 9

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

AddTime.java

p u b l i c c l a s s AddTime implements

  • rg . p r e v a y l e r . TransactionWithQuery

{ p r i v a t e f i n a l Time time ; p u b l i c AddTime( f i n a l Time time ) { t h i s . time = time ; } p u b l i c Object executeAndQuery ( f i n a l Object system , f i n a l Date executionTime ) throws Exception { r e t u r n (( TimeSystem ) system ) . addTime ( time ) ; } }

Rakesh Vidyadharan Java Object Persistence

slide-10
SLIDE 10

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

Client.java

import . . . AddTime ; import . . . PrevalentSystem ; p u b l i c c l a s s C l i e n t { p u b l i c void add () { Time time = new Time ( ) ; time . setXXX ( . . . ) ; PrevalentSystem . g e t P r e v a y l e r ( ) . execute ( new AddTime( time ) ) ; } }

Rakesh Vidyadharan Java Object Persistence

slide-11
SLIDE 11

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

What is a prevalent system?

Provide storage mechanism for business objects Must be serializable.

Rakesh Vidyadharan Java Object Persistence

slide-12
SLIDE 12

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

What is a prevalent system?

Provide storage mechanism for business objects

Business objects are stored in collections. Indexing of query fields through maps. Implement methods required to maintain (create, update, delete) and retrieve business objects. Maintenance methods are executed within the bounds of a transaction.

Must be serializable.

Rakesh Vidyadharan Java Object Persistence

slide-13
SLIDE 13

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

What is a prevalent system?

Provide storage mechanism for business objects

Business objects are stored in collections. Indexing of query fields through maps. Implement methods required to maintain (create, update, delete) and retrieve business objects. Maintenance methods are executed within the bounds of a transaction.

Must be serializable. Rules for Business Objects Must be serializable. Implement hashCode method. Object graphs only through key fields. Direct object references become local copies due to nature of serialization.

Rakesh Vidyadharan Java Object Persistence

slide-14
SLIDE 14

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

Transactions

Must be serializable. Must be deterministic. No direct object references to business objects.

Rakesh Vidyadharan Java Object Persistence

slide-15
SLIDE 15

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

Transactions

Must be serializable. Must be deterministic. Transactions must have the same effect on business objects when they are de-serialized as when they are serialized. No direct object references to business objects.

Rakesh Vidyadharan Java Object Persistence

slide-16
SLIDE 16

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

Transactions

Must be serializable. Must be deterministic. Transactions must have the same effect on business objects when they are de-serialized as when they are serialized. No direct object references to business objects. Things to avoid System.currentTimeMillis() Object.hashCode() default implementation. Iterators of Hashtable, HashMap, or HashSet. No Random without a deterministic seed. No hardware or network access directly.

Rakesh Vidyadharan Java Object Persistence

slide-17
SLIDE 17

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

Interactions

Business Method Prevalent System Transaction Business Method Prevalent System Query Business Object(s) Business Object

Rakesh Vidyadharan Java Object Persistence

slide-18
SLIDE 18

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

When to use Prevayler

Small data set. All data fits into memory. Business objects are simple without too many interdepencies. Simple querying requirements. Application start-up time is not critical. You require high degree of fault tolerance over and above direct object serialization.

Rakesh Vidyadharan Java Object Persistence

slide-19
SLIDE 19

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

Disadvantages

All data must fit into memory. Business objects cannot hold direct business object references. Requires creation of transaction and query objects. Long start-up time while prevalent system is reinstated from snapshot and journals. Storage and indexing must be handled in implemented prevalent system. No schema evolution.

Rakesh Vidyadharan Java Object Persistence

slide-20
SLIDE 20

Introduction Prevayler Object Databases Fundementals Source Code Prevalent System Transactions & Queries

Disadvantages

All data must fit into memory. Business objects cannot hold direct business object references. Requires creation of transaction and query objects.

Dynamic proxies may be used to represent transaction and query objects. Related project Finevayler available that removes some of these inconveniences.

Long start-up time while prevalent system is reinstated from snapshot and journals. Storage and indexing must be handled in implemented prevalent system. No schema evolution.

Rakesh Vidyadharan Java Object Persistence

slide-21
SLIDE 21

Introduction Prevayler Object Databases ObjectDB Pros & Cons Links

What is ObjectDB?

A pure Java Object Database. Embedded or client-server modes. JDO 2.1 and JPA 1.0 (partial) compliant. Seamlessly persist and retrieve complex object graphs. No huge memory requirements. Performance many times that of MySQL/Oracle/. . . ObjectDB Explorer tool provides database management features. Very responsive support.

Rakesh Vidyadharan Java Object Persistence

slide-22
SLIDE 22

Introduction Prevayler Object Databases ObjectDB Pros & Cons Links

What is ObjectDB?

A pure Java Object Database. Embedded or client-server modes. JDO 2.1 and JPA 1.0 (partial) compliant. Production version 1.04 supports only JDO 1.0, while version 2.0 is still in beta. Backup and recovery, index rebuilding, managed relationships etc are still not supported. Seamlessly persist and retrieve complex object graphs. No huge memory requirements. Performance many times that of MySQL/Oracle/. . . ObjectDB Explorer tool provides database management features. Very responsive support.

Rakesh Vidyadharan Java Object Persistence

slide-23
SLIDE 23

Introduction Prevayler Object Databases ObjectDB Pros & Cons Links

Advantages of Object Databases

Seamlessly persist complex object graphs. Performance orders of magnitude higher than relational databases. Extremely efficient handling of object references. Domain specific object modelling. No OR mapping - quick development cycle. Programmer’s system, no DBA’s required.

Rakesh Vidyadharan Java Object Persistence

slide-24
SLIDE 24

Introduction Prevayler Object Databases ObjectDB Pros & Cons Links

Advantages of Object Databases

Seamlessly persist complex object graphs. Performance orders of magnitude higher than relational databases. Extremely efficient handling of object references.

Composite objects may be used to achieve extreme performance. No join queries required.

Domain specific object modelling. No OR mapping - quick development cycle. Programmer’s system, no DBA’s required.

Rakesh Vidyadharan Java Object Persistence

slide-25
SLIDE 25

Introduction Prevayler Object Databases ObjectDB Pros & Cons Links

Disadvantages of Object Databases

Restricted query language. No bulk data loaders and transformers. Cumbersome data management processes. No stored procedures. No job security.

Rakesh Vidyadharan Java Object Persistence

slide-26
SLIDE 26

Introduction Prevayler Object Databases ObjectDB Pros & Cons Links

Disadvantages of Object Databases

Restricted query language.

Poor join performance. Join queries are used to fetch loosely related objects. Poor performance of ad-hoc queries.

No bulk data loaders and transformers. Cumbersome data management processes. No stored procedures. No job security.

Rakesh Vidyadharan Java Object Persistence

slide-27
SLIDE 27

Introduction Prevayler Object Databases ObjectDB Pros & Cons Links

Links

Prevayler Finevayler ObjectDB db4o - JPOX provides an adapter for db4o. MyOODB JODB

Rakesh Vidyadharan Java Object Persistence