org.apache.ojb.odmg
Class DatabaseImpl

java.lang.Object
  extended by org.apache.ojb.odmg.DatabaseImpl
All Implemented Interfaces:
Database

public class DatabaseImpl
extends java.lang.Object
implements Database

Implementation class of the Database interface.

Version:
$Id: DatabaseImpl.java 365232 2005-12-21 22:36:07Z tomdz $
Author:
Thomas Mahler, Matthew Baird, Armin Waibel

Field Summary
 
Fields inherited from interface org.odmg.Database
NOT_OPEN, OPEN_EXCLUSIVE, OPEN_READ_ONLY, OPEN_READ_WRITE
 
Constructor Summary
DatabaseImpl(ImplementationImpl ojb)
           
 
Method Summary
 void bind(java.lang.Object object, java.lang.String name)
          Associate a name with an object and make it persistent.
 void close()
          Close the database.
 void deletePersistent(java.lang.Object object)
          Deletes an object from the database.
 PBKey getPBKey()
          Return the PBKey associated with this Database.
 boolean isOpen()
           
 java.lang.Object lookup(java.lang.String name)
          Lookup an object via its name.
 void makePersistent(java.lang.Object object)
          Make a transient object durable in the database.
 void open(java.lang.String name, int accessMode)
          Open the named database with the specified access mode.
 void unbind(java.lang.String name)
          Disassociate a name with an object
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseImpl

public DatabaseImpl(ImplementationImpl ojb)
Method Detail

getPBKey

public PBKey getPBKey()
Return the PBKey associated with this Database.


isOpen

public boolean isOpen()

open

public void open(java.lang.String name,
                 int accessMode)
          throws ODMGException
Open the named database with the specified access mode. Attempts to open a database when it has already been opened will result in the throwing of the exception DatabaseOpenException. A DatabaseNotFoundException is thrown if the database does not exist. Some implementations may throw additional exceptions that are also derived from ODMGException.

Specified by:
open in interface Database
Parameters:
name - The name of the database.
accessMode - The access mode, which should be one of the static fields: OPEN_READ_ONLY, OPEN_READ_WRITE, or OPEN_EXCLUSIVE.
Throws:
ODMGException - The database could not be opened.

close

public void close()
           throws ODMGException
Close the database. After you have closed a database, further attempts to access objects in the database will cause the exception DatabaseClosedException to be thrown. Some implementations may throw additional exceptions that are also derived from ODMGException.

Specified by:
close in interface Database
Throws:
ODMGException - Unable to close the database.

bind

public void bind(java.lang.Object object,
                 java.lang.String name)
          throws ObjectNameNotUniqueException
Associate a name with an object and make it persistent. An object instance may be bound to more than one name. Binding a previously transient object to a name makes that object persistent.

Specified by:
bind in interface Database
Parameters:
object - The object to be named.
name - The name to be given to the object.
Throws:
ObjectNameNotUniqueException - If an attempt is made to bind a name to an object and that name is already bound to an object.

lookup

public java.lang.Object lookup(java.lang.String name)
                        throws ObjectNameNotFoundException
Lookup an object via its name.

Specified by:
lookup in interface Database
Parameters:
name - The name of an object.
Returns:
The object with that name.
Throws:
ObjectNameNotFoundException - There is no object with the specified name. ObjectNameNotFoundException
See Also:
ObjectNameNotFoundException

unbind

public void unbind(java.lang.String name)
            throws ObjectNameNotFoundException
Disassociate a name with an object

Specified by:
unbind in interface Database
Parameters:
name - The name of an object.
Throws:
ObjectNameNotFoundException - No object exists in the database with that name.

makePersistent

public void makePersistent(java.lang.Object object)
Make a transient object durable in the database. It must be executed in the context of an open transaction. If the transaction in which this method is executed commits, then the object is made durable. If the transaction aborts, then the makePersistent operation is considered not to have been executed, and the target object is again transient. ClassNotPersistenceCapableException is thrown if the implementation cannot make the object persistent because of the type of the object.

Specified by:
makePersistent in interface Database
Parameters:
object - The object to make persistent.
Throws:
TransactionNotInProgressException - if there is no current transaction.

deletePersistent

public void deletePersistent(java.lang.Object object)
Deletes an object from the database. It must be executed in the context of an open transaction. If the object is not persistent, then ObjectNotPersistent is thrown. If the transaction in which this method is executed commits, then the object is removed from the database. If the transaction aborts, then the deletePersistent operation is considered not to have been executed, and the target object is again in the database.

Specified by:
deletePersistent in interface Database
Parameters:
object - The object to delete.


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30