Hi,
I'm seeing different behaviour in exactly when a Hibernate generated DB operation actually occurs on the DB when I swap between MSSQL and Oracle.
The basic program flow is:
1. a create method in a CMT EJB is called
2. this calls a create method in DAO to create a record
3. a JMS message is then sent from the EJB to an MDB
4. the MDB tries to reload the new record
The DAO method is:
Code:
session = getSessionFactory().openSession();
room hibObject = populateHibObject(roomDto, session);
try {
session.save(hibObject, hibObject.getId());
session.flush();
} catch (HibernateException he) {
logger.warn(he.getLocalizedMessage());
throw new DAOException(he.getMessage());
} finally {
try {
session.close();
} catch (Exception e) {
logger.warn(e.getLocalizedMessage());
throw new DAOException(e.getMessage());
}
}
In MSSQL everything works as expected - the room is created and the MDB can reload the room. However, in Oracle this does not happen - I see
Quote:
net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists
exceptions.
Hibernate SQL debugging is identical for both platforms - when session.save() is called an insert is logged. If I step through the code in a debugger and watch what happens on the appropriate DB at the same time I see that when the insert statement is logged MSSQL shows a new room record - but with Oracle its only when the whole CMT method finishes that the insert happens. Is this behaving as expected? Or am I just missunderstanding how session.save() works in a transaction? If anyone can explain why it works like this I'd be most appreciative.
Versions:
Hibernate 2.0.3
Oracle 9i using thin JDBC driver
MS SQL Server 2000 with jTDS 0.7.1 driver
[/code]