Package lumis.portal.dao.hibernate
Class HibernateUtil
- java.lang.Object
-
- lumis.portal.dao.hibernate.HibernateUtil
-
public class HibernateUtil extends Object
A utility class for using hibernate.- Since:
- 4.0.5
- Version:
- $Revision: 24985 $ $Date: 2022-05-02 23:04:30 -0300 (Mon, 02 May 2022) $
-
-
Field Summary
Fields Modifier and Type Field Description static String
HIBERNATE_CONFIG_RESOURCE_NAME
Name that must be given toEjb3Configuration.configure(String)
.static 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(String databaseId, URL configURL, Collection<String> entities)
Creates an entity manager factory.static org.hibernate.type.NullableType
dataTypeToHibernateType(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(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(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 List<Exception>
rebuildEntityManagerFactoriesIfNeeded()
Rebuilds the entity manager factories if needed.
-
-
-
Field Detail
-
HIBERNATE_CONFIG_RESOURCE_NAME
public static final 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 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(String databaseId, URL configURL, Collection<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(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(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(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 List<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
-
-