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


Java EmptyResultDataAccessException类代码示例

本文整理汇总了Java中org.springframework.dao.EmptyResultDataAccessException的典型用法代码示例。如果您正苦于以下问题:Java EmptyResultDataAccessException类的具体用法?Java EmptyResultDataAccessException怎么用?Java EmptyResultDataAccessException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getDependencies

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
public static void getDependencies(
		Long datasetId,
		List<DatasetDependency> depends)
{
	String nativeName = null;
	try
	{
		nativeName = getJdbcTemplate().queryForObject(
				GET_DATASET_NATIVE_NAME,
				String.class,
				datasetId);
	}
	catch (EmptyResultDataAccessException e)
	{
		nativeName = null;
	}

	if (StringUtils.isNotBlank(nativeName))
	{
		getDatasetDependencies("/" + nativeName.replace(".", "/"), 1, 0, depends);
	}

}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:24,代码来源:DatasetsDAO.java

示例2: getReferences

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
public static void getReferences(
		Long datasetId,
		List<DatasetDependency> references)
{
	String nativeName = null;
	try
	{
		nativeName = getJdbcTemplate().queryForObject(
				GET_DATASET_NATIVE_NAME,
				String.class,
				datasetId);
	}
	catch (EmptyResultDataAccessException e)
	{
		nativeName = null;
	}

	if (StringUtils.isNotBlank(nativeName))
	{
		getDatasetReferences("/" + nativeName.replace(".", "/"), 1, 0, references);
	}

}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:24,代码来源:DatasetsDAO.java

