Objectivity for Java Reference

com.objy.db.app
Class ooDBObj

java.lang.Object
  |
  +--com.objy.db.app.ooAbstractObj
        |
        +--com.objy.db.app.ooDBObj

public final class ooDBObj
extends ooAbstractObj

Represents an Objectivity/DB database.

API Summary

A database is the second highest level in the Objectivity/DB storage hierarchy. It contains one or more containers which, in turn, contain fundamental units of persistent data called basic objects.

A database is physically maintained in a database file. This file contains the database and all of its containers and basic objects. Each database is attached to exactly one federated database and is listed in that federated database's catalog. A database has a system name, which is its logical name within the federated database.

To create a new database, call one of the newDB methods on an instance of ooFDObj. These methods create a new database file, a database in the federated database, a default container in the database, an instance of ooDBObj in your application, and lock the database in write mode.

You can get an object representing an existing database in any one of the following ways:

Note: A database object belongs to the session that is in a transaction when the database is created or retrieved. Objectivity for Java does not allow a database to interact with objects that belong to different sessions; see Object Isolation.

Once you have a database object, you can:

The session that owns the database object must be in a transaction when you call methods defined in this class.

In collaboration with autonomous partitions, databases can also manage images or replicas of the database file. Each replica has an integer-valued weight. If the sum of the weights of the images available to an application is greater than half of the total weight of the images, that set of images constitutes a quorum. To guarantee database consistency, a quorum must be available to an application in order for database access operations to succeed.

In some circumstances, it may be desirable to have access to data even in the absence of a quorum. An alternative configuration allowing this access makes use of a tie-breaker autonomous partition. The tie-breaker is a partition that has its own lock server and functions like a pseudo-image. It contains no data, but participates as a member of the database quorum.

For additional information about using databases in your application, see Databases.

API Summary

Functionality
Locking lock(int)
flush()
Modifying delete()
Getting Information About the Database getName()
getOid()
getFileName()
getHostName()
getPathName()
getDefaultContainer()
getContainerCount()
getSession()
getFD()
getContainingPartition() (FTO/DRO)
getImageCount() (DRO)
getTieBreaker() (DRO)
Testing the Database isReadOnly()
isDead()
hasContainer(String)
hasIndex(String)
isAvailable() (FTO/DRO)
isReplicated() (DRO)
hasImageIn(ooAPObj) (DRO)
isNonQuorumReadAllowed() (DRO)
isNonQuorumRead() (DRO)
Modifying the Database setReadOnly(boolean)
changePartition(ooAPObj) (FTO)
setTieBreaker(ooAPObj) (DRO)
Finding Contained Objects scan(String)
scan(String, String)
getDefaultContainer()
lookupContainer(String)
contains()
contains(int) (DRO)
Finding Containing Objects getFD()
getContainingPartition() (FTO)
containingImage() (DRO)
Clustering cluster(Object)
Working With Named Roots bind(Object, String)
unbind(String)
lookup(String)
rootNames()
Working With Scope-Named Objects nameObj(Object, String)
unnameObj(Object)
lookupObj(String)
lookupObj(String, int)
lookupObjName(Object)
Working With Containers addContainer(ooContObj, String, long, long, long)
getContainerCount()
hasContainer(String)
lookupContainer(String)
getDefaultContainer()
contains()
contains(int) (DRO)
Working With Indexes addIndex(String, String, String)
addUniqueIndex(String, String, String)
hasIndex(String)
dropIndex(String)
Converting Objects convertObjects()
Creating and Deleting Images (DRO) replicate(ooAPObj, String, String, long) (DRO)
deleteImage(ooAPObj) (DRO)
deleteImage(ooAPObj, boolean) (DRO)
Getting Information About an Image (DRO) getImageFileName(ooAPObj) (DRO)
getImagePathName(ooAPObj) (DRO)
getImageHostName(ooAPObj) (DRO)
getImageWeight(ooAPObj) (DRO)
Testing an Image (DRO) isImageAvailable(ooAPObj) (DRO)
Modifying an Image (DRO) setImageWeight(ooAPObj, long) (DRO)
Working With Nonquorum Reads (DRO) setNonQuorumReadAllowed(boolean) (DRO)
isNonQuorumReadAllowed() (DRO)
isNonQuorumRead() (DRO)
Resynchronizing Images (DRO) negotiateQuorum(int) (DRO)


