本文整理汇总了Java中org.hibernate.criterion.CriteriaQuery.findColumns方法的典型用法代码示例。如果您正苦于以下问题:Java CriteriaQuery.findColumns方法的具体用法?Java CriteriaQuery.findColumns怎么用?Java CriteriaQuery.findColumns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.criterion.CriteriaQuery
的用法示例。
在下文中一共展示了CriteriaQuery.findColumns方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toSqlString
import org.hibernate.criterion.CriteriaQuery; //导入方法依赖的package包/类
@Override
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) {
String[] columns = criteriaQuery.findColumns(getPropiedad(), criteria);
if (columns.length != 1) {
throw new HibernateException(
"NumberLike may only be used with single-column properties");
}
SessionFactoryImplementor factory = criteriaQuery.getFactory();
if (factory.getDialect() instanceof H2Dialect) {
return "cast(cast(" + columns[0] + " as int) as VARCHAR) "
+ "like ?";
} else {
// XXX ver consistencia entre bases de datos
return columns[0] + "::text like ?";
}
}
示例2: toSqlString
import org.hibernate.criterion.CriteriaQuery; //导入方法依赖的package包/类
@Override
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) {
String[] columns = criteriaQuery.findColumns(getPath(), criteria);
if (columns.length != 1) {
throw new HibernateException(
"Regex may only be used with single-column properties");
}
SessionFactoryImplementor factory = criteriaQuery.getFactory();
if (factory.getDialect() instanceof H2Dialect) {
return columns[0] + " regexp ?";
} else {
// XXX ver consistencia entre bases de datos
return columns[0] + " ~ ?";
}
}
示例3: toSqlString
import org.hibernate.criterion.CriteriaQuery; //导入方法依赖的package包/类
@Override
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
final String[] lhsColumns = criteriaQuery.findColumns( propertyName, criteria );
final String[] rhsColumns = criteriaQuery.findColumns( otherPropertyName, criteria );
List<String> comparisons = new ArrayList<String>();
for (int i = 0; i<lhsColumns.length; i++) {
String comp = formatExpr(lhsColumns[0], rhsColumns[0], mode);
comparisons.add(comp);
}
if ( comparisons.size() > 1 ) {
return '(' + StringHelper.join( " and ", comparisons.toArray(new String[comparisons.size()]) ) + ')';
} else {
return comparisons.get(0);
}
}
示例4: toSqlString
import org.hibernate.criterion.CriteriaQuery; //导入方法依赖的package包/类
@Override
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
String[] columns = criteriaQuery.findColumns(propertyName, criteria);
if (columns.length != 1) {
throw new HibernateException("FulltextSearch may only be used with single-column properties");
}
String searchModeStr = null;
switch (this.searchMode) {
case BOOLEAN:
searchModeStr = "BOOLEAN";
break;
case NATURAL_LANGUAGE:
searchModeStr = "NATURAL_LANGUAGE";
break;
default:
throw new HibernateException("Null SearchMode set");
}
String columnsStr = columns[0];
for (int i = 1; i < columns.length; i++) {
columnsStr += ", " + columns[i];
}
return "match (" + columnsStr + ") against (? IN " + searchModeStr + " MODE)";
}