SqueakSave An Automatic Object-Relational Mapping Framework

763 views

Published on

SqueakSave An Automatic Object-Relational Mapping Framework by Michael Haupt, ESUG09, Brest, France

Published in: Technology
  • Be the first to comment

  • Be the first to like this

SqueakSave An Automatic Object-Relational Mapping Framework

  1. 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. 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. 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. 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. 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. 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. 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
  8. 8. SqueakSave: An Automatic Object-Relational Mapping Framework API – Queries (SqsSearch for: User) detect: [:aUser | aUser username = 'testuser'] (SqsSearch for: Author) select: [:anAuthor | anAuthor blog blogPosts size > 10 ] (SqsSearch for: Blog) anySatisfy: [:aBlog | aBlog blogPosts noneSatisfy: [:aBlogPost | aBlogPost comments isEmpty ] ] (SqsSearch for: Blog) findByTitle: 'testblog' (SqsSearch for: Comment) findByAuthor: 'author' andTitle: 'comment'. Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 8 lundi 31 août 2009
  9. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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
  25. 25. SqueakSave: An Automatic Object-Relational Mapping Framework Evaluation – Traversal Performance Traversal 1 Traversal 2a 6s 5s 3s 2s 0s SqueakSave GLORP SqueakSave GLORP Traversal 2b Traversal 2c 24s 18s – missing eager loading – minimal intrusion into object (n+1 queries problem) 12s models (only collection proxies) 6s 0s SqueakSave GLORP SqueakSave GLORP Thomas Kowark, Robert Hirschfeld, Michael Haupt (www.hpi.uni-potsdam.de/swa) 2009 13 lundi 31 août 2009
  26. 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. 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

×