palio.connectors
Class HibernateConnector

java.lang.Object
  extended by palio.connectors.Connector
      extended by palio.connectors.PooledConnector
          extended by palio.connectors.SQLConnector
              extended by palio.connectors.HibernateConnector
All Implemented Interfaces:
DedicatedConnectionSupport, HibernateConnectable, SQLConnectable, SQLConnectableExt

Deprecated. Replaced by HibernateConnector

@Deprecated
public class HibernateConnector
extends SQLConnector
implements HibernateConnectable

Konfiguracja konektora hibernate'a.
Są dwa sposoby konfiguracji konektora Hibernate:

Konektor wspiera oba sposoby.


I. Mapowanie adnotacjami.

Wpis konektora w pliku instancji powinien zawierać następujące ustawienia:

Przykład wpisu konfiguracyjnego konektora w pliku instancji:
    <connector name="hibernate" url="jdbc:postgresql://localhost:5432/dbname" class="HibernateConnector">
                 <mappingMethod>annotation</mappingMethod>
                 <configFile>/opt/jpalio/instances/lechpol_hibernate.cfg.xml</configFile>
                 <user>db_user</user>
                 <password>db_password</password>
                 <driver>org.postgresql.Driver</driver>
                 <hibernateLoggerLevel>ERROR</hibernateLoggerLevel>
                 <mapClasses>
                   lechpol.model.Address;
                   lechpol.model.BankAccount;
                   lechpol.model.Client;
                   lechpol.model.Config;
                   lechpol.model.Department;
                   lechpol.model.Employee;
                   lechpol.model.Material;
                   lechpol.model.MaterialGroup;
                   lechpol.model.MaterialStorage;
                   lechpol.model.Model
                 </mapClasses>
         </connector>
 

Przykład pliku konfiguracyjnego Hibernate:
 <?xml version='1.0' encoding='utf-8'?>
 <!DOCTYPE hibernate-configuration PUBLIC
         "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 <hibernate-configuration>
     <session-factory>
         <!-- Database connection settings -->
         <property name="connection.driver_class">org.postgresql.Driver</property>
         <property name="connection.url">jdbc:postgresql://localhost:5432/dbname</property>
         <property name="connection.username">db_user</property>
         <property name="connection.password">db_password</property>
 
         <!-- Use the C3P0 connection pool. -->
         <property name="c3p0.min_size">3</property>
         <property name="c3p0.max_size">10</property>
         <property name="c3p0.timeout">1800</property>
 
         <!-- Disable second-level cache. -->
         <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
         <property name="cache.use_query_cache">false</property>
         <property name="cache.use_minimal_puts">false</property>
         <property name="max_fetch_depth">3</property>
 
         <!-- JDBC connection pool (use the built-in) -->
         <!-- <property name="connection.pool_size">1</property> -->
 
         <!-- SQL dialect -->
         <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
 
         <!-- Enable Hibernate's automatic session context management -->
         <!-- Bind the getCurrentSession() method to the thread. -->
         <property name="current_session_context_class">thread</property>
 
         <!-- <property name="hibernate.show_sql">true</property> -->
 
         <property name="hibernate.hbm2ddl.auto">update</property>
     </session-factory>
 </hibernate-configuration>
 


II. Mapowanie standardowe.

Wpis konektora w pliku instancji powinien zawierać następujące ustawienia:

Przykłady użycia znajdują się powyżej

Author:
Michał Kłujszo (mklujszo@torn.com.pl), Grzegorz Tymiński (mailto:gtyminski@torn.com.pl)

Nested Class Summary
 
Nested classes/interfaces inherited from interface palio.connectors.SQLConnectable
SQLConnectable.QueryReader
 
Field Summary
static java.util.Map<Instance,org.apache.log4j.Logger> loggers
          Deprecated. Mapa instancji logera Hibernate.
 
Fields inherited from interface palio.connectors.SQLConnectable
DB2, GENERIC, HIBERNATE, HSQL, MSSQL, MYSQL, ORACLE, PALIO, POSTGRESQL, SYBASE
 
Constructor Summary
HibernateConnector(java.lang.String url, java.util.Properties properties)
          Deprecated.  
 
