Java 类org.springframework.dao.DataAccessException 实例源码

项目:lams    文件:OpenPersistenceManagerInViewInterceptor.java   
@Override
public void afterCompletion(WebRequest request, Exception ex) throws DataAccessException {
    String participateAttributeName = getParticipateAttributeName();
    Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
    if (count != null) {
        // Do not modify the PersistenceManager: just clear the marker.
        if (count > 1) {
            request.setAttribute(participateAttributeName, count - 1, WebRequest.SCOPE_REQUEST);
        }
        else {
            request.removeAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
        }
    }
    else {
        PersistenceManagerHolder pmHolder = (PersistenceManagerHolder)
                TransactionSynchronizationManager.unbindResource(getPersistenceManagerFactory());
        logger.debug("Closing JDO PersistenceManager in OpenPersistenceManagerInViewInterceptor");
        PersistenceManagerFactoryUtils.releasePersistenceManager(
                pmHolder.getPersistenceManager(), getPersistenceManagerFactory());
    }
}
项目:sql-utils    文件:LogJdbcTemplate.java   
@Override
public int update(String sql) throws DataAccessException {
    LogOperate logOperate = parseOperate(sql);
    Assert.notNull(logOperate,"不匹配的操作类型,日志记录失败!");
    switch (logOperate){
        case DELETE:
            deleteRecordLog(logOperate,sql);
            break;
        case UPDATE:
            updateRecordLog(logOperate,sql);
            break;
        case INSERT:
            insertRecordLog(logOperate,sql);
            break;
        default:
            break;
    }
    return super.update(sql);
}
项目:lams    文件:HibernateTemplate.java   
@Override
public Object load(final String entityName, final Serializable id, final LockMode lockMode)
        throws DataAccessException {

    return executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            if (lockMode != null) {
                return session.load(entityName, id, lockMode);
            }
            else {
                return session.load(entityName, id);
            }
        }
    });
}
项目:jshERP    文件:SupplierAction.java   
/**
 * 删除供应商
 * @return
 */
public String delete()
{
    Log.infoFileSync("====================开始调用删除供应商信息方法delete()================");
    try 
    {
           supplierService.delete(model.getSupplierID());
           tipMsg = "成功";
           tipType = 0;
       } 
    catch (DataAccessException e) 
    {
        Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getSupplierID() + "  的供应商异常", e);
        tipMsg = "失败";
           tipType = 1;
       }
    model.getShowModel().setMsgTip(tipMsg);
    logService.create(new Logdetails(getUser(), "删除供应商", model.getClientIp(),
            new Timestamp(System.currentTimeMillis())
    , tipType, "删除供应商ID为  "+ model.getSupplierID() + ",名称为  " + model.getSupplier() + tipMsg + "!", "删除供应商" + tipMsg));
    Log.infoFileSync("====================结束调用删除供应商信息方法delete()================");
    return SUCCESS;
}
项目:Equella    文件:SqlTaxonomyDataSource.java   
private Object executeSingleResultQuery(String query, Map<?, ?> params)
{
    return jdbcTemplate.query(query, params, new ResultSetExtractor()
    {
        @Override
        public Object extractData(ResultSet rs) throws SQLException, DataAccessException
        {
            Object data = null;
            if( rs.next() )
            {
                data = rs.getObject(1);

                // Sanity check - ensure only a single result
                if( rs.next() )
                {
                    throw new IncorrectResultSizeDataAccessException(1);
                }
            }
            return data;
        }
    });
}
项目:jshERP    文件:AssetNameAction.java   
/**
 * 删除资产名称
 * @return
 */
public String delete()
{
    Log.infoFileSync("====================开始调用删除资产名称信息方法delete()================");
    try 
    {
        assetnameService.delete(model.getAssetNameID());
        tipMsg = "成功";
        tipType = 0;
    } 
    catch (DataAccessException e) 
    {
        Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAssetNameID() + "  的资产名称异常", e);
        tipMsg = "失败";
        tipType = 1;
    }
    model.getShowModel().setMsgTip(tipMsg);
    logService.create(new Logdetails(getUser(), "删除资产名称", model.getClientIp(),
            new Timestamp(System.currentTimeMillis())
    , tipType, "删除资产名称ID为  "+ model.getAssetNameID() + " " + tipMsg + "!", "删除资产名称" + tipMsg));
    Log.infoFileSync("====================结束调用删除资产名称信息方法delete()================");
    return SUCCESS;
}
项目:jshERP    文件:CategoryAction.java   
/**
 * 批量删除指定ID资产类型
 * @return
 */