Constructor Summary
ooDBObj(PooDBObj persistor)
          Reserved for internal use; to create a database object, call one of the newDB methods of a federated database.
 
Method Summary
 void addContainer(ooContObj container, String name, long hash, long initialPages, long growthFactor)
          Adds the specified container with the specified system name, hash value, number of initial pages, and percent growth to this database.
 void addIndex(String name, String className, String fieldList)
          Adds an index to this database.
 void addUniqueIndex(String name, String className, String fieldList)
          Adds a unique index to this database.
 void bind(Object object, String name)
          Names the specified object with the specified root name in this database.
 void changePartition(ooAPObj partition)
          (FTO) Changes the autonomous partition that contains this database.
 void cluster(Object object)
          Makes the specified object persistent, clustering it in this database.
 long connectionId()
          Reserved for internal use; you should not call this method.
 Iterator containingImage()
          (DRO) Initializes an iterator to find all the autonomous partitions in which this database has images.
 Iterator contains()
          Initializes an iterator to find all the containers in this database.
 Iterator contains(int filter)
          (DRO) Initializes an iterator to find the containers contained in this database that satisfy the specified filter.
 void convertObjects()
          Converts all basic objects in this database to be consistent with their current Java class definitions.
 void delete()
          Deletes this database.
 void deleteImage(ooAPObj partition)
          (DRO) Deletes the image of this database contained in the specified autonomous partition.
 void deleteImage(ooAPObj partition, boolean deleteDBifLast)
          (DRO) Deletes the image of this database in the specified autonomous partition, possibly deleting the last image of this database.
 void dropIndex(String name)
          Drops the specified index from this database.
 void flush()
          Transfers the data of all modified objects to this database cache.
 long getContainerCount()
          Gets the number of containers in this database.
 ooAPObj getContainingPartition()
          (FTO) Gets the autonomous partition which contains this database.
 ooDefaultContObj getDefaultContainer()
          Gets the default container of this database.
 ooFDObj getFD()
          Gets the federated database that contains this database.
 String getFileName()
          Gets the full pathname of this database's file.
 String getHostName()
          Gets the name of the host on which this database's file is located.
 long getImageCount()
          (DRO) Gets the number of images of this database.
 String getImageFileName(ooAPObj partition)
          (DRO) Gets the filename of this database's image contained in the specified autonomous partition.
 String getImageHostName(ooAPObj partition)
          (DRO) Gets the host location of this database's image file contained in the specified autonomous partition.
 String getImagePathName(ooAPObj partition)
          (DRO) Gets the directory location of this database's image file contained in the specified autonomous partition.
 long getImageWeight(ooAPObj partition)
          (DRO) Gets the weight of the image of this database contained in the specified autonomous partition.
 String getName()
          Gets the system name of this database.
 ooId getOid()
          Gets the object identifier of this database.
 String getPathName()
          Gets the full pathname of the directory where the database file is located.
 Session getSession()
          Gets the session in which this database was created or retrieved.
 ooAPObj getTieBreaker()
          (DRO) Gets the tie-breaker autonomous partition of this database.
 boolean hasContainer(String name)
          Tests whether the container with the specified system name exists in this database.
 boolean hasImageIn(ooAPObj partition)
          (DRO) Tests whether an image of this database exists in the specified autonomous partition.
 boolean hasIndex(String name)
          Tests whether this database has an index with the specified name.
 boolean isAvailable()
          (FTO/DRO) Tests whether this database is accessible by the current process.
 boolean isDead()
          Tests whether this database is dead.
 boolean isImageAvailable(ooAPObj partition)
          (DRO) Tests whether an image of this database in the specified autonomous partition is accessible by the current process.
 boolean isNonQuorumRead()
          (DRO) Tests whether the application is currently reading this database without having access to a quorum of images.
 boolean isNonQuorumReadAllowed()
          (DRO) Tests whether this application can read this database even if a quorum of images is not available.
 boolean isReadOnly()
          Tests whether this database is read only.
 boolean isReplicated()
          (DRO) Tests whether there is more than one image of this database.
 void lock(int mode)
          Locks this database and everything contained in it with the specified lock mode.
 Object lookup(String name)
          Retrieves the object with the specified root name in this database.
 ooContObj lookupContainer(String name)
          Retrieves the container with the specified system name in this database.
 Object lookupObj(String scopeName)
          Retrieves the object with the specified scope name in the scope defined by this database.
 Object lookupObj(String scopeName, int lockMode)
          Retrieves the object with the specified scope name in the scope defined by this database, locking the retrieved object as specified.
 String lookupObjName(Object object)
          Looks up the name of the specified object in the scope defined by this database.
 void nameObj(Object object, String scopeName)
          Names the specified object in the scope of this database.
 void negotiateQuorum(int lockMode)
          (DRO) Forces recalculation of the quorum for this database.
 void replicate(ooAPObj partition, String hostName, String pathName, long weight)
          (DRO) Creates an image of this database in the specified autonomous partition with the given weight.
 Iterator rootNames()
          Initializes an iterator to find the root names maintained by this database.
 Iterator scan(String className)
          Initializes an iterator to scan this database for objects of the specified class.
 Iterator scan(String className, String predicate)
          Initializes an iterator to scan this database for objects of the specified class that satisfy the specified predicate.
 Iterator scan(String className, String predicate, int access)
          Deprecated. Use scan(String, String).
 void setImageWeight(ooAPObj partition, long weight)
          (DRO) Sets the weight of this database's image in the specified autonomous partition.
 void setNonQuorumReadAllowed(boolean allowed)
          (DRO) Specifies whether this application can read this database if a quorum of images is not available.
 void setPersistor(PooDBObj persistor)
          Reserved for internal use; you should not call this method.
 void setReadOnly(boolean value)
          Set the access status of this database so that is is either read-only or read-write.
 void setTieBreaker(ooAPObj partition)
          (DRO) Sets the tie-breaker autonomous partition of this database.
 void unbind(String name)
          Removes a root name from this database.
 void unnameObj(Object object)
          Removes the specified object's name from the name scope of this database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ooDBObj

