Quote:
Just included some pseudo code below.. the actually classes are a bit long winded...
What I suggest then is that you should break down your problem to a simple class with a main method. It is difficult for us to debug your problem without seeing the whole picture.
In what sort of context are you operating (within an application server or as a standalong app?).
Data doesn't automatically get persisted (as I am sure you are aware). You need to start and commit a transaction for each session (in your case each session will be speaking JBDC to a different datasource). If you want to contain your work within a single transaction then you need to use the JTA interface and XA transactions...
So - getting back to basics - your code should look something like (from the docs)
Code:
Session oracleSession =oracleFactory.openSession();
Transaction tx = null;
try {
tx = oracleSession.beginTransaction();
// do some work
tx.commit();
}
catch (Exception e) {
if (tx!=null) tx.rollback();
throw e;
}
finally {
sess.close();
}
Session hsqlSession = hsqlFactory.openSession();
Transaction tx = null;
try {
tx = hsqlSession.beginTransaction();
// do some work
tx.commit();
}
catch (Exception e) {
if (tx!=null) tx.rollback();
throw e;
}
finally {
sess.close();
}