public String batchDelete()
{
    try
    {
        categoryService.batchDelete(model.getCategoryIDs());
           model.getShowModel().setMsgTip("成功");
           //记录操作日志使用
           tipMsg = "成功";
           tipType = 0;
       } 
    catch (DataAccessException e) 
    {
        Log.errorFileSync(">>>>>>>>>>>批量删除资产类型ID为:" + model.getCategoryIDs() + "信息异常", e);
        tipMsg = "失败";
           tipType = 1;
       }

    logService.create(new Logdetails(getUser(), "批量删除资产类型", model.getClientIp(),
               new Timestamp(System.currentTimeMillis())
       , tipType, "批量删除资产类型ID为  "+ model.getCategoryIDs() + " " + tipMsg + "!", "批量删除资产类型" + tipMsg));
    return SUCCESS;
}
项目:redis-info    文件:TestRedis.java   
@Test
public void testCallback3() {
    final Properties[] result = {null};

    redisTemplate.execute(new RedisCallback<Object>() {
        @Override
        public Object doInRedis(RedisConnection connection) throws DataAccessException {
            Properties properties = connection.info();
            System.out.println(properties);

            Enumeration<String> nameList = (Enumeration<String>) properties.propertyNames();
            while (nameList.hasMoreElements()) {
                System.out.println(nameList.nextElement());
            }

            result[0] = properties;
            return null;
        }
    });
}
项目:lams    文件:JdbcTemplate.java   
protected int update(final PreparedStatementCreator psc, final PreparedStatementSetter pss)
        throws DataAccessException {

    logger.debug("Executing prepared SQL update");
    return execute(psc, new PreparedStatementCallback<Integer>() {
        @Override
        public Integer doInPreparedStatement(PreparedStatement ps) throws SQLException {
            try {
                if (pss != null) {
                    pss.setValues(ps);
                }
                int rows = ps.executeUpdate();
                if (logger.isDebugEnabled()) {
                    logger.debug("SQL update affected " + rows + " rows");
                }
                return rows;
            }
            finally {
                if (pss instanceof ParameterDisposer) {
                    ((ParameterDisposer) pss).cleanupParameters();
                }
            }
        }
    });
}
项目:sjk    文件:AppRankDaoImpl.java   
@Override
public List<App> getAppCategoryRank(final int parentId, final int subCatalog, final int top) {
    PreparedStatementCallback<List<App>> cb = new PreparedStatementCallback<List<App>>() {
        @Override
        public List<App> doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
            ps.setInt(1, parentId);
            ps.setInt(2, subCatalog);
            ps.setInt(3, top);
            ResultSet rs = null;
            try {
                rs = ps.executeQuery();
                if (rs.last()) {
                    int count = rs.getRow();
                    List<App> list = new ArrayList<App>(count);
                    rs.beforeFirst();
                    App app = null;
                    while (rs.next()) {
                        app = appRowMapper.mapRow(rs, rs.getRow());
                        changeOutputImpl.setUrls(app);
                        list.add(app);
                    }
                    return list;
                }

            } catch (Exception e) {
                logger.error("SQL data error:", e);
                return null;
            } finally {
                if (null != rs)
                    rs.close();
            }
            return null;
        }
    };
    return jdbcTemplate.execute(QUERY_APP_CATEGORY_TOP_SQL, cb);
}
项目:alfresco-repository    文件:RepositoryAuthenticationDao.java   
@Override
public UserDetails loadUserByUsername(String incomingUserName) throws UsernameNotFoundException, DataAccessException
{
    CacheEntry userEntry = getUserEntryOrNull(incomingUserName);
    if (userEntry == null)
    {
        throw new UsernameNotFoundException("Could not find user by userName: " + incomingUserName);
    }
    UserDetails userDetails = userEntry.userDetails;
    if (userEntry.credentialExpiryDate == null || userEntry.credentialExpiryDate.getTime() >= System.currentTimeMillis())
    {
        return userDetails;
    }

    if (userDetails instanceof RepositoryAuthenticatedUser)
    {
        RepositoryAuthenticatedUser repoUser = (RepositoryAuthenticatedUser) userDetails;
        return new RepositoryAuthenticatedUser(userDetails.getUsername(), userDetails.getPassword(), userDetails.isEnabled(),
                userDetails.isAccountNonExpired(), false,
                userDetails.isAccountNonLocked(), userDetails.getAuthorities(), repoUser.getHashIndicator(), repoUser.getSalt());
    }

    throw new AlfrescoRuntimeException("Unable to retrieve a compatible UserDetails object (requires RepositoryAuthenticatedUser)");
}
项目:premier-wherehows    文件:PropertyDao.java   
public static void updateSortListProp(JsonNode props) throws IOException, SQLException, DataAccessException {
    String name = props.get("scheme").asText();
    JsonNode propNode = props.findPath("properties");
    String propString = recProp("prop.sortlist." + name) + ",";
    if (propNode.isArray()) {
        for (JsonNode p : propNode) {
            propString = propString + p.textValue() + ",";
        }
        propString = propString.substring(0, propString.length() - 1);
    } else if (propNode.isTextual()) {
        propString = propString + propNode.textValue();
    } else {
        Logger.error("passed property neither a list or array");
        throw new IllegalArgumentException();
    }
    chngProp("prop.sortlist." + name, propString);
}
项目:cas-server-4.2.1    文件:SearchModeSearchDatabaseAuthenticationHandler.java   
@Override
protected final HandlerResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential credential)
        throws GeneralSecurityException, PreventedException {

    if (StringUtils.isBlank(this.sql) || getJdbcTemplate() == null) {
        throw new GeneralSecurityException("Authentication handler is not configured correctly");
    }

    final String username = credential.getUsername();
    final String encyptedPassword = getPasswordEncoder().encode(credential.getPassword());
    final int count;
    try {
        count = getJdbcTemplate().queryForObject(this.sql, Integer.class, username, encyptedPassword);
    } catch (final DataAccessException e) {
        throw new PreventedException("SQL exception while executing query for " + username, e);
    }
    if (count == 0) {
        throw new FailedLoginException(username + " not found with SQL query.");
    }
    return createHandlerResult(credential, this.principalFactory.createPrincipal(username), null);
}
项目:sentry    文件:CustomPersistentRememberMeServices.java   
@Override
protected void onLoginSuccess(HttpServletRequest request, HttpServletResponse response, Authentication
    successfulAuthentication) {

    String login = successfulAuthentication.getName();

    log.debug("Creating new persistent login for user {}", login);
    PersistentToken token = userRepository.findOneByLogin(login).map(u -> {
        PersistentToken t = new PersistentToken();
        t.setSeries(generateSeriesData());
        t.setUser(u);
        t.setTokenValue(generateTokenData());
        t.setTokenDate(LocalDate.now());
        t.setIpAddress(request.getRemoteAddr());
        t.setUserAgent(request.getHeader("User-Agent"));
        return t;
    }).orElseThrow(() -> new UsernameNotFoundException("User " + login + " was not found in the database"));
    try {
        persistentTokenRepository.save(token);
        addCookie(token, request, response);
    } catch (DataAccessException e) {
        log.error("Failed to save persistent token ", e);
    }
}
项目:OperatieBRP    文件:ZoekPersoonRepositoryImpl.java   
@Override
public List<Long> zoekPersonen(final SqlStamementZoekPersoon sql, final boolean postgres) throws QueryCancelledException {
    final JdbcTemplate jdbcTemplate = new JdbcTemplate(masterDataSource);
    if (postgres) {
        //statement timeout zorgt ook voor het cancellen van query op server
        jdbcTemplate.execute(String.format("set local statement_timeout = %d", TimeUnit.SECONDS.toMillis(maxStatementDuurSec)));
    }
    try {
        return jdbcTemplate.queryForList(sql.getSql(), Long.class, (Object[]) sql.getParameters().toArray());
    } catch (DataAccessException e) {
        if (e.getCause() != null && e.getCause() instanceof SQLException && SQL_TIMEOUT_CODE.equals(((SQLException) e.getCause()).getSQLState())) {
            throw new QueryCancelledException(e);
        }
        throw e;
    }
}
项目:jshERP    文件:InOutItemAction.java   
/**
 * 删除收支项目
 * @return
 */
