In the Caveatemptor example, it creates a DAO object (e.g. UserDAO, ItemDAO) every time a command is executed (e.g. BidForItemCommand)
see below:
Code:
public void execute() throws CommandException {
try {
ItemDAO itemDAO = new ItemDAO();
UserDAO userDAO = new UserDAO();
Why is this necessary? Can we have a static object for each DAO? so we don' t need to create every time?
And in the constructor of UserDAO(), it begins a transaction.
when does it end?
public UserDAO() {
HibernateUtil.beginTransaction();
}
Thank you.