public ooDBObj(PooDBObj persistor)
Reserved for internal use; to create a database object, call one of the newDB methods of a federated database.

You should not use this constructor directly.

Method Detail

getSession

public Session getSession()
Gets the session in which this database was created or retrieved.

Returns:
The session in which this database was created or retrieved.

getDefaultContainer

public ooDefaultContObj getDefaultContainer()
Gets the default container of this database.

Returns:
The default container of this database.

getFileName

public String getFileName()
Gets the full pathname of this database's file.

Returns:
The full pathname of this database's file.

getHostName

public String getHostName()
Gets the name of the host on which this database's file is located.

Returns:
The name of the host on which this database's file is located.

getName

public String getName()
Gets the system name of this database.

Returns:
The system name of this database.

getContainerCount

public long getContainerCount()
Gets the number of containers in this database.

Returns:
The number of containers in this database.

getOid

public ooId getOid()
Gets the object identifier of this database.

Returns:
The object identifier of this database.

getPathName

public String getPathName()
Gets the full pathname of the directory where the database file is located.

Returns:
The full pathname of the directory where this database's file is located.

getFD

public ooFDObj getFD()
Gets the federated database that contains this database.

Returns:
The federated database that contains this database.

isDead

public boolean isDead()
Tests whether this database is dead.

A database is made dead when you delete it, abort the transaction in which the database was created, or terminate the session to which it belongs.

Returns:
True if this database is dead; otherwise, false.

delete

public void delete()
Deletes this database.

When you delete a database, all of its containers and basic objects will be deleted. Until the current transaction is committed, this database continues to exist in your application's memory, but it and all of its contained objects are marked dead.

Warning: This operation cannot be undone by aborting the transaction.

Throws:
ObjectIsDeadException - If an attempt is made to perform delete on a dead object.


lock

public void lock(int mode)
Locks this database and everything contained in it with the specified lock mode.

Parameters:
mode - The mode in which to lock this database; one of the following constants defined in the oo interface:
READ
Obtain a read lock.
WRITE
Obtain a write lock.

