object- relational persistence in smalltalk

19
Object- Relational Persistence in Smalltalk Alan Knight ([email protected]) Cincom Systems of Canada

Upload: esug

Post on 12-Nov-2014

1.397 views

Category:

Technology


5 download

DESCRIPTION

Object- Relational Persistence in Smalltalk(ESUG 2004, Koethen)

TRANSCRIPT

Page 1: Object- Relational Persistence in Smalltalk

Object-RelationalPersistence inSmalltalk

Alan Knight ([email protected])

Cincom Systems of Canada

Page 2: Object- Relational Persistence in Smalltalk

What is GLORPWhat is GLORP

Generic Lightweight Object-RelationalPersistence

Open-source library for O/R mappingLGPL(S)

Camp Smalltalk projectSponsored by The Object People (2000)

Portable

Planned as one part of major overhaul of ObjectLens

Page 3: Object- Relational Persistence in Smalltalk

Motivating ExampleMotivating Example

Cincom internal application

Widely used internally and by customers

Critical

Relatively simple model19 tables

somewhere between 12 and 46 domain classes

Client-server (although server functionalitydesirable)

Page 4: Object- Relational Persistence in Smalltalk

IssuesIssues

Schema changes extremely difficult

"Interesting" schema

Performance critical

Some operations over very high-latency links

Significant amounts of data

Versioning schema, heavily linked data

Must support multiple databases

Demo

Page 5: Object- Relational Persistence in Smalltalk

Relationship ExampleRelationship Example(aDescriptor newMapping: ToManyMapping)

attributeName: #methods;referenceClass: StoreMethodInPackage;useLinkTable;join: (Join

from: primaryKeyFieldto: methodsTable packageRefField).

methodMapping query alsoFetch: [:each |each definition].

methodMapping query expectedRows: 1000.

Note that Join defines read, write, and join.

Note optimizations

Page 6: Object- Relational Persistence in Smalltalk

Packages and ClassesPackages and Classes

In Store, "Package" means one version

"Class" means ClassDefinition

Entities in database are not like traditional in-memory entities

e.g. what package contains this method

Introduce additional entitiesStoreVersionlessPackage

StoreMethodInPackage (etc)

StoreClassExtension

Clearer domain model, ability to express querie

Page 7: Object- Relational Persistence in Smalltalk

Demo 2Demo 2

Querying UI

Replicating

Browsing

Optimizations

Caching

Page 8: Object- Relational Persistence in Smalltalk

WritingWriting

Unit of Work

Purely transactional

No explicit writes

In-memory rollback

Automatic insert/update

Automatic write order/referential integrity

Mostly automatic database transactions

Optimized

Page 9: Object- Relational Persistence in Smalltalk

Notable Technical PointsNotable Technical Points

Object-level rollback in Unit of Work

RowMaps and write optimization

Block to expression conversion

Joinsdeclarative - defines the table relationship

simple

handles all uses

Page 10: Object- Relational Persistence in Smalltalk

AcknowledgementsAcknowledgements

The Object People

Cincom

All the contributors and users of GLORP

Page 11: Object- Relational Persistence in Smalltalk

ReferencesReferences

GLORP

http://www.glorp.org

http://glorp.sourceforge.net

General

Ambler: Object Primer, http://www.agiledata.com (goodemphasis on importance of both worlds)

Fowler: Patterns of Enterprise Application Architecture (goodpatterns, once you ignore the non-domain model stuff)

Fabian Pascal: Practical Issues in Database Management(pure relational extremist)

ROE - Avi Bryant

Gemstone

Page 12: Object- Relational Persistence in Smalltalk

2004 Cincom Systems, Inc.All Rights Reserved

CINCOM and The Smart Choice are trademarks or registered trademarks of Cincom Systems, Inc

All other trademarks belong to their respective companies.

Page 13: Object- Relational Persistence in Smalltalk

Reading non-Object DataReading non-Object Data

Reading pure data, orderingquery := Query readManyOf: StorePackage.

Aggregate functionsquery orderBy: [:each | each name].

query retrieve: [:each | each name distinct].

query retrieve: [:each | each primaryKey max].

Retrieving pieces of objectsquery retrieve: [:each | each id].

query retrieve: [:each | each name].

query retrieve: [:each | each address] (changing contexts)

Note: All internal queries generated by user-accessiblemechanisms.

Page 14: Object- Relational Persistence in Smalltalk

Change Hats: VisualWorksChange Hats: VisualWorks

Next-generation database frameworks, inputsVisualWorks Object Lens

Strong in many respects, but very dated

Client-server orientation

Object Studio POFVery strong modelling

GLORPOpen-source

Extremely flexible mapping layer

SQLWorksGood server orientation

*very* high-performance

Goal: Synthesize the best of all these

Page 15: Object- Relational Persistence in Smalltalk

Core IssuesCore Issues

Object identity vs primary keys

Pointers vs. foreign keys

Networks of objects vs. rows

Queries vs. traversing relationships

Encapsulation vs. program independence

nil is not null

The role of the application

Page 16: Object- Relational Persistence in Smalltalk

Incidental IssuesIncidental Issues

Keys: natural vs. generated

Integrity constraints

Inheritance

Mismatched schemas

Agility

Page 17: Object- Relational Persistence in Smalltalk

General Database/Multi-UserIssuesGeneral Database/Multi-UserIssues

Scaling

When to read data?

What do queries look like?

Performance, performance, performance

Locking

Caching, refreshing, keeping data in sync

Transaction semantics (knowing whichtransaction to use)

Transaction lengths

Multi-user within an image?

Page 18: Object- Relational Persistence in Smalltalk

ApproachesApproaches

Metadata or code generation

Associating objects with transactions

SQL, OO query language, objects as queries,special syntax

Explicit or automatic writes

Marking objects dirty

When to take objects out of cache

Different framework architectures (e.g. brokers,subclassing)

Page 19: Object- Relational Persistence in Smalltalk

GLORP LicensingGLORP Licensing

LGPL (Lesser GNU Public License)Can be used as a library, does not affect linked code

Modifications must be released under the same license

But…LGPL’s terminology very difficult to interpret withrespect to Smalltalk.

ApproachInclude a clarification with GLORP, specifying asensible Smalltalk interpretation of the license

Copyright held by the authors/not assigned

Counsel: Lawrence Rosen (also general counsel of OSI)