示例3: getDatasetSchemaTextByVersion

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
public static String getDatasetSchemaTextByVersion(
		Long datasetId, String version)
{
	String schemaText = null;
	try
	{
		schemaText = getJdbcTemplate().queryForObject(
				GET_DATASET_SCHEMA_TEXT_BY_VERSION,
				String.class,
				datasetId, version);
	}
	catch (EmptyResultDataAccessException e)
	{
		schemaText = null;
	}
	return schemaText;
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:18,代码来源:DatasetsDAO.java

示例4: getMetricByID

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
public static Metric getMetricByID(int id, String user)
{
   	Integer userId = UserDAO.getUserIDByUserName(user);
	Metric metric = null;
	try
	{
		metric = (Metric)getJdbcTemplate().queryForObject(
				GET_METRIC_BY_ID,
				new MetricRowMapper(),
         			userId,
				id);
	}
	catch(EmptyResultDataAccessException e)
	{
		Logger.error("Metric getMetricByID failed, id = " + id);
		Logger.error("Exception = " + e.getMessage());
	}

	return metric;
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:21,代码来源:MetricsDAO.java

示例5: getFlowSnapshot

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
@Override
public FlowSnapshotEntity getFlowSnapshot(final String flowIdentifier, final Integer version) {
    final String sql =
            "SELECT " +
                    "fs.flow_id, " +
                    "fs.version, " +
                    "fs.created, " +
                    "fs.created_by, " +
                    "fs.comments " +
            "FROM " +
                    "flow_snapshot fs, " +
                    "flow f, " +
                    "bucket_item item " +
            "WHERE " +
                    "item.id = f.id AND " +
                    "f.id = ? AND " +
                    "f.id = fs.flow_id AND " +
                    "fs.version = ?";

    try {
        return jdbcTemplate.queryForObject(sql, new FlowSnapshotEntityRowMapper(),
                flowIdentifier, version);
    } catch (EmptyResultDataAccessException e) {
        return null;
    }
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:27,代码来源:DatabaseMetadataService.java

示例6: getCurrentGithubId

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
public long getCurrentGithubId() {
    KeyHolder keyHolder = new GeneratedKeyHolder();
    String sql = "SELECT stat_id FROM github_stats WHERE stat_date = current_date()";
    long statId = -1;
    try {
        statId = jdbcTemplate.queryForObject(sql, Long.class);
    } catch (EmptyResultDataAccessException e) {

        jdbcTemplate.update(
                new PreparedStatementCreator() {
                    String INSERT_SQL = "INSERT INTO github_stats (stat_date) VALUES (current_date())";
                    public PreparedStatement createPreparedStatement(Connection cn) throws SQLException {
                        PreparedStatement ps = cn.prepareStatement(INSERT_SQL, new String[] {"stat_id"});
                        return ps;
                    }
                },
                keyHolder);
        statId = keyHolder.getKey().longValue();

    }
    logger.info("Current GitHub Stats ID: " + statId);
    return statId;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:24,代码来源:GithubJobUI.java

示例7: githubStatRecordKeyReturned

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
@Test
public void githubStatRecordKeyReturned() throws Exception {
    KeyHolder keyHolder = new GeneratedKeyHolder();
    long statId = -1L;
    try {
        statId = jdbcTemplate.queryForObject("SELECT stat_id FROM github_stats WHERE stat_date = '2010-10-10'", Long.class);
    } catch (EmptyResultDataAccessException e) {

        jdbcTemplate.update(
                new PreparedStatementCreator() {
                    String INSERT_SQL = "INSERT INTO github_stats (stat_date) VALUES ('2010-10-10')";

                    public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
                        PreparedStatement ps = connection.prepareStatement(INSERT_SQL, new String[]{"stat_id"});
                        return ps;
                    }
                },
                keyHolder);
        statId = keyHolder.getKey().longValue();
    }

    assertThat(statId).isGreaterThan(0);
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:24,代码来源:GitHubTests.java

示例8: updateConfigurationValue

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
@Override
public void updateConfigurationValue(Environment env,
                                     String defaultEnvKey,
                                     String key,
                                     String value) throws DataAccessException {
	Map<String, Object> paramMap = new HashMap<>();
	paramMap.put("config_key", key);
	paramMap.put("config_value", value);
	try {
		// check, whether there is a concrete config value
		paramMap.put("config_env", env.getValue());
		namedParameterJdbcTemplate.queryForObject(this.getQuery, paramMap, new ConfigurationValueRowMapper());
	} catch (EmptyResultDataAccessException e) {
		// no... set the default to update
		LOG.trace("no concrete config value, set the default to update", e);
		paramMap.put("config_env", defaultEnvKey);
	}

	namedParameterJdbcTemplate.update(this.updateQuery, paramMap);
}
 
开发者ID:namics,项目名称:spring-configuration-support,代码行数:21,代码来源:ConfigurationDaoImpl.java

示例9: updateConfigurationValue

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
@Override
@Transactional(readOnly = false)
public void updateConfigurationValue(Environment env,
                                     String defaultEnvKey,
                                     String key,
                                     String value) throws DataAccessException {
	Map<String, Object> paramMap = new HashMap<>();
	paramMap.put("config_key", key);
	paramMap.put("config_value", value);
	try {
		// check, whether there is a concrete config value
		paramMap.put("config_env", env.getValue());
		namedParameterJdbcTemplate.queryForObject(this.getQuery, paramMap, new ConfigurationValueRowMapper());
	} catch (EmptyResultDataAccessException e) {
		// no... set the default to update
		LOG.trace("no concrete config value, set the default to update", e);
		paramMap.put("config_env", defaultEnvKey);
	}

	namedParameterJdbcTemplate.update(this.updateQuery, paramMap);
}
 
开发者ID:namics,项目名称:spring-configuration-support,代码行数:22,代码来源:ConfigurationDaoJdbcImpl.java

示例10: testSpringLocalTx

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
@Test
public void testSpringLocalTx() throws Exception {
    DataSource ds = wrap(createHsqlDataSource());
    JdbcTemplate jdbc = new JdbcTemplate(ds);
    TransactionTemplate tx = new TransactionTemplate(new DataSourceTransactionManager(ds));

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

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

    tx.execute(ts -> {
        int nb = jdbc.update(INSERT_INTO_USER, 1, "user1");
        ts.setRollbackOnly();
        return nb;
    });
    try {
        user = tx.execute(ts -> jdbc.queryForObject(SELECT_FROM_USER_BY_ID, new BeanPropertyRowMapper<>(User.class), 1));
        fail("Expected a EmptyResultDataAccessException");
    } catch (EmptyResultDataAccessException e) {
        // expected
    }
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:27,代码来源:HsqlTest.java

示例11: findByClientIdAndSubject

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
@Override
@Transactional
public RefreshTokenContext findByClientIdAndSubject(ClientID clientId, Subject subject) {
	Objects.requireNonNull(clientId, "clientId must not be null");
	Objects.requireNonNull(subject, "subject must not be null");
	try {
		RefreshTokenContext context = this.jdbcOperations.queryForObject(this.statementSelectByClientIdAndSubject,
				refreshTokenContextMapper, clientId.getValue(), subject.getValue());
		if (context.isExpired()) {
			this.jdbcOperations.update(this.statementDeleteByToken,
					ps -> ps.setString(1, context.getRefreshToken().getValue()));
			return null;
		}
		return context;
	}
	catch (EmptyResultDataAccessException e) {
		return null;
	}
}
 
开发者ID:vpavic,项目名称:simple-openid-provider,代码行数:20,代码来源:JdbcRefreshTokenStore.java

示例12: findById

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
@Override
public User findById(Integer id) {

	Map<String, Object> params = new HashMap<String, Object>();
	params.put("id", id);

	String sql = "SELECT * FROM users WHERE id=:id";

	User result = null;
	try {
		result = namedParameterJdbcTemplate.queryForObject(sql, params, new UserMapper());
	} catch (EmptyResultDataAccessException e) {
		// do nothing, return null
	}

	/*
	 * User result = namedParameterJdbcTemplate.queryForObject( sql, params,
	 * new BeanPropertyRowMapper<User>());
	 */

	return result;

}
 
开发者ID:filipebraida,项目名称:siga,代码行数:24,代码来源:UserDaoImpl.java

示例13: registerGlobalAuthentication

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
@Autowired
public void registerGlobalAuthentication(AuthenticationManagerBuilder auth) throws Exception {
    LOG.info("Registering global user details service");
    auth.userDetailsService(username -> {
        try {
            BillingUser user = billingDao.loadUser(username);
            return new User(
                    user.getUsername(),
                    user.getPassword(),
                    Collections.singletonList(() -> "AUTH")
            );
        } catch (EmptyResultDataAccessException e) {
            LOG.warn("No such user: " + username);
            throw new UsernameNotFoundException(username);
        }
    });
}
 
开发者ID:izaharkin,项目名称:JavaRestCalculator,代码行数:18,代码来源:SecurityServiceConfiguration.java

示例14: loadUser

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
public BillingUser loadUser(String username) throws EmptyResultDataAccessException {
    LOG.trace("Querying for user " + username);
    return jdbcTemplate.queryForObject(
            "SELECT username, password, enabled FROM billing.users WHERE username = ?",
            new Object[]{username},
            new RowMapper<BillingUser>() {
                @Override
                public BillingUser mapRow(ResultSet rs, int rowNum) throws SQLException {
                    return new BillingUser(
                            rs.getString("username"),
                            rs.getString("password"),
                            rs.getBoolean("enabled")
                    );
                }
            }
    );
}
 
开发者ID:izaharkin,项目名称:JavaRestCalculator,代码行数:18,代码来源:BillingDao.java

示例15: findUserByEmail

import org.springframework.dao.EmptyResultDataAccessException; //导入依赖的package包/类
@Override
@Transactional(readOnly = true)
public CalendarUser findUserByEmail(final String email) {
    if (email == null) {
        throw new IllegalArgumentException("email cannot be null");
    }
    try {
        return userRepository.findByEmail(email);
    } catch (EmptyResultDataAccessException notFound) {
        return null;
    }
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:13,代码来源:JpaCalendarUserDao.java


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