@Test public void testUpdateThrow() throws Exception { TableInfo<Foo, String> tableInfo = new TableInfo<Foo, String>(connectionSource, null, Foo.class); DatabaseConnection connection = createMock(DatabaseConnection.class); @SuppressWarnings("unchecked") PreparedUpdate<Foo> update = createMock(PreparedUpdate.class); CompiledStatement compiledStmt = createMock(CompiledStatement.class); expect(update.compile(connection, StatementType.UPDATE)).andReturn(compiledStmt); expect(compiledStmt.runUpdate()).andThrow(new SQLException("expected")); compiledStmt.close(); StatementExecutor<Foo, String> statementExec = new StatementExecutor<Foo, String>(databaseType, tableInfo, null); replay(connection, compiledStmt, update); try { statementExec.update(connection, update); fail("should have thrown"); } catch (SQLException e) { } verify(connection, compiledStmt, update); }
public int update(DatabaseConnection databaseConnection, T data, ObjectCache objectCache) throws SQLException { if (mappedUpdate == null) { mappedUpdate = MappedUpdate.build(databaseType, tableInfo); } int result = mappedUpdate.update(databaseConnection, data, objectCache); if (dao != null && !localIsInBatchMode.get()) { dao.notifyChanges(); } return result; }
StatementExecutor implements GenericRowMapper<String[]> { public int update(DatabaseConnection databaseConnection, T data, ObjectCache objectCache) throws SQLException { if (mappedUpdate == null) { mappedUpdate = MappedUpdate.build(databaseType, tableInfo); } int result = mappedUpdate.update(databaseConnection, data, objectCache); if (dao != null && !localIsInBatchMode.get()) { dao.notifyChanges(); } return result; } }
StatementExecutor implements GenericRowMapper<String[]> { public int update(DatabaseConnection databaseConnection, T data, ObjectCache objectCache) throws SQLException { if (mappedUpdate == null) { mappedUpdate = MappedUpdate.build(databaseType, tableInfo); } int result = mappedUpdate.update(databaseConnection, data, objectCache); if (dao != null && !localIsInBatchMode.get()) { dao.notifyChanges(); } return result; } StatementExecutor(DatabaseType databaseType, TableInfo<T, ID> tableInfo, Dao<T, ID> dao); }
StatementExecutor implements GenericRowMapper<String[]> { public int update(DatabaseConnection databaseConnection, T data, ObjectCache objectCache) throws SQLException { if (mappedUpdate == null) { mappedUpdate = MappedUpdate.build(databaseType, tableInfo); } int result = mappedUpdate.update(databaseConnection, data, objectCache); if (dao != null && !localIsInBatchMode.get()) { dao.notifyChanges(); } return result; } StatementExecutor(DatabaseType databaseType, TableInfo<T, ID> tableInfo, Dao<T, ID> dao); T queryForId(DatabaseConnection databaseConnection, ID id, ObjectCache objectCache); T queryForFirst(DatabaseConnection databaseConnection, PreparedStmt<T> preparedStmt, ObjectCache objectCache); List<T> queryForAll(ConnectionSource connectionSource, ObjectCache objectCache); long queryForCountStar(DatabaseConnection databaseConnection); long queryForLong(DatabaseConnection databaseConnection, PreparedStmt<T> preparedStmt); long queryForLong(DatabaseConnection databaseConnection, String query, String[] arguments); List<T> query(ConnectionSource connectionSource, PreparedStmt<T> preparedStmt, ObjectCache objectCache); SelectIterator<T, ID> buildIterator(BaseDaoImpl<T, ID> classDao, ConnectionSource connectionSource,
			int resultFlags, ObjectCache objectCache); GenericRowMapper<T> getSelectStarRowMapper(); RawRowMapper<T> getRawRowMapper(); SelectIterator<T, ID> buildIterator(BaseDaoImpl<T, ID> classDao, ConnectionSource connectionSource,
			PreparedStmt<T> preparedStmt, ObjectCache objectCache, int resultFlags); GenericRawResults<String[]> queryRaw(ConnectionSource connectionSource, String query, String[] arguments,
			ObjectCache objectCache); GenericRawResults<UO> queryRaw(ConnectionSource connectionSource, String query,
			RawRowMapper<UO> rowMapper, String[] arguments, ObjectCache objectCache); GenericRawResults<UO> queryRaw(ConnectionSource connectionSource, String query, DataType[] columnTypes,
			RawRowObjectMapper<UO> rowMapper, String[] arguments, ObjectCache objectCache); GenericRawResults<Object[]> queryRaw(ConnectionSource connectionSource, String query, DataType[] columnTypes,
			String[] arguments, ObjectCache objectCache); GenericRawResults<UO> queryRaw(ConnectionSource connectionSource, String query,
			DatabaseResultsMapper<UO> mapper, String[] arguments, ObjectCache objectCache); int updateRaw(DatabaseConnection connection, String statement, String[] arguments); int executeRawNoArgs(DatabaseConnection connection, String statement); int executeRaw(DatabaseConnection connection, String statement, String[] arguments); int create(DatabaseConnection databaseConnection, T data, ObjectCache objectCache); int update(DatabaseConnection databaseConnection, T data, ObjectCache objectCache); int updateId(DatabaseConnection databaseConnection, T data, ID newId, ObjectCache objectCache); int update(DatabaseConnection databaseConnection, PreparedUpdate<T> preparedUpdate); int refresh(DatabaseConnection databaseConnection, T data, ObjectCache objectCache); int delete(DatabaseConnection databaseConnection, T data, ObjectCache objectCache); int deleteById(DatabaseConnection databaseConnection, ID id, ObjectCache objectCache); int deleteObjects(DatabaseConnection databaseConnection, Collection<T> datas, ObjectCache objectCache); int deleteIds(DatabaseConnection databaseConnection, Collection<ID> ids, ObjectCache objectCache); int delete(DatabaseConnection databaseConnection, PreparedDelete<T> preparedDelete); CT callBatchTasks(ConnectionSource connectionSource, Callable<CT> callable); @Override String[] mapRow(DatabaseResults results); boolean ifExists(DatabaseConnection connection, ID id); }
