DB2 - Websphere 6.1 - java 1.5
I'm trying to implement something that I'm afraid is going to slow my application down, but wanted to see if there was a good way to do this.
The database is already built and being used by more people then just me, so changing the database structure or tables is a last resort.
I have an application that needs to read and modify tables in two different schemas. The tables in the two schemas are identical. One represents work in progress while the other represents production data.
So I would like to have the same DAO flip flop between schemas.
My concern is that because I access my DAO statically I'm going to have to synchronize the methods inside so that users don't connect to the wrong schema.
So in the Manager Class I haev
Code:
DateSensitiveDAO dao = DateSensitiveDAO.getInstance(false);
Then in the DAO
Code:
public final class DateSensitiveDAO extends BaseDAO{
private static final Logger logger = Logger.getLogger(DateSensitiveDAO.class);
private static String cfgFile = "grp_hibernate.cfg.xml";
private static final String cfgFileNonWip = "grp_hibernate.cfg.xml";
private static final String cfgFileWip = "grp_wip_hibernate.cfg.xml";
private static boolean initialized = false;
private static final DateSensitiveDAO _instance = new DateSensitiveDAO();
public static final DateSensitiveDAO getInstance(boolean isWip){
_instance.setWip(isWip);
return _instance;
}
public void setWip(boolean isWip) {
if(isWip) {
cfgFile = cfgFileWip;
}else {
cfgFile = cfgFileNonWip;
}
initialized = false;
}
.....
}
This works with just one user, but I'm worried that it's going to cause problems.
Has anyone had to do something like this?
I could just double the number of classes that I'm using and create separate objects for each table in each schema, but I'd really like to avoid having to do that.