org.mycore.backend.hibernate
Class MCRHIBConnection

java.lang.Object
  extended by org.mycore.backend.hibernate.MCRHIBConnection
All Implemented Interfaces:
MCRSessionListener, MCRShutdownHandler.Closeable

public class MCRHIBConnection
extends Object
implements MCRShutdownHandler.Closeable, MCRSessionListener

Class for hibernate connection to selected database

Author:
Thomas Scheffler (yagee)

Field Summary
(package private) static org.hibernate.cfg.Configuration HIBCFG
           
(package private) static org.hibernate.SessionFactory SESSION_FACTORY
           
(package private) static MCRHIBConnection SINGLETON
           
 
Constructor Summary
protected MCRHIBConnection()
          This method initializes the connection to the database
 
Method Summary
 Element addStringArray(Element base, String tagName, String attrName, String[] values)
           
static void buildSessionFactory(org.hibernate.cfg.Configuration config)
           
 void close()
          cleanly closes this object that implements Closeable.
 boolean containsMapping(String tablename)
          This method checks existance of mapping for given sql-tablename
protected  void finalize()
           
 org.hibernate.cfg.Configuration getConfiguration()
           
 org.hibernate.type.Type getHibType(String type)
          helper mehtod: translates fieldtypes into hibernate types
 org.hibernate.Query getNamedQuery(String name)
          returns the named query from the hibernate mapping.
 org.hibernate.Session getSession()
          This method returns the current session for queries on the database through hibernate
 org.hibernate.SessionFactory getSessionFactory()
           
 void handleStatistics(org.hibernate.stat.Statistics stats)
           
static MCRHIBConnection instance()
           
 void sessionEvent(MCRSessionEvent event)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HIBCFG

static org.hibernate.cfg.Configuration HIBCFG

SESSION_FACTORY

static org.hibernate.SessionFactory SESSION_FACTORY

SINGLETON

static MCRHIBConnection SINGLETON
Constructor Detail

MCRHIBConnection

protected MCRHIBConnection()
                    throws MCRPersistenceException
This method initializes the connection to the database

Throws:
MCRPersistenceException
Method Detail

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

instance

public static MCRHIBConnection instance()
                                 throws MCRPersistenceException
Throws:
MCRPersistenceException

buildSessionFactory

public static void buildSessionFactory(org.hibernate.cfg.Configuration config)

getSession

public org.hibernate.Session getSession()
This method returns the current session for queries on the database through hibernate

Returns:
Session current session object

getConfiguration

public org.hibernate.cfg.Configuration getConfiguration()

containsMapping

public boolean containsMapping(String tablename)
This method checks existance of mapping for given sql-tablename

Parameters:
tablename - sql-table name as string
Returns:
boolean

getHibType

public org.hibernate.type.Type getHibType(String type)
helper mehtod: translates fieldtypes into hibernate types

Parameters:
type - typename as string
Returns:
hibernate type

close

public void close()
Description copied from interface: MCRShutdownHandler.Closeable
cleanly closes this object that implements Closeable. You can provide some functionality to close open files and sockets or so.

Specified by:
close in interface MCRShutdownHandler.Closeable

handleStatistics

public void handleStatistics(org.hibernate.stat.Statistics stats)
                      throws FileNotFoundException,
                             IOException
Throws:
FileNotFoundException
IOException

addStringArray

public Element addStringArray(Element base,
                              String tagName,
                              String attrName,
                              String[] values)

getSessionFactory

public org.hibernate.SessionFactory getSessionFactory()

sessionEvent

public void sessionEvent(MCRSessionEvent event)
Specified by:
sessionEvent in interface MCRSessionListener

getNamedQuery

public org.hibernate.Query getNamedQuery(String name)
returns the named query from the hibernate mapping. if a query with name name.<DBDialect> exists it takes precedence over a query named name

Parameters:
name -
Returns:
Query defined in mapping