public class TopiaUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
TopiaUtil.ConnectionProviderSupplier
Hibernate 4.3.x compatible Supplier<ConnectionProvider>.
|
Modifier and Type | Field and Description |
---|---|
static String |
HIBERNATE_DEFAULT_SCHEMA
Deprecated.
since 2.5.3, use now the constant
TopiaContextFactory.CONFIG_DEFAULT_SCHEMA . |
static String |
TOPIA_PERSISTENCE_CLASSES
Deprecated.
since 2.5.3, use the already present
TopiaContextImpl.TOPIA_PERSISTENCE_CLASSES . |
Constructor and Description |
---|
TopiaUtil() |
Modifier and Type | Method and Description |
---|---|
static <S extends org.hibernate.service.Service> |
getHibernateService(org.hibernate.SessionFactory sessionFactory,
Class<S> serviceClass)
Method to get an Hibernate service instance from a given Hibernate SessionFactory
NB: This method is static to make sure it does not depend on the current instance
|
static Properties |
getProperties(Properties parent,
String pathOrUrl)
Permet de récupérer le fichier de propriété ayant le nom passé en
argument.
|
static Properties |
getProperties(String pathOrUrl)
Permet de récupérer le fichier de propriété ayant le nom passé en
argument.
|
static String |
getSchemaName(TopiaContext tx)
Return hibernate schema name
|
protected static org.hibernate.service.spi.SessionFactoryServiceRegistry |
getSessionFactoryServiceRegistry(org.hibernate.SessionFactory sessionFactory)
Method to extract from the given Hibernate SessionFactory a working instance of SessionFactoryServiceRegistry
IMPORTANT : If possible, prefer using this method instead of
getStandardServiceRegistry(org.hibernate.SessionFactory) because the SessionFactoryServiceRegistry is a
child of the StandardServiceRegistry
NB: This method is static to make sure it does not depend on the current instance |
protected static org.hibernate.boot.registry.StandardServiceRegistry |
getStandardServiceRegistry(org.hibernate.SessionFactory sessionFactory)
Method to extract from the given Hibernate SessionFactory a working instance of StandardServiceRegistry
IMPORTANT : As much as possible, prefer using the
getSessionFactoryServiceRegistry(org.hibernate.SessionFactory) mthod instead of the current one because
the SessionFactoryServiceRegistry is a child of the StandardServiceRegistry
NB: This method is static to make sure it does not depend on the current instance |
static String |
getTopiaIdPattern(Class<? extends TopiaEntity> klass)
Compute the pattern to be used to capture a topia id for a given entity
class.
|
static Pattern |
getTopiaPattern(String format,
Class<? extends TopiaEntity>... classes)
Compute a regex pattern given a format string.
|
static boolean |
isSchemaEmpty(TopiaContext tx)
Test if the db associated to the given
configuration contaisn any of
the dealed entities. |
static boolean |
isSchemaExist(TopiaContext tx,
org.hibernate.boot.Metadata metadata,
String entityName)
Test si une entite donnee correspondant a une configuration existe en
base.
|
static boolean |
isSchemaExist(TopiaContext tx,
String entityName)
Test si une entite donnee correspondant a une configuration existe en
base.
|
@Deprecated public static final String HIBERNATE_DEFAULT_SCHEMA
TopiaContextFactory.CONFIG_DEFAULT_SCHEMA
.@Deprecated public static final String TOPIA_PERSISTENCE_CLASSES
TopiaContextImpl.TOPIA_PERSISTENCE_CLASSES
.public static Properties getProperties(String pathOrUrl) throws TopiaNotFoundException
pathOrUrl
- le nom du fichier de propriété à charger, s'il est null
ou vide retourne un objet Properties vide.TopiaNotFoundException
- Si pathOrUrl n'est pas null ou vide et que
le fichier devant contenir les propriétés
n'est pas retrouvé.public static Properties getProperties(Properties parent, String pathOrUrl) throws TopiaNotFoundException
parent
- l'objet properties utilisé comme parent de l'objet
retournépathOrUrl
- le nom du fichier de propriété à charger, s'il est null
ou vide retourne un objet Properties vide.TopiaNotFoundException
- Si pathOrUrl n'est pas null ou vide et que
le fichier devant contenir les propriétés
n'est pas retrouvé.public static Pattern getTopiaPattern(String format, Class<? extends TopiaEntity>... classes)
String.format(String, Object...)
will be apply to
format
, with for parameters the list of klass
transformed in topia pattern via method getTopiaIdPattern(Class)
ready to be capture (enclosed by ()).format
- the formatclasses
- the list of class to usepublic static String getTopiaIdPattern(Class<? extends TopiaEntity> klass)
klass
- the entity classpublic static boolean isSchemaExist(TopiaContext tx, org.hibernate.boot.Metadata metadata, String entityName)
tx
- la session topiametadata
- mapping des entitésentityName
- le nom de l'entite a testertrue
si le schema de la table existepublic static boolean isSchemaExist(TopiaContext tx, String entityName)
tx
- le context hibernateentityName
- le nom de l'entite a testertrue
si le schema de la table existepublic static boolean isSchemaEmpty(TopiaContext tx)
configuration
contaisn any of
the dealed entities.tx
- topia contexttrue
if there is no schema for any of the dealed entities,
false
otherwise.protected static org.hibernate.boot.registry.StandardServiceRegistry getStandardServiceRegistry(org.hibernate.SessionFactory sessionFactory)
getSessionFactoryServiceRegistry(org.hibernate.SessionFactory)
mthod instead of the current one because
the SessionFactoryServiceRegistry is a child of the StandardServiceRegistry
NB: This method is static to make sure it does not depend on the current instancesessionFactory
- the Hibernate's SessionFactory instanceprotected static org.hibernate.service.spi.SessionFactoryServiceRegistry getSessionFactoryServiceRegistry(org.hibernate.SessionFactory sessionFactory)
getStandardServiceRegistry(org.hibernate.SessionFactory)
because the SessionFactoryServiceRegistry is a
child of the StandardServiceRegistry
NB: This method is static to make sure it does not depend on the current instancesessionFactory
- the Hibernate's SessionFactory instancepublic static <S extends org.hibernate.service.Service> S getHibernateService(org.hibernate.SessionFactory sessionFactory, Class<S> serviceClass)
sessionFactory
- the Hibernate's SessionFactory instanceserviceClass
- the expected service classorg.hibernate.service.UnknownServiceException
- Indicates the service was not known.ServiceRegistry.getService(Class)
public static String getSchemaName(TopiaContext tx)
tx
- topia contextCopyright © 2004–2022 Code Lutin. All rights reserved.