public String delete()
{
    Log.infoFileSync("====================开始调用删除收支项目信息方法delete()================");
    try 
    {
        inOutItemService.delete(model.getInOutItemID());
        tipMsg = "成功";
        tipType = 0;
    } 
    catch (DataAccessException e) 
    {
        Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getInOutItemID() + "  的收支项目异常", e);
        tipMsg = "失败";
        tipType = 1;
    }
    model.getShowModel().setMsgTip(tipMsg);
    logService.create(new Logdetails(getUser(), "删除收支项目", model.getClientIp(),
     new Timestamp(System.currentTimeMillis())
    , tipType, "删除收支项目ID为  "+ model.getInOutItemID() + ",名称为  " + model.getName() + tipMsg + "!", "删除收支项目" + tipMsg));
    Log.infoFileSync("====================结束调用删除收支项目信息方法delete()================");
    return SUCCESS;
}
项目:Learning-Spring-5.0    文件:BookDAO_JdbcTemplate.java   
@Override
public List<Book> findAllBooks(String author) {
    // TODO Auto-generated method stub
    System.out.println(author);
    String FIND_ALL_Author = "select * from book where author=?";
    return jdbcTemplate.query(FIND_ALL_Author, new String[] { author }, new ResultSetExtractor<List<Book>>() {

        List<Book> books = new ArrayList();

        @Override
        public List<Book> extractData(ResultSet set) throws SQLException, DataAccessException {
            // TODO Auto-generated method stub
            while (set.next()) {
                Book book = new Book();
                book.setAuthor(set.getString("author"));
                book.setBookName(set.getString("bookName"));
                book.setISBN(set.getLong("ISBN"));
                book.setPublication(set.getString("publication"));
                book.setDescription(set.getString("description"));
                books.add(book);
            }
            return books;
        }
    });
}
项目:sjk    文件:AppsDaoImpl.java   
@Override
public Topic getPowerTuiJianTopic(final int topicid) {
    PreparedStatementCallback<Topic> cb = new PreparedStatementCallback<Topic>() {
        @Override
        public Topic doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
            ResultSet rs = null;
            try {
                ps.setInt(1, topicid);
                rs = ps.executeQuery();
                if (!rs.next()) {
                    return null;
                }
                Topic topic = topicRowMapper.mapRow(rs, 1);
                changeOutputImpl.setUrls(topic);
                return topic;
            } finally {
                if (null != rs)
                    rs.close();
            }
        }
    };
    return jdbcTemplate.execute(topicPowerTuiJian, cb);
}
项目:bdf2    文件:LobStoreServiceImpl.java   
public void updateBinaryStream(final String id,
        final InputStream inputStream, final int contentLength)
        throws SQLException {
    final String sql = "UPDATE BDF2_BLOB_STORE SET CONTENT_=? WHERE ID_=?";
    int updatedRowCount = super.getJdbcTemplate().execute(
            sql,
            new AbstractLobCreatingPreparedStatementCallback(this
                    .getLobHandler()) {

                @Override
                protected void setValues(
                        PreparedStatement preparedstatement,
                        LobCreator lobcreator) throws SQLException,
                        DataAccessException {
                    lobcreator.setBlobAsBinaryStream(preparedstatement, 1,
                            inputStream, contentLength);
                    preparedstatement.setString(2, id);

                }
            });
    if (0 == updatedRowCount) {
        throw new SQLException(String.format(
                "未能成功更新Byte[id=%s],请检查此记录是否存在", id));
    }
}
项目:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud    文件:RegistrationDAO.java   
public String viewgroupNames() {
    return jdbcTemplate.query("select * from groups order by groupid",
            new ResultSetExtractor<String>() {
                String s = "manager,";

                public String extractData(ResultSet rs)
                        throws SQLException, DataAccessException {
                    while (rs.next()) {
                        s = s + rs.getString(2) + ",";
                    }
                    return s;
                }
            });

}
项目:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud    文件:RegistrationDAO.java   
public boolean updateRevocation(String filename) {
    String newusersql = "update CLOUDFILEDATA set REVOCATION='yes' where filename='"
            + filename.trim() + "'";

    return jdbcTemplate.execute(newusersql,
            new PreparedStatementCallback<Boolean>() {

                @Override
                public Boolean doInPreparedStatement(PreparedStatement ps)
                        throws SQLException, DataAccessException {

                    return ps.execute();
                }

            });

}
项目:kettle_support_kettle8.0    文件:RouterServiceImpl.java   
@Override
public Object select(T entity) throws DataAccessException {
    if (null != entity) {
        entity.setStatus(Constant.STATUS_ENABLED);
        return mapper.iRouterMapper.select(entity);
    }
    return null;
}
项目:kettle_support_kettle8.0    文件:QuartzGroupServiceImpl.java   
@Override
public String update(T entity) throws DataAccessException {
    if (null != entity) {
        if (mapper.update(entity) > 0) {
            return entity.getId();
        }
    }
    return null;
}
项目:lams    文件:HibernateTemplate.java   
@Override
public void lock(final Object entity, final LockMode lockMode) throws DataAccessException {
    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            session.lock(entity, lockMode);
            return null;
        }
    });
}
项目:lams    文件:OpenEntityManagerInViewInterceptor.java   
@Override
public void preHandle(WebRequest request) throws DataAccessException {

    String participateAttributeName = getParticipateAttributeName();

    WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
    if (asyncManager.hasConcurrentResult()) {
        if (applyCallableInterceptor(asyncManager, participateAttributeName)) {
            return;
        }
    }

    if (TransactionSynchronizationManager.hasResource(getEntityManagerFactory())) {
        // do not modify the EntityManager: just mark the request accordingly
        Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
        int newCount = (count != null ? count + 1 : 1);
        request.setAttribute(getParticipateAttributeName(), newCount, WebRequest.SCOPE_REQUEST);
    }
    else {
        logger.debug("Opening JPA EntityManager in OpenEntityManagerInViewInterceptor");
        try {
            EntityManager em = createEntityManager();
            EntityManagerHolder emHolder = new EntityManagerHolder(em);
            TransactionSynchronizationManager.bindResource(getEntityManagerFactory(), emHolder);

            AsyncRequestInterceptor interceptor = new AsyncRequestInterceptor(getEntityManagerFactory(), emHolder);
            asyncManager.registerCallableInterceptor(participateAttributeName, interceptor);
            asyncManager.registerDeferredResultInterceptor(participateAttributeName, interceptor);
        }
        catch (PersistenceException ex) {
            throw new DataAccessResourceFailureException("Could not create JPA EntityManager", ex);
        }
    }
}
项目:kettle_support_kettle8.0    文件:KettleResultServiceImpl.java   
@Override
public List<?> selectByWhere(T entity) throws DataAccessException {
    if (null != entity) {
        return mapper.iKettleResultMapper.selectByWhere(entity);
    }
    return null;
}
项目:kettle_support_kettle8.0    文件:KettleReposServiceImpl.java   
@Override
public String delete(String id) throws DataAccessException {
    if (null != id && !"".equals(id)) {
        if (mapper.iKettleReposMapper.delete(id) > 0) {
            return id;
        }
    }
    return id;
}
项目:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud    文件:RegistrationDAO.java   
public Boolean createUserFloders(int groupid, final String groupname) {

        return jdbcTemplate
                .query(
                        "select (select USERLOGIN.loginid from USERLOGIN where userid=GROUPUSERS.userid) from GROUPUSERS where groupid="
                                + groupid, new ResultSetExtractor<Boolean>() {
                            public Boolean extractData(ResultSet rs)
                                    throws SQLException, DataAccessException {
                                while (rs.next()) {
                                    try {
                                        System.out.println("aaaaa"
                                                + new File(groupname)
                                                        .getAbsolutePath());
                                        boolean path = new File(new File(
                                                groupname).getAbsolutePath()
                                                + "\\" + rs.getString(1))
                                                .mkdir();

                                        createCloudFile(rs.getString(1),
                                                new File(groupname)
                                                        .getAbsolutePath()
                                                        + "\\"
                                                        + rs.getString(1));
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                                return true;
                            }
                        });

    }
项目:kettle_support_kettle8.0    文件:KettleSpoonServiceImpl.java   
@Override
public Object select(T entity) throws DataAccessException {
    if (null != entity) {
        return mapper.iKettleSpoonMapper.select(entity);
    }
    return null;
}
项目:lams    文件:HibernateTemplate.java   
@Override
public void flush() throws DataAccessException {
    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            session.flush();
            return null;
        }
    });
}
项目:lams    文件:HibernateTemplate.java   
@Override
public void persist(final String entityName, final Object entity) throws DataAccessException {
    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            session.persist(entityName, entity);
            return null;
        }
    });
}
项目:lams    文件:HibernateTemplate.java   
@Override
public Serializable save(final Object entity) throws DataAccessException {
    return executeWithNativeSession(new HibernateCallback<Serializable>() {
        @Override
        public Serializable doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            return session.save(entity);
        }
    });
}
项目:kettle_support_kettle8.0    文件:RoleServiceImpl.java   
@Override
public Object insert(T entity) throws DataAccessException {
    if (null != entity) {
        entity.setId(ObjectID.id());
        if (((Integer) mapper.iRoleMapper.insert(entity)) > 0) {
            return entity.getId();
        }
    }
    return null;
}
项目:lams    文件:HibernateTemplate.java   
@Override
public void delete(final Object entity, final LockMode lockMode) throws DataAccessException {
    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            checkWriteOperationAllowed(session);
            if (lockMode != null) {
                session.lock(entity, lockMode);
            }
            session.delete(entity);
            return null;
        }
    });
}
项目:lams    文件:VoteService.java   
@Override
   public List<VoteUsrAttempt> getAttemptsForUserAndQuestionContent(final Long userUid, final Long questionUid) {
try {
    return voteUsrAttemptDAO.getAttemptsForUserAndQuestionContent(userUid, questionUid);
} catch (DataAccessException e) {
    throw new VoteApplicationException(
        "Exception occured when lams is getting vote voteUsrRespDAO by user id and que content id: "
            + e.getMessage(),
        e);
}
   }
