net.sf.cantina.datasource
Class HibernateDataSource

java.lang.Object
  extended bynet.sf.cantina.DataSource
      extended bynet.sf.cantina.datasource.HibernateDataSource
Direct Known Subclasses:
HypersonicDataSource, UserDefinedDataSource

public abstract class HibernateDataSource
extends DataSource

This class configures hibernate and provides access to sessions.

Author:
Stephane JAIS

Field Summary
 
Fields inherited from class net.sf.cantina.DataSource
instance
 
Constructor Summary
HibernateDataSource()
           
 
Method Summary
 void closeSession()
          Close the hibernate (SQL) connection.
abstract  void closeSessionFactory()
           
 void createDocument(java.lang.String documentId)
           
 void createRealm(java.lang.String name)
           
 java.util.Collection findAllRealms()
           
 net.sf.hibernate.Session getSession()
          Gets/create the hibernate session.
abstract  net.sf.hibernate.SessionFactory getSessionFactory()
           
protected abstract  java.lang.ThreadLocal getThreadLocalSession()
          The hibernate session is stored in a ThreadLocal.
 java.lang.Object load(java.lang.String id, java.lang.Class clazz)
           
 Document loadDocument(java.lang.String documentId)
           
 Realm loadRealm(java.lang.String name)
           
 void release()
          Releases all the hibernate resources.
 void removeDocument(java.lang.String documentId)
           
 void removeRealm(java.lang.String name)
           
 void saveDocument(Document d)
           
 void saveRealm(Realm r)
           
 java.util.Collection selectAllDocumentIds()
           
 
Methods inherited from class net.sf.cantina.DataSource
getInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateDataSource

public HibernateDataSource()
Method Detail

getSessionFactory

public abstract net.sf.hibernate.SessionFactory getSessionFactory()

closeSessionFactory

public abstract void closeSessionFactory()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

getThreadLocalSession

protected abstract java.lang.ThreadLocal getThreadLocalSession()
The hibernate session is stored in a ThreadLocal.


getSession

public net.sf.hibernate.Session getSession()
                                    throws net.sf.hibernate.HibernateException
Gets/create the hibernate session.

Throws:
net.sf.hibernate.HibernateException
See Also:
closeSession()

closeSession

public void closeSession()
Close the hibernate (SQL) connection.

Specified by:
closeSession in class DataSource
See Also:
getSession()

release

public void release()
Releases all the hibernate resources.

Specified by:
release in class DataSource

load

public java.lang.Object load(java.lang.String id,
                             java.lang.Class clazz)
                      throws java.lang.Exception
Throws:
java.lang.Exception

createDocument

public void createDocument(java.lang.String documentId)
                    throws DuplicateKeyException,
                           java.lang.Exception
Specified by:
createDocument in class DataSource
Throws:
DuplicateKeyException
java.lang.Exception

loadDocument

public Document loadDocument(java.lang.String documentId)
                      throws java.lang.Exception
Specified by:
loadDocument in class DataSource
Throws:
java.lang.Exception

saveDocument

public void saveDocument(Document d)
                  throws java.lang.Exception
Specified by:
saveDocument in class DataSource
Throws:
java.lang.Exception

removeDocument

public void removeDocument(java.lang.String documentId)
                    throws java.lang.Exception
Specified by:
removeDocument in class DataSource
Throws:
java.lang.Exception

loadRealm

public Realm loadRealm(java.lang.String name)
                throws ObjectNotFoundException,
                       java.lang.Exception
Specified by:
loadRealm in class DataSource
Throws:
ObjectNotFoundException
java.lang.Exception

saveRealm

public void saveRealm(Realm r)
               throws java.lang.Exception
Specified by:
saveRealm in class DataSource
Throws:
java.lang.Exception

createRealm

public void createRealm(java.lang.String name)
                 throws java.lang.Exception
Specified by:
createRealm in class DataSource
Throws:
java.lang.Exception

removeRealm

public void removeRealm(java.lang.String name)
                 throws java.lang.Exception
Specified by:
removeRealm in class DataSource
Throws:
java.lang.Exception

findAllRealms

public java.util.Collection findAllRealms()
                                   throws java.lang.Exception
Specified by:
findAllRealms in class DataSource
Throws:
java.lang.Exception

selectAllDocumentIds

public java.util.Collection selectAllDocumentIds()
                                          throws java.lang.Exception
Specified by:
selectAllDocumentIds in class DataSource
Throws:
java.lang.Exception


Copyright © 2004 Cantina. All Rights Reserved.