RegisterSign In

API Documentation: Class ODBTransaction

Package: com.mckoi.odb

A transaction in an Mckoi Object Database data model session. A transaction is a view of the data at a consistent state in the lifespan of the database. The data visible in a transaction will show changes made locally by the client, but otherwise will never change from the time of construction. Changes made to the backed database that happen while a transaction exists will not be visible in the transaction.

An ODBTransaction object is NOT thread-safe. It is important that interaction with an ODBTransaction, and also any objects produced by, is only ever accessed by a single thread at a time.

Once a series of changes has been made to a transaction, the transaction must be committed for the changes to become permanent. The commit process may discover inconsistencies, such as duplicate entries added to a list or concurrent transactions removing the same item. In such cases, the commit will fail and generate a CommitFaultException.

Methods Summary

String getSessionPathName()
ODBClassCreator getClassCreator()
ODBClass findClass(String class_name)
ODBObject constructObject(ODBClass clazz, Object[] args)
ODBClass getClass(Reference ref)
ODBObject getObject(ODBClass type, Reference ref)
void addNamedItem(String name, ODBObject item)
boolean removeNamedItem(String name)
ODBObject getNamedItem(String name)
void doGarbageCollection()
List<String> getNamedItemsList()
List<String> getClassNamesList()
ODBRootAddress commit() throws CommitFaultException
void finalize() throws Throwable

Method Details

String getSessionPathName()

Returns the path name of the session.

ODBClassCreator getClassCreator()

Returns an ODBClassCreator for creating a class schema in this transaction. The classes created with a creator object must first be validated before they may be accessed within the transaction. As with all data operations, the transaction must be committed before changes are made permanent.

ODBClass findClass(String class_name)

Returns the class instance currently defined with the given name, or null if no class currently defined with that name.

ODBObject constructObject(ODBClass clazz, Object[] args)

Defines an object and returns the object. An object must resolve against the given class type. Note that the given arguments may be only either a java.lang.String, a com.mckoi.odb.Reference or null.

ODBClass getClass(Reference ref)

Returns a class from a reference. The returned class is immutable.

Throws NoSuchReferenceException if the reference is invalid.

ODBObject getObject(ODBClass type, Reference ref)

Returns an ODBObject from a reference. Returns null if the reference is to a null object. The returned object is selectively mutable and changes made are published on commit. Fields defined as immutable can not be changed.

Throws NoSuchReferenceException if the reference is invalid.

void addNamedItem(String name, ODBObject item)

Adds a named item to the database. A named item is a 'window' or starting point of the object graph.

boolean removeNamedItem(String name)

Removes a named item from the database. If the named item isn't defined then returns false, otherwise returns true if the named item was deleted.

ODBObject getNamedItem(String name)

Returns a named item from the database, or null if the named item isn't defined.

void doGarbageCollection()

Scans the object graph and creates a set of reachable objects, and then finds the difference between the entire set of references and the set of reachable objects. References that are not in the graph are deleted.

This process may take time to complete (it is recommended be done in an offline process). A garbage collection operation will never cause a fault on commit.

The contract does not guarantee all unreachable objects will be deleted by this operation since the administrator may define policy on the maximum about of time a garbage collection cycle can take. This operation should operate incrementally if desired.

List<String> getNamedItemsList()

Returns the set of all named items as a List of Java String objects. Changes to the list of named items is immediately reflected in the returned object, however the returned list itself is immutable.

List<String> getClassNamesList()

Returns the set of all class names as a List of Java String objects. Changes to the classes defined is immediately reflected in the returned object, however the returned list itself is immutable.

ODBRootAddress commit()

Commits any changes made in this transaction.

void finalize()

The GC finalize method for this object.

The text on this page is licensed under the Creative Commons Attribution 3.0 License. Java is a registered trademark of Oracle and/or its affiliates.
Mckoi is Copyright © 2000 - 2020 Diehl and Associates, Inc. All rights reserved.