本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}