The lock mode is limited by the open mode of this database object's session. A session open mode of openReadWrite permits lock modes of WRITE or READ; a session open mode of openReadOnly only permits the lock mode READ.

If this database is already locked, you can call this method to upgrade a read lock to a write lock, but not to downgrade a write lock to a read lock.


flush

public void flush()
Transfers the data of all modified objects to this database cache.

After the successful execution of this method, the objects are no longer marked as modified.

This method makes the data of modified objects available to the process that calls the method, but does not make the changes permanent and available to other processes. When you commit or checkpoint the transaction, the changes become permanent.


cluster

public void cluster(Object object)
Makes the specified object persistent, clustering it in this database.

Parameters:
object - The transient object to be made persistent. The object to be clustered must be an instance of a persistence-capable class.

  • If object is a basic object, this method assigns it a storage location in the default container of this database.

  • If object is a container, this method adds it to this database as a hashed container with no system name, 5 initial pages, a hash value of 10, and a growth factor of 10%.

See Also:
addContainer(com.objy.db.app.ooContObj, java.lang.String, long, long, long)

nameObj

public void nameObj(Object object,
                    String scopeName)
Names the specified object in the scope of this database.

If the specified object is transient, this method makes it persistent. If the specified object is already persistent, this method locks it for write.

This method locks this database for write.

Parameters:
object - The object to be named.

scopeName - The name for the specified object in the scope of this database. This string must consist of only ASCII characters and must be unique within the name scope of this database.

See Also:
lookupObj(java.lang.String), unnameObj(java.lang.Object)

unnameObj

public void unnameObj(Object object)
Removes the specified object's name from the name scope of this database.

This method locks both this database and object for write.

Parameters:
object - The object whose name is to be removed.

Throws:
ObjyRuntimeException - If object has no name in the scope of this database.

See Also:
lookupObj(java.lang.String), nameObj(java.lang.Object, java.lang.String)

lookupObj

public Object lookupObj(String scopeName)
Retrieves the object with the specified scope name in the scope defined by this database.

Parameters:
scopeName - The scope name to look up.

Returns:
The object with the specified scope name in the scope of this database.

Throws:
ObjyRuntimeException - If there is no object named scopeName in the scope of this database.

See Also:
lookupObjName(java.lang.Object)

lookupObj

public Object lookupObj(String scopeName,
                        int lockMode)
Retrieves the object with the specified scope name in the scope defined by this database, locking the retrieved object as specified.

Parameters:
scopeName - The scope name to look up.

lockMode - The type of lock to obtain for the object; one of the following constants defined in the oo interface:
READ
Obtain a read lock.
WRITE
Obtain a write lock.

Returns:
The object with the specified scope name in the scope of this database; the returned object is locked as specified by lockMode.

Throws:
ObjyRuntimeException - If there is no object named scopeName in the scope of this database.

See Also:
lookupObjName(java.lang.Object)

lookupObjName

public String lookupObjName(Object object)
Looks up the name of the specified object in the scope defined by this database.

Parameters:
object - The object whose name is to be looked up.

Returns:
The scope name of the specified object in the name scope of this database.

Throws:
ObjyRuntimeException - If object has no name in the scope of this database.

See Also:
lookupObj(java.lang.String)

isAvailable

public boolean isAvailable()
(FTO/DRO) Tests whether this database is accessible by the current process.

(FTO) If the database is not replicated, it is accessible if the process can access its containing partition.

(DRO) If the database is replicated, it is accessible if the process can access a quorum of its images.

Returns:
True if this database is available; otherwise, false.

isReplicated

public boolean isReplicated()
(DRO) Tests whether there is more than one image of this database.

Returns:
True if there is more than one image of this database; otherwise, false.

getImageCount

public long getImageCount()
(DRO) Gets the number of images of this database.

Returns:
The number of images. For any existing database, there is always at least one image.

getTieBreaker

public ooAPObj getTieBreaker()
(DRO) Gets the tie-breaker autonomous partition of this database.

Returns:
The tie-breaker partition, or null if there is none.

See Also:
setTieBreaker(com.objy.db.app.ooAPObj)

setTieBreaker

public void setTieBreaker(ooAPObj partition)
(DRO) Sets the tie-breaker autonomous partition of this database.

