Download presentation
Presentation is loading. Please wait.
Published byAnna Preston Modified over 9 years ago
1
Svetoslav Kapralov
2
ContentsContents 1.DB4O Overview OODBMS vs. RDBMSOODBMS vs. RDBMS What is DB4OWhat is DB4O 2.DB4O Basics Object ContainerObject Container CRUDCRUD ActivationActivation TransactionsTransactions 1.DB4O Overview OODBMS vs. RDBMSOODBMS vs. RDBMS What is DB4OWhat is DB4O 2.DB4O Basics Object ContainerObject Container CRUDCRUD ActivationActivation TransactionsTransactions
3
DB4O Overview
4
OОDBMS (db4o) vs. RDBMS Object-oriented programming (OOP) and relational databases (RDBMS) do not match upObject-oriented programming (OOP) and relational databases (RDBMS) do not match up An object database (ODBMS) stores objects directlyAn object database (ODBMS) stores objects directly Object-oriented programming (OOP) and relational databases (RDBMS) do not match upObject-oriented programming (OOP) and relational databases (RDBMS) do not match up An object database (ODBMS) stores objects directlyAn object database (ODBMS) stores objects directly
5
What is db4o? Open source object databaseOpen source object database Designed for embeddedDesigned for embedded 1,000,000 downloads,1,000,000 downloads, 20,000 registered community members20,000 registered community members 200 customers200 customers Dual license model (GPL / commercial)Dual license model (GPL / commercial) db4o is up to 55x faster than Hibernate + RDBMS!db4o is up to 55x faster than Hibernate + RDBMS! Open source object databaseOpen source object database Designed for embeddedDesigned for embedded 1,000,000 downloads,1,000,000 downloads, 20,000 registered community members20,000 registered community members 200 customers200 customers Dual license model (GPL / commercial)Dual license model (GPL / commercial) db4o is up to 55x faster than Hibernate + RDBMS!db4o is up to 55x faster than Hibernate + RDBMS!
6
What is db4o? No Database Administrator requiredNo Database Administrator required No conversion or mapping needed since objects are stored as they areNo conversion or mapping needed since objects are stored as they are Only one line of code to store objects of any complexity nativelyOnly one line of code to store objects of any complexity natively Installation by adding a single library fileInstallation by adding a single library file No Database Administrator requiredNo Database Administrator required No conversion or mapping needed since objects are stored as they areNo conversion or mapping needed since objects are stored as they are Only one line of code to store objects of any complexity nativelyOnly one line of code to store objects of any complexity natively Installation by adding a single library fileInstallation by adding a single library file
7
DB4O Basics
8
Object Container Represents db4o databasesRepresents db4o databases Supports local file mode or client connections to db4o serverSupports local file mode or client connections to db4o server All operations are executed transactionalAll operations are executed transactional Maintains references to stored and instantiated objectsMaintains references to stored and instantiated objects Represents db4o databasesRepresents db4o databases Supports local file mode or client connections to db4o serverSupports local file mode or client connections to db4o server All operations are executed transactionalAll operations are executed transactional Maintains references to stored and instantiated objectsMaintains references to stored and instantiated objects
9
Storing Objects Objects stored using method set of ObjectContainerObjects stored using method set of ObjectContainer Stores objects of arbitrary complexityStores objects of arbitrary complexity Objects stored using method set of ObjectContainerObjects stored using method set of ObjectContainer Stores objects of arbitrary complexityStores objects of arbitrary complexity ObjectContainer database = Db4o.openFile("test.db"); // create a publication Book book = new Book(“db4o"); // create authors Author lambo = new Author(“Lambo"); Author gruiu = new Author(“Gruiu"); // assign authors to book book.addAuthor(lambo); book.addAuthor(gruiu); //store complex object database.set(book);
10
Retrieving Objects db4o supports three query languagesdb4o supports three query languages QBEQBE Native queryNative query SODASODA db4o supports three query languagesdb4o supports three query languages QBEQBE Native queryNative query SODASODA
11
Query by Example ObjectContainer database = Db4o.openFile("test.db"); // get author “Lambo" Author proto = new Author(“Lambo"); ObjectSet authors = database.get(proto); for (Author author: authors) { System.out.println(author.getName()); } // get all books ObjectSet books = database.get(Book.class); for (Book book: books) { System.out.println(book.getTitle()); } simple method based on prototype objects simple method based on prototype objects
12
Native Queries ObjectContainer database = Db4o.openFile("test.db"); // find all books after 1995 ObjectSet books = database.query( new Predicate () { public boolean match(Book book) { return book.getYear() > 1995; } ); for (Book book: books) { System.out.println(book.getTitle()); } type safe type safe transformed to SODA and optimized transformed to SODA and optimized type safe type safe transformed to SODA and optimized transformed to SODA and optimized
13
Update / Delete Objects Update procedure for persistent objectUpdate procedure for persistent object retrieve desired object from the databaseretrieve desired object from the database perform the required changes and modificationperform the required changes and modification store object back to the database by calling the set methodstore object back to the database by calling the set method Delete procedure for persistent objectDelete procedure for persistent object retrieve desired object from the databaseretrieve desired object from the database method delete of ObjectContainer removes objectsmethod delete of ObjectContainer removes objects Update procedure for persistent objectUpdate procedure for persistent object retrieve desired object from the databaseretrieve desired object from the database perform the required changes and modificationperform the required changes and modification store object back to the database by calling the set methodstore object back to the database by calling the set method Delete procedure for persistent objectDelete procedure for persistent object retrieve desired object from the databaseretrieve desired object from the database method delete of ObjectContainer removes objectsmethod delete of ObjectContainer removes objects
14
CRUD Summary Storing of new objects using the set methodStoring of new objects using the set method object graph is traversed and all referenced objects are storedobject graph is traversed and all referenced objects are stored Updating of existing objects using the set methodUpdating of existing objects using the set method by default update depth is set to oneby default update depth is set to one only primitive and string values are updatedonly primitive and string values are updated object graph is not traversed for reasons of performanceobject graph is not traversed for reasons of performance Storing of new objects using the set methodStoring of new objects using the set method object graph is traversed and all referenced objects are storedobject graph is traversed and all referenced objects are stored Updating of existing objects using the set methodUpdating of existing objects using the set method by default update depth is set to oneby default update depth is set to one only primitive and string values are updatedonly primitive and string values are updated object graph is not traversed for reasons of performanceobject graph is not traversed for reasons of performance
15
CRUD Summary Deleting existing objects using the delete methodDeleting existing objects using the delete method by default delete operations are not cascadedby default delete operations are not cascaded referenced objects have to be deleted manuallyreferenced objects have to be deleted manually cascading delete can be configured for individual classescascading delete can be configured for individual classes Deleting existing objects using the delete methodDeleting existing objects using the delete method by default delete operations are not cascadedby default delete operations are not cascaded referenced objects have to be deleted manuallyreferenced objects have to be deleted manually cascading delete can be configured for individual classescascading delete can be configured for individual classes
16
ActivationActivation Activation controls instantiation of object fieldsActivation controls instantiation of object fields object field values are loaded into memory only to a certain depth when a query retrieves objectsobject field values are loaded into memory only to a certain depth when a query retrieves objects activation depth denotes the length of the reference chain from an object to anotheractivation depth denotes the length of the reference chain from an object to another fields beyond the activation depth are set to null for object references or to default values for primitive typesfields beyond the activation depth are set to null for object references or to default values for primitive types Activation controls instantiation of object fieldsActivation controls instantiation of object fields object field values are loaded into memory only to a certain depth when a query retrieves objectsobject field values are loaded into memory only to a certain depth when a query retrieves objects activation depth denotes the length of the reference chain from an object to anotheractivation depth denotes the length of the reference chain from an object to another fields beyond the activation depth are set to null for object references or to default values for primitive typesfields beyond the activation depth are set to null for object references or to default values for primitive types
17
ActivationActivation Activation depth trade-offActivation depth trade-off set to maximumset to maximum set to minimumset to minimum Controlling activationControlling activation default activation depth is 5default activation depth is 5 methods activate and deactivate of ObjectContainermethods activate and deactivate of ObjectContainer per class configurationper class configuration Activation depth trade-offActivation depth trade-off set to maximumset to maximum set to minimumset to minimum Controlling activationControlling activation default activation depth is 5default activation depth is 5 methods activate and deactivate of ObjectContainermethods activate and deactivate of ObjectContainer per class configurationper class configuration
18
TransactionsTransactions ACID transaction modelACID transaction model Data transaction journalingData transaction journaling zero data loss in case of system failurezero data loss in case of system failure automatic data recovery after system failureautomatic data recovery after system failure db4o core is thread-safe for simultaneous operationsdb4o core is thread-safe for simultaneous operations db4o uses the read committed isolation leveldb4o uses the read committed isolation level ACID transaction modelACID transaction model Data transaction journalingData transaction journaling zero data loss in case of system failurezero data loss in case of system failure automatic data recovery after system failureautomatic data recovery after system failure db4o core is thread-safe for simultaneous operationsdb4o core is thread-safe for simultaneous operations db4o uses the read committed isolation leveldb4o uses the read committed isolation level
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.