本文整理汇总了Java中org.hibernate.util.StringHelper.replace方法的典型用法代码示例。如果您正苦于以下问题:Java StringHelper.replace方法的具体用法?Java StringHelper.replace怎么用?Java StringHelper.replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.util.StringHelper
的用法示例。
在下文中一共展示了StringHelper.replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sqlConstraintString
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public String sqlConstraintString(Dialect dialect, String constraintName, String defaultCatalog,
String defaultSchema) {
StringBuffer buf = new StringBuffer(
dialect.getAddPrimaryKeyConstraintString( constraintName )
).append( '(' );
Iterator iter = getColumnIterator();
boolean nullable = false;
while ( iter.hasNext() ) {
Column column = (Column) iter.next();
if ( !nullable && column.isNullable() ) nullable = true;
buf.append( column.getQuotedName( dialect ) );
if ( iter.hasNext() ) buf.append( ", " );
}
return !nullable || dialect.supportsNotNullUnique() ?
StringHelper.replace( buf.append( ')' ).toString(), "primary key", "unique" ) :
//TODO: improve this hack!
null;
}
示例2: toColumns
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public String[] toColumns(String alias, String propertyName) throws QueryException {
//TODO: *two* hashmap lookups here is one too many...
String[] columns = (String[]) columnsByPropertyPath.get(propertyName);
if ( columns == null ) {
throw propertyException( propertyName );
}
String[] templates = (String[]) formulaTemplatesByPropertyPath.get(propertyName);
String[] result = new String[columns.length];
for ( int i=0; i<columns.length; i++ ) {
if ( columns[i]==null ) {
result[i] = StringHelper.replace( templates[i], Template.TEMPLATE, alias );
}
else {
result[i] = StringHelper.qualify( alias, columns[i] );
}
}
return result;
}
示例3: expandParameterList
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
/**
* Warning: adds new parameters to the argument by side-effect, as well as
* mutating the query string!
*/
private String expandParameterList(String query, String name, TypedValue typedList, Map namedParamsCopy) {
Collection vals = (Collection) typedList.getValue();
Type type = typedList.getType();
if ( vals.size() == 1 ) {
// short-circuit for performance...
namedParamsCopy.put( name, new TypedValue( type, vals.iterator().next(), session.getEntityMode() ) );
return query;
}
StringBuffer list = new StringBuffer( 16 );
Iterator iter = vals.iterator();
int i = 0;
boolean isJpaPositionalParam = parameterMetadata.getNamedParameterDescriptor( name ).isJpaStyle();
while ( iter.hasNext() ) {
String alias = ( isJpaPositionalParam ? 'x' + name : name ) + i++ + '_';
namedParamsCopy.put( alias, new TypedValue( type, iter.next(), session.getEntityMode() ) );
list.append( ParserHelper.HQL_VARIABLE_PREFIX ).append( alias );
if ( iter.hasNext() ) {
list.append( ", " );
}
}
String paramPrefix = isJpaPositionalParam ? "?" : ParserHelper.HQL_VARIABLE_PREFIX;
return StringHelper.replace( query, paramPrefix + name, list.toString(), true );
}
示例4: toSqlString
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public String toSqlString(
Criteria criteria,
int loc,
CriteriaQuery criteriaQuery)
throws HibernateException {
return StringHelper.replace( sql, "{alias}", criteriaQuery.getSQLAlias(criteria) );
}
示例5: toColumns
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public String[] toColumns(String name, final int i) {
final String alias = generateTableAlias( name, getSubclassPropertyTableNumber( i ) );
String[] cols = getSubclassPropertyColumnNames( i );
String[] templates = getSubclassPropertyFormulaTemplateClosure()[i];
String[] result = new String[cols.length];
for ( int j = 0; j < cols.length; j++ ) {
if ( cols[j] == null ) {
result[j] = StringHelper.replace( templates[j], Template.TEMPLATE, alias );
}
else {
result[j] = StringHelper.qualify( alias, cols[j] );
}
}
return result;
}
示例6: getManyToManyOrderByString
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public String getManyToManyOrderByString(String alias) {
if ( isManyToMany() && manyToManyOrderByString != null ) {
return StringHelper.replace( manyToManyOrderByTemplate, Template.TEMPLATE, alias );
}
else {
return "";
}
}
示例7: qualify
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
private static String[] qualify(String alias, String[] columnNames, String[] formulaTemplates) {
int span = columnNames.length;
String[] result = new String[span];
for (int i=0; i<span; i++) {
if ( columnNames[i]==null ) {
result[i] = StringHelper.replace( formulaTemplates[i], Template.TEMPLATE, alias );
}
else {
result[i] = StringHelper.qualify( alias, columnNames[i] );
}
}
return result;
}
示例8: addDiscriminatorWhereFragment
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public void addDiscriminatorWhereFragment(RestrictableStatement statement, Queryable persister, Map enabledFilters, String alias) {
String whereFragment = persister.filterFragment( alias, enabledFilters ).trim();
if ( "".equals( whereFragment ) ) {
return;
}
if ( whereFragment.startsWith( "and" ) ) {
whereFragment = whereFragment.substring( 4 );
}
// Need to parse off the column qualifiers; this is assuming (which is true as of now)
// that this is only used from update and delete HQL statement parsing
whereFragment = StringHelper.replace( whereFragment, persister.generateFilterConditionAlias( alias ) + ".", "" );
// Note: this simply constructs a "raw" SQL_TOKEN representing the
// where fragment and injects this into the tree. This "works";
// however it is probably not the best long-term solution.
//
// At some point we probably want to apply an additional grammar to
// properly tokenize this where fragment into constituent parts
// focused on the operators embedded within the fragment.
AST discrimNode = astFactory.create( SQL_TOKEN, whereFragment );
if ( statement.getWhereClause().getNumberOfChildren() == 0 ) {
statement.getWhereClause().setFirstChild( discrimNode );
}
else {
AST and = astFactory.create( AND, "{and}" );
AST currentFirstChild = statement.getWhereClause().getFirstChild();
and.setFirstChild( discrimNode );
and.addChild( currentFirstChild );
statement.getWhereClause().setFirstChild( and );
}
}
示例9: toSqlString
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
@Override
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
StringBuilder fragment = new StringBuilder();
fragment.append("(");
fragment.append(sql);
fragment.append(")");
fragment.append(ascending ? " asc" : " desc");
return StringHelper.replace(fragment.toString(), "{alias}",
criteriaQuery.getSQLAlias(criteria));
}
示例10: injectCatalogAndSchema
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
private String injectCatalogAndSchema(String ddlString, String defaultCatalog, String defaultSchema) {
String rtn = StringHelper.replace( ddlString, "${catalog}", defaultCatalog );
rtn = StringHelper.replace( rtn, "${schema}", defaultSchema );
return rtn;
}
示例11: toGroupSqlString
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
return StringHelper.replace( groupBy, "{alias}", criteriaQuery.getSQLAlias(criteria) );
}
示例12: toSqlString
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public String toSqlString(
Criteria criteria,
CriteriaQuery criteriaQuery)
throws HibernateException {
return StringHelper.replace( sql, "{alias}", criteriaQuery.getSQLAlias(criteria) );
}
示例13: getSQLWhereString
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
protected String getSQLWhereString(String alias) {
return StringHelper.replace( sqlWhereStringTemplate, Template.TEMPLATE, alias );
}
示例14: getSQLOrderByString
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public String getSQLOrderByString(String alias) {
return hasOrdering() ?
StringHelper.replace( sqlOrderByStringTemplate, Template.TEMPLATE, alias ) : "";
}
示例15: setFormula
import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public InFragment setFormula(String alias, String formulaTemplate) {
this.columnName = StringHelper.replace(formulaTemplate, Template.TEMPLATE, alias);
return setColumn(this.columnName);
}