站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 2.1.8 正式版 API 英文文档

Database (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate.odmg
Class Database

java.lang.Object
  extended bynet.sf.hibernate.odmg.Database
All Implemented Interfaces:
org.odmg.Database

public class Database
extends Object
implements org.odmg.Database

Implements the ODMG Database API. This provides operations for persisting and deleteing objects, binding names to objects and looking up objects by name.

Applications may create an instance by calling Implementation.newDatabase() or by instantiating this class directly. The application should then call open() to associate it with an existing Hibernate SessionFactory.

Instances maintain an association between Threads and Transactions.

See Also:
Implementation, Transaction

Field Summary
 
Fields inherited from interface org.odmg.Database
NOT_OPEN, OPEN_EXCLUSIVE, OPEN_READ_ONLY, OPEN_READ_WRITE
 
Constructor Summary
Database()
          Instantiate
 
Method Summary
 void bind(Object object, String name)
          Bind a name to a persistent object, making the object persistent if necessary.
 void close()
          Close the Database (but not the underlying SessionFactory).
 Transaction currentTransaction()
          Get the Transaction associatedm with the current thread.
 void deletePersistent(Object object)
          Delete the given object from the database.
 Session getSession()
          Get the Session underlying the Transaction associated with the current thread.
 SessionFactory getSessionFactory()
          Get the SessionFactory underlying this Database.
 Object lookup(String name)
          Retrieve the persistent object bound to the given name.
 void makePersistent(Object object)
          Make the given object persistent.
 void open(SessionFactory factory)
          Specify the underlying SessionFactory.
 void open(String name, int accessMode)
          Specify the underlying SessionFactory, by passing a JNDI name.
 void unbind(String name)
          Unbind the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Database

public Database()
Instantiate

Method Detail

open

public void open(SessionFactory factory)
Specify the underlying SessionFactory. This method is not exposed by the ODMG API but is needed when no JNDI server is available.


getSession

public Session getSession()
Get the Session underlying the Transaction associated with the current thread.


getSessionFactory

public SessionFactory getSessionFactory()
Get the SessionFactory underlying this Database.


currentTransaction

public Transaction currentTransaction()
Get the Transaction associatedm with the current thread.


open

public void open(String name,
                 int accessMode)
          throws org.odmg.ODMGException
Specify the underlying SessionFactory, by passing a JNDI name. The accessMode is ignored by Hibernate.

Specified by:
open in interface org.odmg.Database
Throws:
org.odmg.ODMGException
See Also:
Database.open(String, int)

close

public void close()
           throws org.odmg.ODMGException
Close the Database (but not the underlying SessionFactory).

Specified by:
close in interface org.odmg.Database
Throws:
org.odmg.ODMGException
See Also:
Database.close()

bind

public void bind(Object object,
                 String name)
          throws org.odmg.ObjectNameNotUniqueException
Bind a name to a persistent object, making the object persistent if necessary.

Specified by:
bind in interface org.odmg.Database
Throws:
org.odmg.ObjectNameNotUniqueException
See Also:
Database.bind(Object, String)

lookup

public Object lookup(String name)
              throws org.odmg.ObjectNameNotFoundException
Retrieve the persistent object bound to the given name.

Specified by:
lookup in interface org.odmg.Database
Throws:
org.odmg.ObjectNameNotFoundException
See Also:
Database.lookup(String)

unbind

public void unbind(String name)
            throws org.odmg.ObjectNameNotFoundException
Unbind the given name.

Specified by:
unbind in interface org.odmg.Database
Throws:
org.odmg.ObjectNameNotFoundException
See Also:
Database.unbind(String)

makePersistent

public void makePersistent(Object object)
Make the given object persistent.

Specified by:
makePersistent in interface org.odmg.Database
See Also:
Database.makePersistent(Object)

deletePersistent

public void deletePersistent(Object object)
Delete the given object from the database.

Specified by:
deletePersistent in interface org.odmg.Database
See Also:
Database.deletePersistent(Object)