public void testOneToOnePropertyRef() {
    Session s = openSession();
    Transaction t = s.beginTransaction();
    Customer c = new Customer();
    c.setName("Emmanuel");
    c.setCustomerId("C123-456");
    c.setPersonId("P123-456");
    Account a = new Account();
    a.setCustomer(c);
    a.setPerson(c);
    a.setType('X');
    s.persist(c);
    s.persist(a);
    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    a =
        (Account)
            s.createQuery("from Account acc join fetch acc.customer join fetch acc.person")
                .uniqueResult();
    assertNotNull(a.getCustomer());
    assertTrue(Hibernate.isInitialized(a.getCustomer()));
    assertNotNull(a.getPerson());
    assertTrue(Hibernate.isInitialized(a.getPerson()));
    c = (Customer) s.createQuery("from Customer").uniqueResult();
    assertSame(c, a.getCustomer());
    assertSame(c, a.getPerson());
    s.delete(a);
    s.delete(a.getCustomer());
    s.delete(a.getPerson());
    t.commit();
    s.close();
  }
 /*
  * Adds earned interest to the account
  *
  * @param t A reference to some arbitrary Transaction object
  * @param account A reference to an Account object to which the earned interest is added
  * @param transactionType The type of transaction (eg deposit, withdrawal)
  * @param amount The amount processed during the transaction
  * @param date The date of the transaction in the form mmddyyyy
  * @param fees A description of any unusual fees
  */
 public void makeInterestDeposit(
     Transaction t,
     Account account,
     String transactionType,
     double amount,
     String date,
     String fees) {
   double earnedInterest = account.getBalance() * account.getCustomer().getSavingsInterest() / 100;
   account.addInterest();
   makeTransaction(t, account, transactionType, earnedInterest, date, fees);
 }
  /*
   * Withdraws the specified amount from an account.
   *
   * @param t A reference to some arbitrary Transaction object
   * @param account A reference to an Account object from which the deposit is subtracted
   * @param transactionType The type of transaction (eg deposit, withdrawal)
   * @param amount The amount processed during the transaction
   * @param date The date of the transaction in the form mmddyyyy
   * @param fees A description of any unusual fees
   *
   */
  public void makeWithdrawal(
      Transaction t,
      Account account,
      String transactionType,
      double amount,
      String date,
      String fees) {
    account.withdraw(amount);
    if (amount > 0) makeTransaction(t, account, transactionType, amount, date, fees);

    // Adding a separate transaction to process overdraft penalties
    if (account.getBalance() < 0)
      makeTransaction(
          t,
          account,
          "fee",
          account.getCustomer().getOverdraftPenalty(),
          date,
          "Overdraft penalty");
  }