Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * {@inheritDoc}
- */
- @Log(levelOnException = LogLevel.FATAL)
- public boolean insert(final DocumentVO document, final Long warningNumber) throws DAOException {
- return (insertCore(document) && insertBranch(document, warningNumber));
- }
- /**
- * Method responsible for inserting document reference and transfer data
- * @param document - document information
- * @return boolean - true / success, false / fail
- * @throws DAOException
- */
- @Log(levelOnException = LogLevel.FATAL)
- private boolean insertCore(final DocumentVO document) throws DAOException {
- Connection connection = null;
- PreparedStatement preparedStatement = null;
- int rowsAffected = 0;
- try {
- connection = getDataSource().getConnection();
- StringBuffer sql = new StringBuffer(449);
- sql.append("INSERT INTO OWNER.TABLE_BASE (FIELD_1, FIELD_2)" +
- " VALUES (?,?, CURRENT TIMESTAMP)");
- preparedStatement = connection.prepareStatement(sql.toString());
- preparedStatement.setLong(1, document.getDocumentId());
- preparedStatement.setLong(2, new Long(document.getUser().getId()));
- rowsAffected = preparedStatement.executeUpdate();
- } catch (SQLException e) {
- throw new DAOException(e.getMessage(), e);
- } finally {
- closeStatement(preparedStatement);
- closeConnection(connection);
- }
- return rowsAffected == 1 ? true : false;
- }
- /**
- * Method responsible for inserting relationship between document and specific Branch
- * @param document - document information
- * @param numeroAvas - Warning Number
- * @return boolean - true / success, false / fail
- * @throws DAOException
- */
- @Log(levelOnException = LogLevel.FATAL)
- private boolean insertBranch(final DocumentVO document, final Long warningNumber) throws DAOException {
- .
- .
- .
- .
Add Comment
Please, Sign In to add comment