I have a question.
We're writing Swing applications for data manipulation. We have a central "PersistenceManager", a wrapper round our current persistence layer (VBSF), that is being used throughout our program.
Code:
public interface IPersistenceManager
{
public Connection getConnection() throws PersistenceException;
public Object getId(Object obj) throws NullPointerException, PersistenceException;
public Iterator iterate(Class type) throws PersistenceException, NullPointerException;
public Iterator iterate(IQuery query) throws PersistenceException, NullPointerException;
public List list(Class type) throws PersistenceException, NullPointerException;
public List list(IQuery query) throws PersistenceException, NullPointerException;
public Object load(Class type, Serializable id) throws PersistenceException, NullPointerException;
public IQuery newQuery(Class type) throws NullPointerException;
public void refresh(Object obj) throws NullPointerException, PersistenceException;
public void remove(Object obj) throws DeleteFailedException, NullPointerException;
public void remove(IQuery query) throws DeleteFailedException, NullPointerException;
public void update(Object obj) throws PersistenceException, UpdateConflictException, NullPointerException;
}
We are looking to another persistence framework (and Hibernate is my favorite), so the plan is to replace our VBSF implementation with a Hibernate implementation.
Our program consists of "overview panels" (=grids) and "form panel" (= forms). A frame is composed from any combinations of these two components.
A typical scenario of a program is:
1. the user opens an overviewframe (f.e. Customers)
2. the user enters criteria to search a particular Customer
3. the user double clicks on the Customer in the table to go to the form panel to modify the Customer
4. he enters some data, and clicks the update button.
After reading the documentation on the hibernate website, I still have some questions:
1. do we close the session after populating the overview and do we reopen it when the user clicks the update button?
2. Or do we keep the session open for as long as the user is using the program?
3. Or can we use the disconnect/reconnect methods in between?
The ideal solution would imply that throughout the program no extra instances are made in the different frames, we don't want to have two Customer objects pointing to the same row in the CustomerTable, because changes in one frame should be reflected in other frames where the same Customer instance is being used.
Thanks for your time,
Peter