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


Java Query.executeAndFetchFirst方法代码示例

本文整理汇总了Java中org.sql2o.Query.executeAndFetchFirst方法的典型用法代码示例。如果您正苦于以下问题:Java Query.executeAndFetchFirst方法的具体用法?Java Query.executeAndFetchFirst怎么用?Java Query.executeAndFetchFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sql2o.Query的用法示例。


在下文中一共展示了Query.executeAndFetchFirst方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHomePage

import org.sql2o.Query; //导入方法依赖的package包/类
@Override
public Class<? extends Page> getHomePage() {
    Sql2o sql2o = Spring.getBean(Sql2o.class);
    try (Connection connection = sql2o.open()) {
        Query query = connection.createQuery("SELECT groovy.java_class FROM setting INNER JOIN page on setting.value = page.page_id INNER JOIN groovy on page.groovy_id = groovy.groovy_id where setting.name = 'home_page'");
        String javaClass = query.executeAndFetchFirst(String.class);
        if (Strings.isNullOrEmpty(javaClass)) {
            return DashboardPage.class;
        } else {
            GroovyClassLoader classLoader = Spring.getBean(GroovyClassLoader.class);
            try {
                return (Class<? extends Page>) classLoader.loadClass(javaClass);
            } catch (ClassNotFoundException | ClassCastException e) {
                return DashboardPage.class;
            }
        }
    }
}
 
开发者ID:PkayJava,项目名称:MBaaS,代码行数:19,代码来源:Application.java

示例2: find

import org.sql2o.Query; //导入方法依赖的package包/类
public <T extends ActiveRecord> T find() {
    QueryMeta queryMeta = SqlBuilder.buildFindSql(this);
    Class<T>  type      = (Class<T>) getClass();
    try (Connection con = getSql2o().open()) {
        this.cleanParam();

        log.debug(EXECUTE_SQL_PREFIX + " => {}", queryMeta.getSql());
        log.debug(PARAMETER_PREFIX + " => {}", Arrays.toString(queryMeta.getParams()));

        Query query = con.createQuery(queryMeta.getSql()).withParams(queryMeta.getParams()).throwOnMappingFailure(false);
        if (queryMeta.hasColumnMapping()) {
            queryMeta.getColumnMapping().forEach(query::addColumnMapping);
        }
        return query.executeAndFetchFirst(type);
    }
}
 
开发者ID:lets-blade,项目名称:blade-jdbc,代码行数:17,代码来源:ActiveRecord.java

示例3: getObject

import org.sql2o.Query; //导入方法依赖的package包/类
@Override
public Item getObject(String id, IModel<? extends List<? extends Item>> choices) {
    Sql2o sql2o = Spring.getBean(Sql2o.class);
    try (Connection connection = sql2o.open()) {
        List<String> where = new ArrayList<>();
        where.addAll(this.where);
        where.add(this.idField + " = :id");
        Query query = connection.createQuery("SELECT " + this.idField + " id, " + this.labelField + " value " + " FROM " + this.table + " WHERE " + StringUtils.join(where, " AND "));
        query.addParameter("id", id);
        return query.executeAndFetchFirst(Item.class);
    }
}
 
开发者ID:PkayJava,项目名称:MBaaS,代码行数:13,代码来源:JdbcMultipleChoiceProvider.java

示例4: toChoice

import org.sql2o.Query; //导入方法依赖的package包/类
@Override
public Item toChoice(String s) {
    Sql2o sql2o = Spring.getBean(Sql2o.class);
    try (Connection connection = sql2o.open()) {
        List<String> where = new ArrayList<>();
        where.addAll(this.where);
        where.add(this.idField + " = :id");
        Query query = connection.createQuery("SELECT " + this.idField + " id, " + this.labelField + " value " + " FROM " + this.table + " WHERE " + StringUtils.join(where, " AND "));
        query.addParameter("id", s);
        return query.executeAndFetchFirst(Item.class);
    }
}
 
开发者ID:PkayJava,项目名称:MBaaS,代码行数:13,代码来源:JdbcSingleChoiceProvider.java

示例5: get

import org.sql2o.Query; //导入方法依赖的package包/类
public static <T> T get(String sql, Class<T> clazz, Map<String, Object> params){
	Connection con = sql2o.open();
	Query query = con.createQuery(sql);
	executeQuery(query, params);
	T t = query.executeAndFetchFirst(clazz);
	con.close();
	return t;
}
 
开发者ID:thinkhoon,项目名称:mario-a-simple-mvc-framework--fork-,代码行数:9,代码来源:MarioDb.java


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