Guest User

Untitled

a guest
May 24th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Log(levelOnException = LogLevel.FATAL)
  5. public boolean insert(final DocumentVO document, final Long warningNumber) throws DAOException {
  6. return (insertCore(document) && insertBranch(document, warningNumber));
  7. }
  8.  
  9. /**
  10. * Method responsible for inserting document reference and transfer data
  11. * @param document - document information
  12. * @return boolean - true / success, false / fail
  13. * @throws DAOException
  14. */
  15. @Log(levelOnException = LogLevel.FATAL)
  16. private boolean insertCore(final DocumentVO document) throws DAOException {
  17. Connection connection = null;
  18. PreparedStatement preparedStatement = null;
  19. int rowsAffected = 0;
  20.  
  21. try {
  22. connection = getDataSource().getConnection();
  23.  
  24. StringBuffer sql = new StringBuffer(449);
  25.  
  26. sql.append("INSERT INTO OWNER.TABLE_BASE (FIELD_1, FIELD_2)" +
  27. " VALUES (?,?, CURRENT TIMESTAMP)");
  28.  
  29. preparedStatement = connection.prepareStatement(sql.toString());
  30. preparedStatement.setLong(1, document.getDocumentId());
  31. preparedStatement.setLong(2, new Long(document.getUser().getId()));
  32.  
  33. rowsAffected = preparedStatement.executeUpdate();
  34.  
  35.  
  36. } catch (SQLException e) {
  37. throw new DAOException(e.getMessage(), e);
  38. } finally {
  39. closeStatement(preparedStatement);
  40. closeConnection(connection);
  41. }
  42. return rowsAffected == 1 ? true : false;
  43. }
  44.  
  45. /**
  46. * Method responsible for inserting relationship between document and specific Branch
  47. * @param document - document information
  48. * @param numeroAvas - Warning Number
  49. * @return boolean - true / success, false / fail
  50. * @throws DAOException
  51. */
  52. @Log(levelOnException = LogLevel.FATAL)
  53. private boolean insertBranch(final DocumentVO document, final Long warningNumber) throws DAOException {
  54.  
  55. .
  56. .
  57. .
  58. .
Add Comment
Please, Sign In to add comment