Package com.isomorphic.hibernate
Class HB
java.lang.Object
com.isomorphic.hibernate.HB
Singleton factory for hibernate
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:
getEntityManagerreturnEntityManagergetTransactioncommitTransactionrollbackTransaction
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName of sub property for hibernate configuration lookup style.static final StringDefault Hibernate provider class name.static final StringDefault Spring Hibernate provider class name.static final StringName of prefix for hibernate provider block.static final StringName of property for JPA EMF provider implementation.static final StringLookup style value specifying Spring usage.static final StringName of sub property for hibernate provider implementation.static final StringAttribute name for RPCManager. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcommitTransaction(String configName, org.hibernate.Transaction tx) Commits specified transaction.static voidcommitTransaction(org.hibernate.Transaction tx) Commits specified transaction.static org.hibernate.SessionFactoryget()ReturnsSessionFactory.static org.hibernate.SessionFactoryReturnsSessionFactory.static org.hibernate.SessionReturnsSessionfor persistence operations.static org.hibernate.SessiongetSession(String configName) ReturnsSessionfor persistence operations.static org.hibernate.TransactiongetTransaction(String configName, org.hibernate.Session session) Returns started transaction.static org.hibernate.TransactiongetTransaction(org.hibernate.Session session) Returns started transaction.static voidreturnSession(String configName, org.hibernate.Session session) ClosesSession.static voidreturnSession(org.hibernate.Session session) ClosesSession.static voidrollbackTransaction(String configName, org.hibernate.Transaction tx) Rolls back specified transaction.static voidrollbackTransaction(org.hibernate.Transaction tx) Rolls back specified transaction.
-
Field Details
-
HB_PREFIX
Name of prefix for hibernate provider block.- See Also:
-
PROVIDER
Name of sub property for hibernate provider implementation.- See Also:
-
CONFIG_LOOKUP_STYLE
Name of sub property for hibernate configuration lookup style.- See Also:
-
LOOKUP_STYLE_SPRING
Lookup style value specifying Spring usage.- See Also:
-
DEFAULT_HB_PROVIDER
Default Hibernate provider class name. Will be used if provider is not specified in configuration.- See Also:
-
DEFAULT_SPRING_HB_PROVIDER
Default Spring Hibernate provider class name. Will be used if provider is not specified in configuration and lookupStyle property is set to 'spring'.- See Also:
-
HB_PROVIDER
Name of property for JPA EMF provider implementation.- See Also:
-
TRANSACTION_ATTR
Attribute name for RPCManager. Under this attribute current transaction is stored.- See Also:
-
-
Method Details
-
get
public static org.hibernate.SessionFactory get()ReturnsSessionFactory. Using default configuration.- Returns:
SessionFactoryor null.
-
get
ReturnsSessionFactory.- Parameters:
configName-Stringconfiguration name. Default provider is used ifnullor empty string is passed.- Returns:
SessionFactoryor null.
-
getSession
public static org.hibernate.Session getSession() throws org.hibernate.HibernateExceptionReturnsSessionfor persistence operations. Using default configuration.- Returns:
Sessionfor persistence operations.- Throws:
org.hibernate.HibernateException- if unable to acquireSession.
-
getSession
public static org.hibernate.Session getSession(String configName) throws org.hibernate.HibernateException ReturnsSessionfor persistence operations.- Parameters:
configName-Stringconfiguration name. Default provider is used ifnullor empty string is passed.- Returns:
Sessionfor persistence operations.- Throws:
org.hibernate.HibernateException- if unable to acquireSession.
-
returnSession
public static void returnSession(org.hibernate.Session session) ClosesSession. Using default configuration.- Parameters:
session-Sessionwhich should be closed.
-
returnSession
ClosesSession.- Parameters:
configName-Stringconfiguration name. Default provider is used ifnullor empty string is passed.session-Sessionwhich should be closed.
-
getTransaction
public static org.hibernate.Transaction getTransaction(org.hibernate.Session session) throws org.hibernate.HibernateException Returns started transaction. Using default configuration.- Parameters:
session-Sessionneeded if joining to existing transaction or starting transaction locally.- Returns:
TransactionAlready started transaction for persistence operations.- Throws:
org.hibernate.HibernateException- if unable to acquire or open transaction.
-
getTransaction
public static org.hibernate.Transaction getTransaction(String configName, org.hibernate.Session session) throws org.hibernate.HibernateException Returns started transaction.- Parameters:
configName-Stringconfiguration name. Default provider is used ifnullor empty string is passed.session-Sessionneeded if joining to existing transaction or starting transaction locally.- Returns:
TransactionAlready started transaction for persistence operations.- Throws:
org.hibernate.HibernateException- if unable to acquire or open transaction.
-
commitTransaction
public static void commitTransaction(org.hibernate.Transaction tx) throws org.hibernate.HibernateException Commits specified transaction. Using default configuration.- Parameters:
tx-Transactiontransaction to be committed.- Throws:
org.hibernate.HibernateException- occurred while committing transaction.
-
commitTransaction
public static void commitTransaction(String configName, org.hibernate.Transaction tx) throws org.hibernate.HibernateException Commits specified transaction.- Parameters:
configName-Stringconfiguration name. Default provider is used ifnullor empty string is passed.tx-Transactiontransaction to be committed.- Throws:
org.hibernate.HibernateException- occurred while committing transaction.
-
rollbackTransaction
public static void rollbackTransaction(org.hibernate.Transaction tx) Rolls back specified transaction. Using default configuration.- Parameters:
tx-Transactiontransaction to be rolled back.
-
rollbackTransaction
Rolls back specified transaction.- Parameters:
configName-Stringconfiguration name. Default provider is used ifnullor empty string is passed.tx-Transactiontransaction to be rolled back.
-