public TransactionDBTO toTransactionDBTO(Transaction transaction) {
    String username = transaction.getUser().getUsername();

    String category = transaction.getCategory().getName();
    Date date = transaction.getDate().getDate();
    String currency = transaction.getCurrency().getType();

    return toTransactionDBTO(transaction, username, category, date, currency);
  }
  public Transaction toTransaction(TransactionDBTO transactionDBTO) {
    Transaction transaction = new Transaction();
    BeanUtils.copyProperties(transactionDBTO, transaction, "user", "date", "currency", "category");

    UserDBTO userDBTO = transactionDBTO.getUser();
    User user = userAdapter.toUser(userDBTO);
    transaction.setUser(user);

    DateDBTO dateDBTO = transactionDBTO.getDate();
    it.ow.stage.persistence.model.Date date = dateAdapter.toDate(dateDBTO);
    transaction.setDate(date);

    CategoryDBTO categoryDBTO = transactionDBTO.getCategory();
    Category category = categoryAdapter.toCategory(categoryDBTO);
    transaction.setCategory(category);

    CurrencyDBTO currencyDBTO = transactionDBTO.getCurrency();
    Currency currency = currencyAdapter.toCurrency(currencyDBTO);
    transaction.setCurrency(currency);

    return transaction;
  }