本文整理汇总了Java中org.hibernate.dialect.function.SQLFunction.render方法的典型用法代码示例。如果您正苦于以下问题:Java SQLFunction.render方法的具体用法?Java SQLFunction.render怎么用?Java SQLFunction.render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.dialect.function.SQLFunction
的用法示例。
在下文中一共展示了SQLFunction.render方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testClob
import org.hibernate.dialect.function.SQLFunction; //导入方法依赖的package包/类
@Test
public void testClob() {
SessionFactoryImplementor sf = (SessionFactoryImplementor) HibernateUtil.getSessionFactory();
Session session = sf.getCurrentSession();
Dialect dialect = sf.getDialect();
SQLFunction function = dialect.getFunctions().get("substr");
String substr = function.render(StringType.INSTANCE, Arrays.asList("input", 0, 5), sf);
Transaction t = session.beginTransaction();
TestsDAO dao = HibernateDAOFactory.DEFAULT.buildTestsDAO();
for (Tests test : dao.findAll()) {
try {
System.out.println("Test: " + test.getId());
System.out.println("\tinput length: " + test.getInput().length());
System.out.println("\tCriterion: " + session.createCriteria(Tests.class).setProjection(
Projections.sqlProjection(substr + " as short", new String[]{"short"}, new Type[]{StringType.INSTANCE})
).add(Restrictions.idEq(test.getId())).uniqueResult());
} catch (Throwable throwable) {
throwable.printStackTrace(System.err);
}
break;
}
}
示例2: getPartOfTest
import org.hibernate.dialect.function.SQLFunction; //导入方法依赖的package包/类
private static String getPartOfTest(Tests test, String part, Integer limit) {
if (test == null || ("input".equals(part) == false && "output".equals(part) == false)) {
return "";
}
String substr = null;
SessionFactory sf = HibernateUtil.getSessionFactory();
if (sf instanceof SessionFactoryImplementor) {
SessionFactoryImplementor sfi = (SessionFactoryImplementor) HibernateUtil.getSessionFactory();
Dialect dialect = sfi.getDialect();
if (dialect != null) {
SQLFunction function = dialect.getFunctions().get("substr");
if (function != null) {
substr = function.render(StringType.INSTANCE, Arrays.asList("input", 0, limit), sfi);
}
}
}
if (substr == null) {
substr = String.format("substr('%s',%d,%d)", "input", 1, limit);
}
return (String) sf.getCurrentSession()
.createCriteria(Tests.class)
.setProjection(
Projections.sqlProjection(
substr + " as short",
new String[]{"short"},
new Type[]{StringType.INSTANCE}))
.add(Restrictions.idEq(test.getId()))
.uniqueResult();
}
示例3: render
import org.hibernate.dialect.function.SQLFunction; //导入方法依赖的package包/类
protected String render(BasicType basic, List<String> columns, SessionFactory sessionFactory, SQLFunction sqlFunction) {
return sqlFunction.render(basic, columns, (SessionFactoryImplementor) sessionFactory);
}