Package lumis.portal.dao.hibernate
Class HibernateUtil
- java.lang.Object
-
- lumis.portal.dao.hibernate.HibernateUtil
-
public class HibernateUtil extends java.lang.Object
A utility class for using hibernate.- Since:
- 4.0.5
- Version:
- $Revision: 25415 $ $Date: 2023-01-11 13:50:30 -0300 (Wed, 11 Jan 2023) $
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
HIBERNATE_CONFIG_RESOURCE_NAME
Name that must be given toEjb3Configuration.configure(String)
.static java.lang.String
SYSTEM_PROPERTY_DISABLE_READJUST_CACHE_CAPACITY
System property for internal use that disables the readjust cache capacity phase during initialization.
-
Constructor Summary
Constructors Constructor Description HibernateUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static EntityManagerFactory
createEntityManagerFactory(java.lang.String databaseId, java.net.URL configURL, java.util.Collection<java.lang.String> entities)
Creates an entity manager factory.static org.hibernate.type.NullableType
dataTypeToHibernateType(java.lang.String dataType)
Returns the hibernate type to be used to read/write to the given lumis field data type.static void
destroy()
static EntityManagerFactory
getEntityManagerFactory()
Returns the default entity manager factory, that access the portal's main database.static EntityManagerFactory
getEntityManagerFactory(java.lang.String databaseId)
Returns the entity manager factory associated with the given id.static org.hibernate.SessionFactory
getSessionFactory()
Returns the default session factory, that access the portal's main database.static org.hibernate.SessionFactory
getSessionFactory(java.lang.String databaseId)
Returns the session factory associated with the given id.static void
init()
static boolean
isInitialized()
Indicates if the portal's hibernate infra-structure has been initialized.static java.util.List<java.lang.Exception>
rebuildEntityManagerFactoriesIfNeeded()
Rebuilds the entity manager factories if needed.
-
-
-
Field Detail
-
HIBERNATE_CONFIG_RESOURCE_NAME
public static final java.lang.String HIBERNATE_CONFIG_RESOURCE_NAME
Name that must be given toEjb3Configuration.configure(String)
.- Since:
- 7.1.0
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_DISABLE_READJUST_CACHE_CAPACITY
public static final java.lang.String SYSTEM_PROPERTY_DISABLE_READJUST_CACHE_CAPACITY
System property for internal use that disables the readjust cache capacity phase during initialization.- Since:
- 9.0.0
- See Also:
- Constant Field Values
-
-
Method Detail
-
getEntityManagerFactory
public static EntityManagerFactory getEntityManagerFactory()
Returns the default entity manager factory, that access the portal's main database.- Returns:
- the entity manager factory.
- Since:
- 4.2.0
-
getSessionFactory
public static org.hibernate.SessionFactory getSessionFactory()
Returns the default session factory, that access the portal's main database.- Returns:
- the session factory.
-
createEntityManagerFactory
public static EntityManagerFactory createEntityManagerFactory(java.lang.String databaseId, java.net.URL configURL, java.util.Collection<java.lang.String> entities)
Creates an entity manager factory.- Parameters:
databaseId
- the detabase id.configURL
- the configuration URL.entities
- the entities that will be adde to the factory.- Returns:
- the created factory.
- Since:
- 7.1.0
-
getEntityManagerFactory
public static EntityManagerFactory getEntityManagerFactory(java.lang.String databaseId)
Returns the entity manager factory associated with the given id.- Parameters:
databaseId
- the id that identifies the database.- Returns:
- the entity manager factory.
- Since:
- 4.2.0
-
getSessionFactory
public static org.hibernate.SessionFactory getSessionFactory(java.lang.String databaseId)
Returns the session factory associated with the given id.- Parameters:
databaseId
- the id that identifies the database the session factory accesses.- Returns:
- the session factory.
- Since:
- 4.0.4
-
dataTypeToHibernateType
public static org.hibernate.type.NullableType dataTypeToHibernateType(java.lang.String dataType)
Returns the hibernate type to be used to read/write to the given lumis field data type.- Parameters:
dataType
- the lumis field data type.- Returns:
- the hibernate type, or null if an appropriate hibernate type was not found.
-
isInitialized
public static boolean isInitialized()
Indicates if the portal's hibernate infra-structure has been initialized.- Returns:
true
if initialized,false
otherwise.- Since:
- 4.0.11
-
init
public static void init()
-
destroy
public static void destroy()
-
rebuildEntityManagerFactoriesIfNeeded
public static java.util.List<java.lang.Exception> rebuildEntityManagerFactoriesIfNeeded() throws PortalException, EntityManagerFactoryAlreadyBeingRebuiltException, EntityManagerFactoryLockedForBeingRebuiltException, EntityManagerFactoryRebuildTimeoutException
Rebuilds the entity manager factories if needed.- Returns:
- a list of exceptions that occurred when recreating entity manager factories.
- Throws:
EntityManagerFactoryRebuildTimeoutException
- if a rebuild lock couldn't be obtained.EntityManagerFactoryLockedForBeingRebuiltException
- if a factory is already locked for rebuilt.EntityManagerFactoryAlreadyBeingRebuiltException
- if a factory is already being rebuilt.PortalException
- Since:
- 8.2.0
-
-