package org.academiadecodigo.enuminatti.hibernatebootstrap.inheritance.mappedsuperclass;

import org.academiadecodigo.enuminatti.hibernatebootstrap.SaveUtil;

/**
 * MIT License
 * (c) 2017 Ricardo Constantino
 */

public class MappedSuper {
    public static void main(String[] args) {
        SaveUtil<AbstractModel> saveUtil = new SaveUtil<>();

        Customer ricardo = new Customer("Ricardo");
        Account ricardoAccount = new Account(4000d);

        ricardo.setAccount(ricardoAccount);
        ricardoAccount.setCustomer(ricardo);

        Customer savedCustomer = (Customer) saveUtil.save(ricardo);
        Account savedAccount = (Account) saveUtil.fetch(Account.class, 1);
        System.out.println(savedAccount.getCustomer());
        System.out.println(savedCustomer.getAccount());

        saveUtil.close();
    }

}
