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


Java JdbcTemplate.queryForObject方法代码示例

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


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

示例1: deleteHistoryActivities

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
/**
 * 删除历史节点.
 */
public void deleteHistoryActivities(List<String> historyNodeIds) {
    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    logger.info("historyNodeIds : {}", historyNodeIds);

    for (String id : historyNodeIds) {
        String taskId = jdbcTemplate.queryForObject(
                "select task_id_ from ACT_HI_ACTINST where id_=?",
                String.class, id);

        if (taskId != null) {
            Context.getCommandContext()
                    .getHistoricTaskInstanceEntityManager()
                    .deleteHistoricTaskInstanceById(taskId);
        }

        jdbcTemplate.update("delete from ACT_HI_ACTINST where id_=?", id);
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:23,代码来源:WithdrawTaskCmd.java

示例2: queryObjCountByCondition

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public int queryObjCountByCondition(String tableName, String condition){
	/*		JdbcTemplate jdbcTemplate = (JdbcTemplate) MicroDbHolder
	.getDbSource(dbName);*/
	JdbcTemplate jdbcTemplate = getMicroJdbcTemplate();
	String sql="";
	sql="select count(1) from " + tableName + " where "+condition;
	logger.debug(sql);
	Integer total=jdbcTemplate.queryForObject(sql,Integer.class);
	return total;
}
 
开发者ID:jeffreyning,项目名称:nh-micro,代码行数:11,代码来源:MicroMetaDao.java

示例3: getHistoricActivityInstanceEntity

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
/**
 * 查询历史节点.
 */
public HistoricActivityInstanceEntity getHistoricActivityInstanceEntity(
        String historyTaskId) {
    logger.info("historyTaskId : {}", historyTaskId);

    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    String historicActivityInstanceId = jdbcTemplate.queryForObject(
            "SELECT ID_ FROM ACT_HI_ACTINST WHERE TASK_ID_=?",
            String.class, historyTaskId);
    logger.info("historicActivityInstanceId : {}",
            historicActivityInstanceId);

    HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl = new HistoricActivityInstanceQueryImpl();
    historicActivityInstanceQueryImpl
            .activityInstanceId(historicActivityInstanceId);

    HistoricActivityInstanceEntity historicActivityInstanceEntity = (HistoricActivityInstanceEntity) Context
            .getCommandContext()
            .getHistoricActivityInstanceEntityManager()
            .findHistoricActivityInstancesByQueryCriteria(
                    historicActivityInstanceQueryImpl, new Page(0, 1))
            .get(0);

    return historicActivityInstanceEntity;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:29,代码来源:RollbackTaskCmd.java

示例4: getHistoricActivityInstanceEntity

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public HistoricActivityInstanceEntity getHistoricActivityInstanceEntity(
        String historyTaskId) {
    logger.info("historyTaskId : {}", historyTaskId);

    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    String historicActivityInstanceId = jdbcTemplate.queryForObject(
            "select id_ from ACT_HI_ACTINST where task_id_=?",
            String.class, historyTaskId);
    logger.info("historicActivityInstanceId : {}",
            historicActivityInstanceId);

    HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl = new HistoricActivityInstanceQueryImpl();
    historicActivityInstanceQueryImpl
            .activityInstanceId(historicActivityInstanceId);

    HistoricActivityInstanceEntity historicActivityInstanceEntity = (HistoricActivityInstanceEntity) Context
            .getCommandContext()
            .getHistoricActivityInstanceEntityManager()
            .findHistoricActivityInstancesByQueryCriteria(
                    historicActivityInstanceQueryImpl, new Page(0, 1))
            .get(0);

    return historicActivityInstanceEntity;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:26,代码来源:WithdrawTaskCmd.java

示例5: getUserExpressCount

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public int getUserExpressCount(int userId){
	
	JdbcTemplate jdbcTemplate = util.getJdbcTemplate(Constant.APPID,ExpressDeliverAfterTransMethod.BUSINESS_CODE,(ExpressDeliverAfterTransMethodRequest)null);
	Integer queryForObject = jdbcTemplate.queryForObject("select count(1) from express where user_id = ?", Integer.class,userId);
	if(queryForObject == null){
		queryForObject = 0;
	}
	return queryForObject;
}
 
开发者ID:QNJR-GROUP,项目名称:EasyTransaction,代码行数:10,代码来源:ExpressService.java

示例6: findNearestUserTask

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
/**
 * 查找离当前节点最近的上一个userTask.
 */
public String findNearestUserTask(CommandContext commandContext) {
    TaskEntity taskEntity = commandContext.getTaskEntityManager()
            .findTaskById(taskId);

    if (taskEntity == null) {
        logger.debug("cannot find task : {}", taskId);

        return null;
    }

    Graph graph = new ActivitiHistoryGraphBuilder(
            taskEntity.getProcessInstanceId()).build();
    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    String historicActivityInstanceId = jdbcTemplate.queryForObject(
            "SELECT ID_ FROM ACT_HI_ACTINST WHERE TASK_ID_=?",
            String.class, taskId);
    Node node = graph.findById(historicActivityInstanceId);

    String previousHistoricActivityInstanceId = this.findIncomingNode(
            graph, node);

    if (previousHistoricActivityInstanceId == null) {
        logger.debug(
                "cannot find previous historic activity instance : {}",
                taskEntity);

        return null;
    }

    return jdbcTemplate.queryForObject(
            "SELECT TASK_ID_ FROM ACT_HI_ACTINST WHERE ID_=?",
            String.class, previousHistoricActivityInstanceId);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:38,代码来源:RollbackTaskCmd.java

示例7: isSkipActivity

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
/**
 * 判断跳过节点.
 */
public boolean isSkipActivity(String historyActivityId) {
    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    String historyTaskId = jdbcTemplate.queryForObject(
            "SELECT TASK_ID_ FROM ACT_HI_ACTINST WHERE ID_=?",
            String.class, historyActivityId);

    HistoricTaskInstanceEntity historicTaskInstanceEntity = Context
            .getCommandContext().getHistoricTaskInstanceEntityManager()
            .findHistoricTaskInstanceById(historyTaskId);
    String deleteReason = historicTaskInstanceEntity.getDeleteReason();

    return "跳过".equals(deleteReason);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:18,代码来源:RollbackTaskCmd.java

示例8: getBlockCount

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
/**
 * return the block count.
 *
 * @return the block count.
 */
@Override
public long getBlockCount() {
	synchronized (this) {
		if (closed) {
			return 0;
		}
	}
	final JdbcTemplate t = new JdbcTemplate(ds);
	final String sql = getSql("getBlockCount");
	return t.queryForObject(sql, Integer.class);
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:17,代码来源:BlockDbH2Impl.java

示例9: findNearestUserTask

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public String findNearestUserTask() {
    TaskEntity taskEntity = Context.getCommandContext()
            .getTaskEntityManager().findTaskById(taskId);

    if (taskEntity == null) {
        logger.debug("cannot find task : {}", taskId);

        return null;
    }

    Graph graph = new ActivitiHistoryGraphBuilder(
            taskEntity.getProcessInstanceId()).build();
    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    String historicActivityInstanceId = jdbcTemplate.queryForObject(
            "select id_ from ACT_HI_ACTINST where task_id_=?",
            String.class, taskId);
    Node node = graph.findById(historicActivityInstanceId);

    String previousHistoricActivityInstanceId = this.findIncomingNode(
            graph, node);

    if (previousHistoricActivityInstanceId == null) {
        logger.debug(
                "cannot find previous historic activity instance : {}",
                taskEntity);

        return null;
    }

    return jdbcTemplate.queryForObject(
            "select task_id_ from ACT_HI_ACTINST where id_=?",
            String.class, previousHistoricActivityInstanceId);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:35,代码来源:RollbackCmd.java

示例10: isSkipActivity

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
/**
 * 判断跳过节点.
 */
public boolean isSkipActivity(String historyActivityId) {
    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    String historyTaskId = jdbcTemplate.queryForObject(
            "select task_id_ from ACT_HI_ACTINST where id_=?",
            String.class, historyActivityId);

    HistoricTaskInstanceEntity historicTaskInstanceEntity = Context
            .getCommandContext().getHistoricTaskInstanceEntityManager()
            .findHistoricTaskInstanceById(historyTaskId);
    String deleteReason = historicTaskInstanceEntity.getDeleteReason();

    return "跳过".equals(deleteReason);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:18,代码来源:RollbackCmd.java

示例11: testSpring

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
@Test
public void testSpring() throws Exception {
    DataSource ds = wrap(createH2DataSource());
    JdbcTemplate jdbc = new JdbcTemplate(ds);

    jdbc.execute(DROP_USER);
    jdbc.execute(CREATE_TABLE_USER);

    jdbc.update(INSERT_INTO_USER, 1, "user1");
    User user = jdbc.queryForObject(SELECT_FROM_USER_BY_ID, new BeanPropertyRowMapper<>(User.class), 1);
    assertEquals(new User(1, "user1"), user);

    jdbc.update(DELETE_FROM_USER_BY_ID, 1);
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:15,代码来源:H2Test.java

示例12: queryObjJoinCountByCondition

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public int queryObjJoinCountByCondition(String sql){
	/*		JdbcTemplate jdbcTemplate = (JdbcTemplate) MicroDbHolder
	.getDbSource(dbName);*/
	JdbcTemplate jdbcTemplate = getMicroJdbcTemplate();
	logger.debug(sql);
	Integer total=jdbcTemplate.queryForObject(sql,Integer.class);
	return total;
}
 
开发者ID:jeffreyning,项目名称:nh-micro,代码行数:9,代码来源:MicroMetaDao.java

示例13: getUserPoint

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public int getUserPoint(int userId){
	JdbcTemplate jdbcTemplate = util.getJdbcTemplate(applicationName,OrderMessage.BUSINESS_CODE,(OrderMessage)null);
	Integer queryForObject = jdbcTemplate.queryForObject("select point from point where user_id = ?", Integer.class, userId);
	return queryForObject == null?0:queryForObject;
}
 
开发者ID:QNJR-GROUP,项目名称:EasyTransaction,代码行数:6,代码来源:PointService.java

示例14: getUserOrderCount

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public int getUserOrderCount(int userId){
	JdbcTemplate jdbcTemplate = util.getJdbcTemplate(Constant.APPID, BUSINESS_CODE, String.valueOf(userId));
	Integer queryForObject = jdbcTemplate.queryForObject("SELECT count(1) FROM `order` where user_id = ?;", Integer.class,userId);
	return queryForObject == null?0:queryForObject;
}
 
开发者ID:QNJR-GROUP,项目名称:EasyTransaction,代码行数:6,代码来源:OrderService.java

示例15: getUserTotalAmount

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public int getUserTotalAmount(int userId){
	JdbcTemplate jdbcTemplate = util.getJdbcTemplate(Constant.APPID,WalletPayTccMethod.METHOD_NAME,(WalletPayTccMethodRequest)null);
	Integer queryForObject = jdbcTemplate.queryForObject("select total_amount from wallet where user_id = ?", Integer.class, userId);
	
	return queryForObject == null?0:queryForObject;
}
 
开发者ID:QNJR-GROUP,项目名称:EasyTransaction,代码行数:7,代码来源:WalletService.java


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