Parameters:
partition - The tie-breaker autonomous partition. Any existing tie breaker for this database is eliminated if partition is null.

Throws:
ObjyRuntimeException - If partition already contains an image of this database.

See Also:
getTieBreaker()

changePartition

public void changePartition(ooAPObj partition)
(FTO) Changes the autonomous partition that contains this database.

The database is assigned to the partition partition and is removed from the current containing partition.

This method updates logical containment information in the catalogs of the autonomous partitions. If you also want to change the physical location of a database file, you must do so using the Objectivity/DB oochangedb tool.

You may not combine this operation with other updates to the database in the same transaction. You should consider executing changePartition in a separate transaction.

If the referenced database is read-only, you must use the setReadOnly method to change it back to read-write before you can change its partition.

(DRO) If multiple images of this database exist, the current containing partition will be left unchanged.

Parameters:
partition - The autonomous partition that is to contain the database.

getImageWeight

public long getImageWeight(ooAPObj partition)
(DRO) Gets the weight of the image of this database contained in the specified autonomous partition.

Parameters:
partition - The partition containing this database's image.

Returns:
The weight assigned to the image in the specified partition.

See Also:
setImageWeight(com.objy.db.app.ooAPObj, long)

getImagePathName

public String getImagePathName(ooAPObj partition)
(DRO) Gets the directory location of this database's image file contained in the specified autonomous partition.

Parameters:
partition - The autonomous partition containing this database's image.

Returns:
The full pathname of the directory where this database's image file is located.


getImageFileName

public String getImageFileName(ooAPObj partition)
(DRO) Gets the filename of this database's image contained in the specified autonomous partition.

Parameters:
partition - The autonomous partition containing this database's image.

Returns:
The filename of this database image.

getImageHostName

public String getImageHostName(ooAPObj partition)
(DRO) Gets the host location of this database's image file contained in the specified autonomous partition.

Parameters:
partition - The autonomous partition containing this database's image.

Returns:
The name of the host on which this database's image file is located.

setImageWeight

public void setImageWeight(ooAPObj partition,
                           long weight)
(DRO) Sets the weight of this database's image in the specified autonomous partition.

You cannot change the weight of an image of a read-only database. If this database is read-only, you must call the setReadOnly method to change it back to read-write before you can change the weight of an individual image.

Parameters:
partition - The partition containing the database image.

weight - The weight to assign to the image; the weight must be greater than 0.

See Also:
getImageWeight(com.objy.db.app.ooAPObj)

isImageAvailable

public boolean isImageAvailable(ooAPObj partition)
(DRO) Tests whether an image of this database in the specified autonomous partition is accessible by the current process.

Parameters:
partition - The autonomous partition to be checked for a database image.

Returns:
True if an image of this database in the specified autonomous partition is available; otherwise, false.

hasImageIn

public boolean hasImageIn(ooAPObj partition)
(DRO) Tests whether an image of this database exists in the specified autonomous partition.

Parameters:
partition - The specified autonomous partition.

Returns:
True if an image exists in the partition; otherwise, false.

deleteImage

public void deleteImage(ooAPObj partition)
(DRO) Deletes the image of this database contained in the specified autonomous partition.

If the specified partition contains the last image of this database, that image will not be deleted.

You cannot delete an image of a read-only database. If this database is read-only, you must call the setReadOnly method to change it back to read-write before you can delete an individual image.

Parameters:
partition - The autonomous partition containing the image.

deleteImage

public void deleteImage(ooAPObj partition,
                        boolean deleteDBifLast)
(DRO) Deletes the image of this database in the specified autonomous partition, possibly deleting the last image of this database.

If the specified partition contains the last image of this database and deleteDBifLast is true, that image and the database itself are deleted. If deleteDBifLast is false, the last image is not deleted.

You cannot delete an image of a read-only database. If this database is read-only, you must call the setReadOnly method to change it back to read-write before you can delete an individual image.

Parameters:
partition - The autonomous partition containing the image.

deleteDBifLast - True to delete the specified image even if it is the last image of this database; otherwise, false.

replicate

public void replicate(ooAPObj partition,
                      String hostName,
                      String pathName,
                      long weight)
(DRO) Creates an image of this database in the specified autonomous partition with the given weight.

