public final class PersistenceUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DDL_CREATE_OPERATION
Name constant for "create" operation.
|
static String |
DDL_DROP_OPERATION
Name constant for "drop" operation.
|
static String |
DDL_UPDATE_OPERATION
Name constant for "update" operation.
|
Modifier and Type | Method and Description |
---|---|
static String |
buildDdlResourcePath(String base,
String namespace,
String operation,
String component,
DatabaseType databaseType)
Convenience method that builds a specific DDL resource path from the given elements that make up the path.
|
static String |
buildDdlResourcePath(String base,
String namespace,
String operation,
String component,
String classifier,
DatabaseType databaseType)
Convenience method that builds a specific DDL resource path from the given elements that make up the path.
|
static com.google.common.collect.ImmutableList<URL> |
buildDdlResourcePaths(String base,
String namespace,
String operation,
String component,
String classifier,
DatabaseType databaseType)
Convenience method that builds a list of specific DDL resource paths from the given elements that make up the paths.
|
static SqlMappingContext |
createSqlMappingContext(List<org.springframework.core.io.Resource> resources,
DatabaseType databaseType,
EntityResolver entityResolver)
Reads the specified XML
resources into a SqlMappingContext . |
static SqlMappingContext |
createSqlMappingContext(String[] fileNames,
DatabaseType databaseType,
EntityResolver entityResolver)
Reads the specified XML
file resources into a SqlMappingContext . |
static com.google.common.collect.ImmutableList<String> |
extractParameterNames(String sql)
Extracts the parameter names from the given sql statement.
|
static com.google.common.collect.ImmutableMap<String,Integer> |
extractParameterSqlTypes(String sql)
Extracts the sql type information for each named parameter from the given sql statement.
|
static com.google.common.collect.ImmutableList<URL> |
findDdlResources(String base,
String defaultBase,
String namespace,
String operation,
String component,
int initialFromVersion,
int finalToVersion,
DatabaseType databaseType)
Convenience method that returns DDL resources in a given version range.
|
static <T extends ComponentEntity> |
mapByForeignKey(Collection<T> components)
Separates the given component entities by their source reference.
|
static String |
removeParameterSqlTypes(String sql)
Removes the sql type information from the given sql statement.
|
static String |
replaceParameterName(String sql,
String parameterName,
String newParameterName)
Replaces the given parameter name with a new parameter name in the given sql statement.
|
public static final String DDL_CREATE_OPERATION
public static final String DDL_UPDATE_OPERATION
public static final String DDL_DROP_OPERATION
public static SqlMappingContext createSqlMappingContext(String[] fileNames, DatabaseType databaseType, EntityResolver entityResolver) throws Exception
file resources
into a SqlMappingContext
.fileNames
- the XML file resources to be readdatabaseType
- the type of database for which to read the mappingsentityResolver
- the resolver used to locate XML entitiesException
- thrown in case something goes wrong during the XML loading/parsing processpublic static SqlMappingContext createSqlMappingContext(List<org.springframework.core.io.Resource> resources, DatabaseType databaseType, EntityResolver entityResolver) throws Exception
resources
into a SqlMappingContext
.resources
- the XML resources to be readdatabaseType
- the type of database for which to read the mappingsentityResolver
- the resolver used to locate XML entitiesException
- thrown in case something goes wrong during the XML loading/parsing processpublic static String replaceParameterName(String sql, String parameterName, String newParameterName)
A named parameter and its sql type are defined as :<name>{<TYPE>}
, e.g. :id{VARCHAR}
.
sql
- the sql statement to processparameterName
- the parameter name to replacenewParameterName
- the new parameter namepublic static com.google.common.collect.ImmutableList<String> extractParameterNames(String sql)
A named parameter and its sql type are defined as :<name>{<TYPE>}
, e.g. :id{VARCHAR}
.
sql
- the sql statement to processpublic static com.google.common.collect.ImmutableMap<String,Integer> extractParameterSqlTypes(String sql)
A named parameter and its sql type are defined as :<name>{<TYPE>}
, e.g. :id{VARCHAR}
.
sql
- the sql statement to processpublic static String removeParameterSqlTypes(String sql)
A named parameter and its sql type are defined as :<name>{<TYPE>}
, e.g. :id{VARCHAR}
.
sql
- the sql statement to processpublic static String buildDdlResourcePath(String base, String namespace, String operation, String component, DatabaseType databaseType)
base/operation/namespace.databaseType.operation.component.sql
base
- the base pathnamespace
- the namespace of the tableoperation
- the type of db operations to executecomponent
- the component affecteddatabaseType
- the database typepublic static String buildDdlResourcePath(String base, String namespace, String operation, String component, String classifier, DatabaseType databaseType)
base/operation/namespace.databaseType.operation.component[.classifier].sql
base
- the base pathnamespace
- the namespace of the tableoperation
- the type of db operations to executecomponent
- the component affectedclassifier
- the optional classifierdatabaseType
- the database typepublic static com.google.common.collect.ImmutableList<URL> buildDdlResourcePaths(String base, String namespace, String operation, String component, String classifier, DatabaseType databaseType)
base/operation/namespace.databaseType.operation.component[.classifier].sql
This method is useful when the resources have the same path but are located under a different root.
base
- the base pathnamespace
- the namespace of the tableoperation
- the type of db operations to executecomponent
- the component affectedclassifier
- the optional classifierdatabaseType
- the database typepublic static com.google.common.collect.ImmutableList<URL> findDdlResources(String base, String defaultBase, String namespace, String operation, String component, int initialFromVersion, int finalToVersion, DatabaseType databaseType)
base/operation/namespace.databaseType.operation.component.Sx.to.Sy.sql
base
- the primary base pathdefaultBase
- the default base pathnamespace
- the namespace of the tableoperation
- the type of db operations to executecomponent
- the component affectedinitialFromVersion
- the start of the first range to findfinalToVersion
- the end of the last range to finddatabaseType
- the database typepublic static <T extends ComponentEntity> com.google.common.collect.ImmutableMap<String,Set<T>> mapByForeignKey(Collection<T> components)
T
- component entitycomponents
- the component entities to separateCopyright © 2010 - 2018 edorasware ag. All Rights Reserved.