Method Summary
static org.hibernate.Session getCurrentSession()
          Deprecated. Zwraca aktualną sesję połączenia, jeżeli jest skonfigurowane.
 java.lang.Long getSequence(java.lang.String sequenceName)
          Deprecated.  
 org.hibernate.Session getSession()
          Deprecated. Zwraca sesję połączenia z bazą danych.
 org.hibernate.Session getSession(org.hibernate.EntityMode entityMode)
          Deprecated.  
 org.hibernate.SessionFactory getSessionFactory()
          Deprecated.  
 int getType()
          Deprecated.  
 void init()
          Deprecated.  
 boolean needWriteLob()
          Deprecated.  
static org.hibernate.Session openSession()
          Deprecated.  
 void putSession(org.hibernate.Session session)
          Deprecated.  
 
Methods inherited from class palio.connectors.SQLConnector
commit, debugInit, debugSave, dedicatedCommit, dedicatedRollback, dedicatedStart, dedicatedStop, executeFunction, executePL_SQL, executeProcedure, fastRead, getConnectorTypes, getInfo, getMetaData, getOutTypeParamForClass, getResultSet, getResultSetMetaData, info, isNoTransaction, isTransaction, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, readAsMaps, readAsMaps, readAsMaps, readAsMaps, readAsMaps, readAsMaps, readAsMaps, readLine, readLine, readLine, readLineAsMap, readLineAsMap, readLineAsMap, rollback, transactionStart, transactionStop, write, write, write, writeLob, writeLob
 
Methods inherited from class palio.connectors.PooledConnector
BusyChecker, clearThreadResources, close, DedicateChecker, FreeChecker, refresh
 
Methods inherited from class palio.connectors.Connector
getConnector, getInstance, getName, getUrl, init, setDedicatedLogConfiguration, setInstance
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface palio.connectors.SQLConnectable
getName, getUrl
 

Field Detail

loggers

public static java.util.Map<Instance,org.apache.log4j.Logger> loggers
Deprecated. 
Mapa instancji logera Hibernate.

Constructor Detail

HibernateConnector

public HibernateConnector(java.lang.String url,
                          java.util.Properties properties)
Deprecated. 
Method Detail

getCurrentSession

public static org.hibernate.Session getCurrentSession()
                                               throws palio.PalioException
Deprecated. 
Zwraca aktualną sesję połączenia, jeżeli jest skonfigurowane.

Returns:
Aktualna sesja połączenia z bazą danych lub null, jeżeli wowłano metodę spoza działania instancji - Current.getInstance() zwróci null.
Throws:
palio.PalioException - Konektor nie został skonfigurowany.

init

public void init()
          throws palio.PalioException
Deprecated. 
Overrides:
init in class SQLConnector
Throws:
palio.PalioException

getSessionFactory

public org.hibernate.SessionFactory getSessionFactory()
Deprecated. 
Specified by:
getSessionFactory in interface HibernateConnectable
Returns:
Obiekt konfigurujący sesje/pule połączeń z bazą danych.

getSequence

public java.lang.Long getSequence(java.lang.String sequenceName)
                           throws palio.PalioException
Deprecated. 
Specified by:
getSequence in interface SQLConnectable
Throws:
palio.PalioException

openSession

public static org.hibernate.Session openSession()
Deprecated. 

getSession

public org.hibernate.Session getSession()
                                 throws palio.PalioException
Deprecated. 
Description copied from interface: HibernateConnectable
Zwraca sesję połączenia z bazą danych.

Specified by:
getSession in interface HibernateConnectable
Returns:
Sesja Hibernate'owa
Throws:
palio.PalioException - Wystąpił problem z połączenie do bazy, lub nie można otworzyć sesji.

getSession

public org.hibernate.Session getSession(org.hibernate.EntityMode entityMode)
                                 throws palio.PalioException
Deprecated. 
Specified by:
getSession in interface HibernateConnectable
Returns:
Hibernate session with special etity mapping mode
Throws:
palio.PalioException

putSession

public void putSession(org.hibernate.Session session)
Deprecated. 
Specified by:
putSession in interface HibernateConnectable
Parameters:
session - Sesja połączenia z DB.

getType

public int getType()
Deprecated. 
Specified by:
getType in interface SQLConnectable

needWriteLob

public boolean needWriteLob()
Deprecated. 
Specified by:
needWriteLob in interface SQLConnectable