public class PersistenceUtils extends Object
Provides utility methods related to persistence operations.
| Modifier and Type | Method and Description | 
|---|---|
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 List<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 <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 SqlMappingContext createSqlMappingContext(String[] fileNames, DatabaseType databaseType, EntityResolver entityResolver) throws Exception
Reads the specified XML 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
Reads the specified XML 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)
Replaces the given parameter name with a new parameter name in the given sql statement.
<p>
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 List<String> extractParameterNames(String sql)
Extracts the parameter names from the given sql statement.
<p>
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)
Extracts the sql type information for each named parameter from the given sql statement.
<p>
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)
Removes the sql type information from the given sql statement.
<p>
A named parameter and its sql type are defined as :<name>{<TYPE>}, e.g. :id{VARCHAR}.
sql - the sql statement to processpublic static <T extends ComponentEntity> com.google.common.collect.ImmutableMap<String,Set<T>> mapByForeignKey(Collection<T> components)
Separates the given component entities by their source reference.
T - component entitycomponents - the component entities to separateCopyright © 2010 - 2019 edorasware ag. All Rights Reserved.