-
Notifications
You must be signed in to change notification settings - Fork 9
Examples
ZooDB contains usage examples in the /examples
folder.
This example demonstrates basic functionality:
- Create/delete databases
- How to turn a class into a persistent class: add
extends ZooPC
and an default constructor to the class definition and insertzooActivateRead()
into getter methods andzooActivateWrite()
into setter methods - Open a database
- Transparent persistence: Once one persistent object (PC) is made persistent, all reachable objects will be stored as well. Changes to objects are detected automatically (via
zooActivateWrite()
). - Basic queries
- Extents: a faster query, but without filter
This example demonstrates some more advanced features:
- How to handle inheritance: Simply extend a persistent class
- Indexes can be created with
ZooJdoHelper.createIndex(...)
- How to use navigation: simplify follow a Java reference (no JOIN on primary keys needed!)
- Path Queries: query over references, this is similar to multiple JOINs in RDBMS. For example, querying
teacher.name == "Peter"
on the Course class returns all courses whose teacher is called Peter. Null references always evaluate to false.
This example that shows how to access object outside of transactions with non-transactional read. This can be useful in GUI applications where a transaction should be closed most of the time, while the GUI should still be able to read data from the database.
Note that in a setting with multiple concurrent persistence managers, this may result in inconsistencies because any values that were read outside of a transaction may be outdated by the time when the next transaction commits.
Non-transactional can be configured on different levels, for example on the PersistenceManagerFasctory
or on the Transaction
.