StatementExecutor implements GenericRowMapper<String[]> { public int update(DatabaseConnection databaseConnection, T data, ObjectCache objectCache) throws SQLException { if (mappedUpdate == null) { mappedUpdate = MappedUpdate.build(databaseType, tableInfo); } int result = mappedUpdate.update(databaseConnection, data, objectCache); if (dao != null && !localIsInBatchMode.get()) { dao.notifyChanges(); } return result; } StatementExecutor(DatabaseType databaseType, TableInfo<T, ID> tableInfo, Dao<T, ID> dao); T queryForId(DatabaseConnection databaseConnection, ID id, ObjectCache objectCache); T queryForFirst(DatabaseConnection databaseConnection, PreparedStmt<T> preparedStmt, ObjectCache objectCache); List<T> queryForAll(ConnectionSource connectionSource, ObjectCache objectCache); long queryForCountStar(DatabaseConnection databaseConnection); long queryForLong(DatabaseConnection databaseConnection, PreparedStmt<T> preparedStmt); long queryForLong(DatabaseConnection databaseConnection, String query, String[] arguments); List<T> query(ConnectionSource connectionSource, PreparedStmt<T> preparedStmt, ObjectCache objectCache); SelectIterator<T, ID> buildIterator(BaseDaoImpl<T, ID> classDao, ConnectionSource connectionSource,
			int resultFlags, ObjectCache objectCache); GenericRowMapper<T> getSelectStarRowMapper(); RawRowMapper<T> getRawRowMapper(); SelectIterator<T, ID> buildIterator(BaseDaoImpl<T, ID> classDao, ConnectionSource connectionSource,
			PreparedStmt<T> preparedStmt, ObjectCache objectCache, int resultFlags); GenericRawResults<String[]> queryRaw(ConnectionSource connectionSource, String query, String[] arguments,
			ObjectCache objectCache); GenericRawResults<UO> queryRaw(ConnectionSource connectionSource, String query,
			RawRowMapper<UO> rowMapper, String[] arguments, ObjectCache objectCache); GenericRawResults<UO> queryRaw(ConnectionSource connectionSource, String query, DataType[] columnTypes,
			RawRowObjectMapper<UO> rowMapper, String[] arguments, ObjectCache objectCache); GenericRawResults<Object[]> queryRaw(ConnectionSource connectionSource, String query, DataType[] columnTypes,
			String[] arguments, ObjectCache objectCache); GenericRawResults<UO> queryRaw(ConnectionSource connectionSource, String query,
			DatabaseResultsMapper<UO> mapper, String[] arguments, ObjectCache objectCache); int updateRaw(DatabaseConnection connection, String statement, String[] arguments); int executeRawNoArgs(DatabaseConnection connection, String statement); int executeRaw(DatabaseConnection connection, String statement, String[] arguments); int create(DatabaseConnection databaseConnection, T data, ObjectCache objectCache); int update(DatabaseConnection databaseConnection, T data, ObjectCache objectCache); int updateId(DatabaseConnection databaseConnection, T data, ID newId, ObjectCache objectCache); int update(DatabaseConnection databaseConnection, PreparedUpdate<T> preparedUpdate); int refresh(DatabaseConnection databaseConnection, T data, ObjectCache objectCache); int delete(DatabaseConnection databaseConnection, T data, ObjectCache objectCache); int deleteById(DatabaseConnection databaseConnection, ID id, ObjectCache objectCache); int deleteObjects(DatabaseConnection databaseConnection, Collection<T> datas, ObjectCache objectCache); int deleteIds(DatabaseConnection databaseConnection, Collection<ID> ids, ObjectCache objectCache); int delete(DatabaseConnection databaseConnection, PreparedDelete<T> preparedDelete); CT callBatchTasks(ConnectionSource connectionSource, Callable<CT> callable); @Override String[] mapRow(DatabaseResults results); boolean ifExists(DatabaseConnection connection, ID id);  }