You cannot create an image of a read-only database. If this database is read-only, you must call the setReadOnly method to change it back to read-write before you can create a new image.

Parameters:
partition - The partition in which this database's image will be created.

hostName - The host machine for the new image. If an empty string is provided, the host will be the same as that hosting the partition's system database file. The host machine must be running AMS.

pathName - The local directory path and name of the new image's file. If an empty string is provided, the image's file is created with a name based on this database's system name and is placed in the same directory as the partition's system database file.

weight - The weight of the new database image. The default is 1; the weight must be greater than 0.

Throws:
ObjyRuntimeException - If partition already contains an image of this database.

getContainingPartition

public ooAPObj getContainingPartition()
(FTO) Gets the autonomous partition which contains this database.

Returns:
If this database is not replicated, the autonomous partition containing the image; otherwise null.

containingImage

public Iterator containingImage()
(DRO) Initializes an iterator to find all the autonomous partitions in which this database has images.

Returns:
An iterator that finds all the autonomous partitions in which this database has images. When the iterator gets an autonomous partition, it does not open or lock the partition.

setNonQuorumReadAllowed

public void setNonQuorumReadAllowed(boolean allowed)
(DRO) Specifies whether this application can read this database if a quorum of images is not available.

Parameters:
allowed - True to allow this application to read this database even if a quorum of images is not available; false to prevent this application from reading this database when a quorum is not available.

By default, nonquorum reading is disabled for all databases. You must call this method explicitly to permit nonquorum reading for a particular database during a particular transaction. Nonquorum reading is automatically disabled at the end of the transaction in which this method is called.

Warning: If you enable nonquorum reading, your application may read stale data from this database.

See Also:
isNonQuorumReadAllowed(), isNonQuorumRead()

isNonQuorumReadAllowed

public boolean isNonQuorumReadAllowed()
(DRO) Tests whether this application can read this database even if a quorum of images is not available.

Returns:
True if nonquorum reads are allowed; otherwise, false.

See Also:
setNonQuorumReadAllowed(boolean), isNonQuorumRead()

negotiateQuorum

public void negotiateQuorum(int lockMode)
(DRO) Forces recalculation of the quorum for this database.

If this database has any images in previously unavailable partitions, this method adds those images back into the quorum for this database. The reacquired images are resynchronized--that is, they are updated to be consistent with the images in the quorum.

If your application includes a reinitialization procedure that is executed when an autonomous partition that was down is brought back up, that procedure should call this method for every database with an image in the restored autonomous partition.

This method performs no action if any of the following conditions is true:

You may not recalculate a quorum if nonquorum reading has been enabled for this database (see setNonQuorumReadAllowed). To recalculate a quorum in that case, you must end the current transaction (to disable nonquorum reading) and then call negotiateQuorum from within a new transaction.

Parameters:
lockMode - The type of lock to obtain for this database; one of the following constants defined in the oo interface:
READ
Obtain a read lock.
WRITE
Obtain a write lock.

isNonQuorumRead

public boolean isNonQuorumRead()
(DRO) Tests whether the application is currently reading this database without having access to a quorum of images.

Nonquorum reading of a database is possible only after an application has called this database's setNonQuorumReadAllowed method during the current transaction.

Returns:
True if the application is reading this database without having access to a quorum of images; otherwise, false.

Warning: If this method returns true, your application may be reading stale data from this database.


addContainer

public void addContainer(ooContObj container,
                         String name,
                         long hash,
                         long initialPages,
                         long growthFactor)
Adds the specified container with the specified system name, hash value, number of initial pages, and percent growth to this database.

This method makes the specified container persistent and locks it and this database in write mode.

Parameters:
container - The container to be added to this database.

name - The system name of the container. A valid system name follows the same rules as for naming files within the operating system. You can specify an empty string or null to create an unnamed container.

hash - Indicates whether the container being added should be a hashed container. If hash = 0, then a nonhashed container is added. Neither this container or any basic object it contains may be used as a scope when naming an object. If hash > 0, then a hashed container is added. The value of hash is used as a clustering factor (number of sequentially indexed objects to place into a page) when you add scope names to this container. If you do not care about the clustering factor, you should set the value of hash to 1.

initialPages - The initial number of pages allocated for the container.