项目:premier-wherehows    文件:PropertyDao.java   
public static void updateProp(JsonNode prop, String base, String attr, String val_name) throws IOException, SQLException, DataAccessException, IncompleteJsonException {
    if (prop.has(val_name) && prop.has("scheme")) {
        String name = base + "." + attr + "." + prop.get("scheme").asText();
        String value = prop.get(val_name).asText();
        chngProp(name, value);
    } else {
        throw new IncompleteJsonException("Json missing scheme and or " + val_name);
    }
}
项目:spring-configuration-support    文件:ConfigurationDaoJdbcImpl.java   
@Override
@Transactional(readOnly = true)
public Collection<ConfigurationValue> getConfiguration(Environment env,
                                                       String defaultEnvKey) throws DataAccessException {
    Map<String, Object> paramMap = new HashMap<>();
    paramMap.put("config_env", env.getValue());
    paramMap.put("default_env_key", defaultEnvKey);
    return namedParameterJdbcTemplate.query(this.listQuery, paramMap, new ConfigurationValueRowMapper());
}
项目:factcast    文件:PGCatchUpPrepare.java   
public long prepareCatchup(AtomicLong serial) {
    PGQueryBuilder b = new PGQueryBuilder(req);
    long clientId = jdbc.queryForObject(PGConstants.NEXT_FROM_CATCHUP_SEQ, Long.class);
    String catchupSQL = b.catchupSQL(clientId);
    return jdbc.execute(catchupSQL, new PreparedStatementCallback<Long>() {

        @Override
        public Long doInPreparedStatement(PreparedStatement ps) throws SQLException,
                DataAccessException {

            log.debug("{} preparing paging for matches after {}", req, serial.get());
            try {
                Stopwatch sw = Stopwatch.createStarted();
                b.createStatementSetter(serial).setValues(ps);
                int numberOfFactsToCatchup = ps.executeUpdate();
                sw.stop();
                if (numberOfFactsToCatchup > 0) {
                    log.debug("{} prepared {} facts for cid={} in {}ms", req,
                            numberOfFactsToCatchup, clientId, sw.elapsed(
                                    TimeUnit.MILLISECONDS));
                    return clientId;
                } else {
                    log.debug("{} nothing to catch up", req);
                    return 0L;
                }
            } catch (SQLException ex) {
                log.error("While trying to prepare catchup", ex);
                throw ex;
            }
        }
    });

}
项目:lams    文件:HibernateTemplate.java   
@Override
public void refresh(final Object entity, final LockMode lockMode) throws DataAccessException {
    executeWithNativeSession(new HibernateCallback<Object>() {
        @Override
        public Object doInHibernate(Session session) throws HibernateException {
            if (lockMode != null) {
                session.refresh(entity, lockMode);
            }
            else {
                session.refresh(entity);
            }
            return null;
        }
    });
}
项目:wherehowsX    文件:DatabaseWriter.java   
/**
 * use JDBC template PreparedStatement to update row in database by setting columns with conditions
 * @param columns String[] column names to update
 * @param columnValues Object[] new values
 * @param conditions String[] conditions
 * @param conditionValues Object[] condition values
 */
public void update(String[] columns, Object[] columnValues, String[] conditions, Object[] conditionValues)
    throws DataAccessException {
  if (columns.length != columnValues.length || conditions.length != conditionValues.length) {
    logger.error("DatabaseWriter update columns and values mismatch");
    return;
  }
  Object[] values = Arrays.copyOf(columnValues, columnValues.length + conditionValues.length);
  System.arraycopy(conditionValues, 0, values, columnValues.length, conditionValues.length);

  final String sql = PreparedStatementUtil.prepareUpdateTemplateWithColumn(tableName, columns, conditions);
  //logger.debug("DatabaseWriter template for " + record0.getClass() + " : " + sql);

  execute(sql, values);
}