This document describes SqueakSave, an automatic object-relational mapping framework. SqueakSave allows objects in Smalltalk to be automatically persisted to a relational database with a simple API. It uses naming conventions to deduce mappings between objects and database tables. Queries can be written using Smalltalk syntax that gets translated to SQL. The framework architecture includes classes for managing connections, processing queries, and handling schema updates.
Introduction to Open Source RAG and RAG Evaluation
SqueakSave An Automatic Object-Relational Mapping Framework
1. SqueakSave
An Automatic Object-Relational Mapping Framework
Thomas Kowark
Robert Hirschfeld
Michael Haupt
Software Architecture Group
Hasso-Plattner-Institut Potsdam
www.hpi.uni-potsdam.de/swa
lundi 31 août 2009
2. SqueakSave: An Automatic Object-Relational Mapping Framework
Outline
• motivation
• basic usage
• framework architecture
• performance
• summary & outlook
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 2
lundi 31 août 2009
3. SqueakSave: An Automatic Object-Relational Mapping Framework
Available Persistence Approaches
• image storing
• object databases
• (object-)relational persistence
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 3
lundi 31 août 2009
4. SqueakSave: An Automatic Object-Relational Mapping Framework
SqueakSave – Project Goals
• automatic mapping deduction
• simplistic API
• seamless integration into existing applications
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 4
lundi 31 août 2009
5. SqueakSave: An Automatic Object-Relational Mapping Framework
Guiding Example
ual Paradigm for UML Community Edition [not for commercial use]
User +blog 1 Blog
-email : string -title : string
-username : string -lastUpdate : dateTime
-password : string +administeredBlogs 0..*
0..* +followers
1
0..* +blogPosts
BlogPost
1 -title : string
Author -text : string
1
1
0..* +comments
Comment
Admin -author : string
1..* -title : string
-text : string
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 5
lundi 31 août 2009
6. SqueakSave: An Automatic Object-Relational Mapping Framework
API – Configuration
• configuration based on naming conventions
SqsConfig subclass: #BlogExampleSqsConfig
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'BlogExample'
BlogExampleSqsConfig
class>>#connectionSpecification
^ SqsMySQLConnectionSpecification
user: 'admin'
password: 'password'
database: 'blog_example_db'
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 6
lundi 31 août 2009
7. SqueakSave: An Automatic Object-Relational Mapping Framework
API – Basic Operations
author := Author new
password: 'password';
username: 'testuser';
email: 'user@example.org'.
author blog: (Blog new title: 'My Blog').
author save.
...
author destroy.
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 7
lundi 31 août 2009
9. or commercial use]
SqueakSave: An Automatic Object-Relational Mapping Framework
Class
class currentClass
1 1
SqueakSave – Architecture
instVarValue
SqsBase 0..* SqsConnection
SqsProxy
SqsConnectionManager
+classInfo SqsClassInfo 1
1
+session SqsSession 1 <<use>>
1
dbAdapter 1
SqsDatabaseAdapter
ler SqsDescriptionHandler
1 <<use>>
0..*
0..1 connection
uctureHandler SqsTableStructureHandler SqsDatabaseConnection
1
ure 4.1: Overview of SqueakSave System Classes.
me into the separate sub words and connects them with an underscore. A
me’, for example, is thereby converted to the column name ‘user name’.
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 9
vide31simple compatibility with most other O/R mappers for dynamic
lundi août 2009
10. or commercial use]
SqueakSave: An Automatic Object-Relational Mapping Framework
Class
class currentClass
1 1
SqueakSave – Architecture
instVarValue
SqsBase 0..* anObject save SqsConnection
SqsProxy
SqsConnectionManager
+classInfo SqsClassInfo 1
1
+session SqsSession 1 <<use>>
1
dbAdapter 1
SqsDatabaseAdapter
ler SqsDescriptionHandler
1 <<use>>
0..*
0..1 connection
uctureHandler SqsTableStructureHandler SqsDatabaseConnection
1
ure 4.1: Overview of SqueakSave System Classes.
me into the separate sub words and connects them with an underscore. A
me’, for example, is thereby converted to the column name ‘user name’.
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 9
vide31simple compatibility with most other O/R mappers for dynamic
lundi août 2009
11. or commercial use]
SqueakSave: An Automatic Object-Relational Mapping Framework
Class
class currentClass
1 1
SqueakSave – Architecture
instVarValue
SqsBase 0..* SqsConnection
SqsProxy
SqsConnectionManager
+classInfo SqsClassInfo 1
1
SqsSession <<use>>
+session
Creation 1or fetching of
1
unique SqsStorage dbAdapter 1
ler SqsDescriptionHandler wrapper instance SqsDatabaseAdapter
1 <<use>>
0..*
0..1 connection
uctureHandler SqsTableStructureHandler SqsDatabaseConnection
1
ure 4.1: Overview of SqueakSave System Classes.
me into the separate sub words and connects them with an underscore. A
me’, for example, is thereby converted to the column name ‘user name’.
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 9
vide31simple compatibility with most other O/R mappers for dynamic
lundi août 2009
12. or commercial use]
SqueakSave: An Automatic Object-Relational Mapping Framework
Class
class currentClass
1 1
SqueakSave – Architecture
instVarValue
SqsBase 0..* SqsConnection
SqsProxy
SqsConnectionManager
+classInfo SqsClassInfo 1
1
+session SqsSession 1 <<use>>
1
dbAdapter 1
SqsDatabaseAdapter
ler SqsDescriptionHandler
1 <<use>>
0..*
0..1 connection
uctureHandler SqsTableStructureHandler SqsDatabaseConnection
1 Creation or update of
mapping descriptions
ure 4.1: Overview of SqueakSave System Classes.
me into the separate sub words and connects them with an underscore. A
me’, for example, is thereby converted to the column name ‘user name’.
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 9
vide31simple compatibility with most other O/R mappers for dynamic
lundi août 2009
13. or commercial use]
SqueakSave: An Automatic Object-Relational Mapping Framework
Class
class currentClass
1 1
SqueakSave – Architecture
instVarValue
SqsBase 0..* SqsConnection
SqsProxy
SqsConnectionManager
+classInfo SqsClassInfo 1
1
+session SqsSession 1 <<use>>
1
dbAdapter 1
SqsDatabaseAdapter
ler SqsDescriptionHandler
1 <<use>>
0..*
0..1 connection
uctureHandler SqsTableStructureHandler SqsDatabaseConnection
1
ure 4.1: Overview of SqueakSave System Classes.
Calculation of changes to
me into the separatedatabase and connects them with an underscore. A
the relational sub words
schema
me’, for example, is thereby converted to the column name ‘user name’.
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 9
vide31simple compatibility with most other O/R mappers for dynamic
lundi août 2009
14. or commercial use]
SqueakSave: An Automatic Object-Relational Mapping Framework
Class
class currentClass
1 1
SqueakSave – Architecture
instVarValue
SqsBase 0..* SqsConnection
SqsProxy
SqsConnectionManager
+classInfo SqsClassInfo 1
1
+session SqsSession 1 <<use>>
1 Connection pooling
dbAdapter 1
SqsDatabaseAdapter
ler SqsDescriptionHandler
1 <<use>>
0..*
0..1 connection
uctureHandler SqsTableStructureHandler SqsDatabaseConnection
1
ure 4.1: Overview of SqueakSave System Classes.
me into the separate sub words and connects them with an underscore. A
me’, for example, is thereby converted to the column name ‘user name’.
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 9
vide31simple compatibility with most other O/R mappers for dynamic
lundi août 2009
15. or commercial use]
SqueakSave: An Automatic Object-Relational Mapping Framework
Class
class currentClass
1 1
SqueakSave – Architecture
instVarValue
SqsBase 0..* SqsConnection
SqsProxy
SqsConnectionManager
+classInfo SqsClassInfo 1
1
+session SqsSession 1 <<use>>
1
dbAdapter 1
SqsDatabaseAdapter
ler SqsDescriptionHandler
1 <<use>>
0..*
0..1 connection
uctureHandler SqsTableStructureHandler SqsDatabaseConnection
Schema update and
1
object insertion or update
ure 4.1: Overview of SqueakSave System Classes.
me into the separate sub words and connects them with an underscore. A
me’, for example, is thereby converted to the column name ‘user name’.
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 9
vide31simple compatibility with most other O/R mappers for dynamic
lundi août 2009
16. SqueakSave: An Automatic Object-Relational Mapping Framework
Query Analysis
• SQL statement generation through block execution
with placeholder objects
• one placeholder class per ‘simple type’,
SqsQueryObject and SqsQueryCollection for
complex cases
(SqsSearch for: User) detect: [:aUser |
aUser username = 'testuser']
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 10
lundi 31 août 2009
17. SqueakSave: An Automatic Object-Relational Mapping Framework
Query Analysis
• SQL statement generation through block execution
with placeholder objects
• one placeholder class per ‘simple type’,
SqsQueryObject and SqsQueryCollection for
complex cases
(SqsSearch for: User) detect: [:aUser |
aUser username = 'testuser']
queryObject := SqsQueryObject new
depictedClass: User.
result := aBlock value: queryObject.
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 10
lundi 31 août 2009
18. SqueakSave: An Automatic Object-Relational Mapping Framework
Query Analysis
• SQL statement generation through block execution
with placeholder objects
• one placeholder class per ‘simple type’,
SqsQueryObject and SqsQueryCollection for
complex cases
(SqsSearch for: User) detect: [:aUser |
aUser username = 'testuser']
The query object does not know what #username
does, but generates the SQL to scope to the
respective column.
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 10
lundi 31 août 2009
19. SqueakSave: An Automatic Object-Relational Mapping Framework
Query Analysis
• SQL statement generation through block execution
with placeholder objects
• one placeholder class per ‘simple type’,
SqsQueryObject and SqsQueryCollection for
complex cases
(SqsSearch for: User) detect: [:aUser |
aUser username = 'testuser']
WHERE users.username
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 10
lundi 31 août 2009
20. SqueakSave: An Automatic Object-Relational Mapping Framework
Query Analysis
• SQL statement generation through block execution
with placeholder objects
• one placeholder class per ‘simple type’,
SqsQueryObject and SqsQueryCollection for
complex cases
(SqsSearch for: User) detect: [:aUser |
aUser username = 'testuser']
The result of the first call is an SqsQueryString.
It knows how to map the #= to SQL properly.
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 10
lundi 31 août 2009
21. SqueakSave: An Automatic Object-Relational Mapping Framework
Query Analysis
• SQL statement generation through block execution
with placeholder objects
• one placeholder class per ‘simple type’,
SqsQueryObject and SqsQueryCollection for
complex cases
(SqsSearch for: User) detect: [:aUser |
aUser username = 'testuser']
WHERE users.username =
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 10
lundi 31 août 2009
22. SqueakSave: An Automatic Object-Relational Mapping Framework
Query Analysis
• SQL statement generation through block execution
with placeholder objects
• one placeholder class per ‘simple type’,
SqsQueryObject and SqsQueryCollection for
complex cases
(SqsSearch for: User) detect: [:aUser |
aUser username = 'testuser']
WHERE users.username = ‘testuser’
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 10
lundi 31 août 2009
23. SqueakSave: An Automatic Object-Relational Mapping Framework
Evaluation
• evaluation based on OO7 benchmark
– CAD application data structure
– complex object model with many cyclic dependencies
• set of queries with increasing complexity
• number of traversals of an object graph
• comparison with GLORP
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 11
lundi 31 août 2009
24. SqueakSave: An Automatic Object-Relational Mapping Framework
Evaluation – Query Performance
• approx. 20% slower than GLORP
• two exceptions
– caching mechanism (10x slower)
(SqsSearch for: SqsAtomicPart) detect:
[:ap | ap oid = id].
– query creation with joins (1/3x faster)
(SqsSearch for: SqsBaseAssembly) select: [:ba |
ba unsharedParts anySatisfy: [:part |
part document = id ]].
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 12
lundi 31 août 2009
26. SqueakSave: An Automatic Object-Relational Mapping Framework
Summary and Outlook
• simple usage & setup
– integration into existing applications almost seamless
• automatic deduction of database structures
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 14
lundi 31 août 2009
27. SqueakSave: An Automatic Object-Relational Mapping Framework
Summary and Outlook
• simple usage & setup
– integration into existing applications almost seamless
• automatic deduction of database structures
• possible extensions
– SqueakDBX usage
– eager loading
– performance optimizations
Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 14
lundi 31 août 2009