if(returnStatusId!=null){
String sql = "INSERT INTO "+quoteTable("return_status")+"(return_status_id, language_id, name) VALUES(?, ?, ?)";
getJdbcOperations().update(sql, returnStatusId,
returnStatus.getLanguageId(), returnStatus.getName());
}else{
KeyHolder keyHolder = new GeneratedKeyHolder();
getJdbcOperations().update(new PreparedStatementCreator() {
@Override
public PreparedStatement createPreparedStatement(Connection con)
throws SQLException {
String sql = "INSERT INTO "+quoteTable("return_status")+"(language_id, name) VALUES(?, ?)";
PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
ps.setInt(1, returnStatus.getLanguageId());
ps.setString(2, returnStatus.getName());
return ps;
}
}, keyHolder);
returnStatusId = keyHolder.getKey().intValue();
}
}
}