当前位置: 首页>>代码示例>>Java>>正文


Java SQLFunction.render方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:faramir,项目名称:ZawodyWeb,代码行数:26,代码来源:TestsHibernateDAOTest.java

示例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();
}
 
开发者ID:faramir,项目名称:ZawodyWeb,代码行数:36,代码来源:ELFunctions.java

示例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);
}
 
开发者ID:grails,项目名称:gorm-hibernate5,代码行数:4,代码来源:HibernateQuery.java


注:本文中的org.hibernate.dialect.function.SQLFunction.render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。