public class HB
extends java.lang.Object
Session
and transaction with helper methods. Configuration is read from server.properties file. Value of property hibernate.provider specifies actual implementation. Methods hiding Session
and transaction object initialization are used by HibernateDataSource
: getEntityManager
returnEntityManager
getTransaction
commitTransaction
rollbackTransaction
Modifier and Type | Field and Description |
---|---|
static java.lang.String | CONFIG_LOOKUP_STYLE Name of sub property for hibernate configuration lookup style. |
static java.lang.String | DEFAULT_HB_PROVIDER Default Hibernate provider class name. |
static java.lang.String | DEFAULT_SPRING_HB_PROVIDER Default Spring Hibernate provider class name. |
static java.lang.String | HB_PREFIX Name of prefix for hibernate provider block. |
static java.lang.String | HB_PROVIDER Name of property for JPA EMF provider implementation. |
static java.lang.String | LOOKUP_STYLE_SPRING Lookup style value specifying Spring usage. |
static java.lang.String | PROVIDER Name of sub property for hibernate provider implementation. |
static java.lang.String | TRANSACTION_ATTR Attribute name for RPCManager. |
Modifier and Type | Method and Description |
---|---|
static void | commitTransaction(java.lang.String configName, Transaction tx) Commits specified transaction. |
static void | commitTransaction(Transaction tx) Commits specified transaction. |
static SessionFactory | get() Returns SessionFactory . |
static SessionFactory | get(java.lang.String configName) Returns SessionFactory . |
static Session | getSession() Returns Session for persistence operations. |
static Session | getSession(java.lang.String configName) Returns Session for persistence operations. |
static Transaction | getTransaction(Session session) Returns started transaction. |
static Transaction | getTransaction(java.lang.String configName, Session session) Returns started transaction. |
static void | returnSession(Session session) Closes Session . |
static void | returnSession(java.lang.String configName, Session session) Closes Session . |
static void | rollbackTransaction(java.lang.String configName, Transaction tx) Rolls back specified transaction. |
static void | rollbackTransaction(Transaction tx) Rolls back specified transaction. |
public static final java.lang.String HB_PREFIX
public static final java.lang.String PROVIDER
public static final java.lang.String CONFIG_LOOKUP_STYLE
public static final java.lang.String LOOKUP_STYLE_SPRING
public static final java.lang.String DEFAULT_HB_PROVIDER
public static final java.lang.String DEFAULT_SPRING_HB_PROVIDER
public static final java.lang.String HB_PROVIDER
public static final java.lang.String TRANSACTION_ATTR
public static SessionFactory get()
SessionFactory
. Using default configuration.SessionFactory
or null.public static SessionFactory get(java.lang.String configName)
SessionFactory
.configName
- String
configuration name. Default provider is used if null
or empty string is passed.SessionFactory
or null.public static Session getSession() throws HibernateException
Session
for persistence operations. Using default configuration.Session
for persistence operations.HibernateException
- if unable to acquire Session
.public static Session getSession(java.lang.String configName) throws HibernateException
Session
for persistence operations.configName
- String
configuration name. Default provider is used if null
or empty string is passed.Session
for persistence operations.HibernateException
- if unable to acquire Session
.public static void returnSession(Session session)
Session
. Using default configuration.session
- Session
which should be closed.public static void returnSession(java.lang.String configName, Session session)
Session
.configName
- String
configuration name. Default provider is used if null
or empty string is passed.session
- Session
which should be closed.public static Transaction getTransaction(Session session) throws HibernateException
session
- Session
needed if joining to existing transaction or starting transaction locally.Transaction
Already started transaction for persistence operations.HibernateException
- if unable to acquire or open transaction.public static Transaction getTransaction(java.lang.String configName, Session session) throws HibernateException
configName
- String
configuration name. Default provider is used if null
or empty string is passed.session
- Session
needed if joining to existing transaction or starting transaction locally.Transaction
Already started transaction for persistence operations.HibernateException
- if unable to acquire or open transaction.public static void commitTransaction(Transaction tx) throws HibernateException
tx
- Transaction
transaction to be committed.HibernateException
- occurred while committing transaction.public static void commitTransaction(java.lang.String configName, Transaction tx) throws HibernateException
configName
- String
configuration name. Default provider is used if null
or empty string is passed.tx
- Transaction
transaction to be committed.HibernateException
- occurred while committing transaction.public static void rollbackTransaction(Transaction tx)
tx
- Transaction
transaction to be rolled back.public static void rollbackTransaction(java.lang.String configName, Transaction tx)
configName
- String
configuration name. Default provider is used if null
or empty string is passed.tx
- Transaction
transaction to be rolled back.