growthFactor - The percentage by which the container should grow when needed to accommodate more basic objects.

Throws:
ObjyRuntimeException - If this database already has a container named name. You can call hasContainer to test whether a container with the name name exists in this database.

hasContainer

public boolean hasContainer(String name)
Tests whether the container with the specified system name exists in this database.

Parameters:
name - The system name of the container.

Returns:
True if the container with the system name name exists in this database; otherwise false.

lookupContainer

public ooContObj lookupContainer(String name)
Retrieves the container with the specified system name in this database.

Parameters:
name - The system name of the container.

Returns:
The specified container.

Throws:
ObjectNotFoundException - If this database does not have a container with the specified system name.

LockNotGrantedException - If a lock for the container with the specified system name could not be obtained.

scan

public Iterator scan(String className)
Initializes an iterator to scan this database for objects of the specified class.

Parameters:
className - The package-qualified name of the class of the desired objects.

Returns:
An iterator that finds the specified objects.

scan

public Iterator scan(String className,
                     String predicate)
Initializes an iterator to scan this database for objects of the specified class that satisfy the specified predicate.

If predicate-scan autoflush is enabled for the connection object, this method will flush any modified objects to the federated database before performing the scan. Otherwise, the result of the scan may contain out-of-date information.

Parameters:
className - The package-qualified name of the class of the desired objects.

predicate - The condition that each retrieved object must satisfy, expressed in the Objectivity/DB predicate query language.

Returns:
An iterator that finds the specified objects.

See Also:
Connection.setPredicateScanAutoFlush(boolean), Connection.isPredicateScanAutoFlush()

scan

public Iterator scan(String className,
                     String predicate,
                     int access)
Deprecated. Use scan(String, String).


contains

public Iterator contains()
Initializes an iterator to find all the containers in this database.

Returns:
An iterator that finds all the containers in this database.

contains

public Iterator contains(int filter)
(DRO) Initializes an iterator to find the containers contained in this database that satisfy the specified filter.

Parameters:
filter - Specifies which containers should be accessed through the iterator. One of the following constants defined in the oo interface:
ALL_CONTAINERS
Initializes the iterator with all containers contained in this database.
NOT_TRANSFERRED
Initializes the iterator with containers that have the same controlling autonomous partition as this database.
TRANSFERRED
Initializes the iterator with those containers that have a different controlling autonomous partition than this database.

Returns:
An iterator that finds the specified containers.

bind

public void bind(Object object,
                 String name)
          throws ObjectNameNotUniqueException
Names the specified object with the specified root name in this database.

Giving an object a root name makes the object persistent. The named object is made persistent immediately; all transient objects reachable from the named object are made persistent on transaction commit.

Parameters:
object - The object being named.

name - The root name for the object. This string must consist of only ASCII characters and must be unique within the root dictionary of this database.

Throws:
ObjectNameNotUniqueException - If the name already exists in the root dictionary.

See Also:
unbind(java.lang.String)

lookup

public Object lookup(String name)
              throws ObjectNameNotFoundException
Retrieves the object with the specified root name in this database.

Parameters:
name - The root name of the object.

Returns:
The object with the specified root name. If this object is the root of a graph of objects, only the root object is returned.

Throws:
ObjectNameNotFoundException - If the name doesn't exist in the root dictionary.

rootNames

public Iterator rootNames()
Initializes an iterator to find the root names maintained by this database.

Returns:
An iterator initialized to return all the root names maintained by this database.

unbind

public void unbind(String name)
            throws ObjectNameNotFoundException
Removes a root name from this database.

Parameters:
name - The root name to be removed.

Throws:
ObjectNameNotFoundException - If the name doesn't exist in the root dictionary.

See Also:
bind(java.lang.Object, java.lang.String)

addIndex

public void addIndex(String name,
                     String className,
                     String fieldList)
Adds an index to this database.

Parameters:
name - The name of the index to be added; must be different from the names of existing indexes in this database. You can call hasIndex to test whether an index with the specified name exists.

fieldList - The key fields for the index, separated by commas. Each key field must be the name of a valid persistent field of className whose type is one of the Java types supported by indexes.

Throws:
ObjyRuntimeException - If Objectivity/DB is unable to create the index.

