use of org.springframework.dao.EmptyResultDataAccessException in project perun by CESNET.
the class AttributesManagerImpl method getAttributes.
public List<Attribute> getAttributes(PerunSession sess, UserExtSource ues, List<String> attrNames) throws InternalErrorException {
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("uesId", ues.getId());
parameters.addValue("nSC", AttributesManager.NS_UES_ATTR_CORE);
parameters.addValue("nSO", AttributesManager.NS_UES_ATTR_OPT);
parameters.addValue("nSD", AttributesManager.NS_UES_ATTR_DEF);
parameters.addValue("nSV", AttributesManager.NS_UES_ATTR_VIRT);
parameters.addValue("attrNames", attrNames);
try {
return namedParameterJdbcTemplate.query("select " + getAttributeMappingSelectQuery("ues") + " from attr_names " + "left join user_ext_source_attr_values ues on id=ues.attr_id and ues_id=:uesId " + "where namespace in ( :nSC,:nSO,:nSD,:nSV ) and attr_names.attr_name in ( :attrNames )", parameters, new AttributeRowMapper(sess, this, ues));
} catch (EmptyResultDataAccessException ex) {
return new ArrayList<Attribute>();
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
}
use of org.springframework.dao.EmptyResultDataAccessException in project perun by CESNET.
the class AttributesManagerImpl method getAttributes.
public List<Attribute> getAttributes(PerunSession sess, Vo vo, List<String> attrNames) throws InternalErrorException {
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("vId", vo.getId());
parameters.addValue("nSC", AttributesManager.NS_VO_ATTR_CORE);
parameters.addValue("nSO", AttributesManager.NS_VO_ATTR_OPT);
parameters.addValue("nSD", AttributesManager.NS_VO_ATTR_DEF);
parameters.addValue("nSV", AttributesManager.NS_VO_ATTR_VIRT);
parameters.addValue("attrNames", attrNames);
try {
return namedParameterJdbcTemplate.query("select " + getAttributeMappingSelectQuery("vot") + " from attr_names " + "left join vo_attr_values vot on id=vot.attr_id and vo_id=:vId " + "where namespace in ( :nSC,:nSO,:nSD,:nSV ) and attr_names.attr_name in ( :attrNames )", parameters, new AttributeRowMapper(sess, this, vo));
} catch (EmptyResultDataAccessException ex) {
return new ArrayList<Attribute>();
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
}
use of org.springframework.dao.EmptyResultDataAccessException in project perun by CESNET.
the class DatabaseManagerImpl method updateDatabaseVersion.
public void updateDatabaseVersion(List<DBVersion> dbVersions) throws InternalErrorException {
Collections.reverse(dbVersions);
for (DBVersion v : dbVersions) {
log.debug("Executing update commands of version " + v.getVersion());
List<String> successfulCommands = new ArrayList<>();
for (String c : v.getCommands()) {
try {
jdbc.execute(c);
log.debug("Command executed: " + c);
successfulCommands.add(c);
} catch (EmptyResultDataAccessException ex) {
log.error("Update unsuccessful. All versions before " + v.getVersion() + " were successfully executed. " + "Error executing command in version " + v.getVersion() + ": " + c, ex);
log.error("Successful commands from " + v.getVersion() + ": " + successfulCommands);
throw new ConsistencyErrorException("Update unsuccessful. Error executing command in version " + v.getVersion() + ": " + c, ex);
} catch (RuntimeException ex) {
log.error("Update unsuccessful. All versions before " + v.getVersion() + " were successfully executed. " + "Error executing command in version " + v.getVersion() + ": " + c, ex);
log.error("Successful commands from " + v.getVersion() + ": " + successfulCommands);
throw new InternalErrorException("Update unsuccessful. Error executing command in version " + v.getVersion() + ": " + c, ex);
}
}
}
}
use of org.springframework.dao.EmptyResultDataAccessException in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class UserRepository method findUserByNickname.
public User findUserByNickname(String nickname) {
String query = "SELECT * FROM User WHERE nickname = ?";
List<User> resultUser;
try {
resultUser = jdbcTemplate.query(query, (rs, rowNum) -> {
User user = new User();
user.setId(rs.getLong("id"));
user.setEmail(rs.getString("email"));
user.setPassword(rs.getString("password"));
user.setNickname(rs.getString("nickname"));
return user;
}, nickname);
} catch (EmptyResultDataAccessException e) {
log.error(e.getMessage());
return null;
}
return resultUser.size() > 0 ? resultUser.get(0) : null;
}
use of org.springframework.dao.EmptyResultDataAccessException in project bamboobsc by billchen198318.
the class SysMessageUtil method get.
public static String get(String code) {
if (code == null || "".equals(code)) {
return "";
}
if (sysMsgMap.get(code) != null) {
return sysMsgMap.get(code);
}
init();
if (jdbcTemplate == null) {
return "";
}
String message = null;
TbSysCode sysCode = new TbSysCode();
sysCode.setCode(code);
Map<String, Object> queryMap = getQuery(sysCode);
if (queryMap == null) {
return "";
}
try {
message = jdbcTemplate.queryForObject(((String) queryMap.get(SqlGenerateUtil.RETURN_SQL)), (Object[]) queryMap.get(SqlGenerateUtil.RETURN_PARAMS), String.class);
if (message != null) {
sysMsgMap.put(code, message);
}
} catch (EmptyResultDataAccessException eda) {
System.out.println(eda.getMessage().toString());
} catch (Exception e) {
e.printStackTrace();
}
return message == null ? code : message;
}
Aggregations