See Also:
addUniqueIndex(java.lang.String, java.lang.String, java.lang.String), dropIndex(java.lang.String)

addUniqueIndex

public void addUniqueIndex(String name,
                           String className,
                           String fieldList)
Adds a unique index to this database.

The application is responsible for ensuring that every object indexed by a unique index has a unique combination of values in its key fields. If two or more objects have a given combination of key values, the index will contain only the first such object that is encountered when the index is created or updated.

Parameters:
name - The name of the index to be added; must be different from the names of existing indexes in this database. You can call hasIndex to test whether an index with the specified name exists.

className - The package-qualified name of the class whose instances are to be indexed.

fieldList - The key fields for the index, separated by commas. Each key field must be the name of a valid persistent field of className whose type is one of the Java types supported by indexes.

Throws:
ObjyRuntimeException - If Objectivity/DB is unable to create the index.

See Also:
addIndex(java.lang.String, java.lang.String, java.lang.String), dropIndex(java.lang.String)

dropIndex

public void dropIndex(String name)
Drops the specified index from this database.

Parameters:
name - The name of the index to be dropped.

Throws:
ObjyRuntimeException - If this database does not have an index named name. You can call hasIndex to test whether an index with the specified name exists.

See Also:
addIndex(java.lang.String, java.lang.String, java.lang.String), addUniqueIndex(java.lang.String, java.lang.String, java.lang.String), hasIndex(java.lang.String)

hasIndex

public boolean hasIndex(String name)
Tests whether this database has an index with the specified name.

Parameters:
name - The name of the index.

Returns:
True if this database has an index named name; otherwise, false.

See Also:
addIndex(java.lang.String, java.lang.String, java.lang.String), addUniqueIndex(java.lang.String, java.lang.String, java.lang.String), dropIndex(java.lang.String)

convertObjects

public void convertObjects()
Converts all basic objects in this database to be consistent with their current Java class definitions.

You can call this method if the definitions of some Java classes are not consistent with the corresponding descriptions in the schema. Certain changes to a class definition affect how instances of a class should be laid out in storage. After you make such a change, existing persistent objects of the changed classes are rendered out-of-date until they are converted to their new representations.

In general, you can allow each affected object to be converted automatically the first time it is accessed after the class description in the schema is changed. Such automatic conversion may distribute the performance impact of conversion across many transactions. Alternatively, you can concentrate the performance impact of conversion into fewer transactions by converting all the affected objects in a container, a database, or the federated database on demand. You call this method in an update transaction to convert the affected objects in this database on demand. This method takes no action if the affected objects in the database have already been converted.

The convertObjects method automatically drops any index that is invalidated by a schema evolution change. Specifically, if you changed the type or deleted a field that is a key field of an index that index is dropped.

If the referenced database is read-only, you must call the setReadOnly method to change it back to read-write before you can convert objects in it.


isReadOnly

public boolean isReadOnly()
Tests whether this database is read only.

A read-only database can be opened only for read; any attempt to open the database for write (implicitly or explicitly) will fail as if there were a lock conflict.

Returns:
True if this database is a read-only database; otherwise, false.

See Also:
setReadOnly(boolean)

setReadOnly

public void setReadOnly(boolean value)
Set the access status of this database so that is is either read-only or read-write.

A read-only database can be opened only for read; any attempt to open the database for write (implicitly or explicitly) will fail as if there were a lock conflict. Using a read-only database can improve performance by allowing the application to grant read locks and deny update locks without consulting the lock server.

You can change a read-only database back to read-write only if no application or tool is currently reading either that database or any other read-only database in the same federated database. You must change the database back to read-write before you can perform any other operation on it.

(DRO) If one image of a database is made read-only, all images are automatically made read-only. Similarly, if one image is changed back to read-write, all images are changed back to read-write.

Parameters:
value - True to mark this database as read-only; false to change the database back to read-write.

See Also:
isReadOnly()

setPersistor

public void setPersistor(PooDBObj persistor)
Reserved for internal use; you should not call this method.


connectionId

public long connectionId()
Reserved for internal use; you should not call this method.


Objectivity for Java Reference

Copyright © 2000 Objectivity, Inc. All rights reserved.