Using Hibernate3.1, Hibernate-tools3.1-beta2, Oracle 10g.
I'm getting an error when trying to create a transaction. Basically, I think the problem is in the changes in SessionImpl and JDBCContext java classes between Hibernate 3.0 to 3.1. It used to work in the older version. We are using our own custom TransactionFactory. I've shown some of the differences in the code below. Anybody have any ideas on how to solve this problem? Thanks.
Here is the error (lines marked with ">>>>" are my own debug):
Code:
[java] >>>> entering beginTransaction()
[java] >>>> entering getTransaction()
[java] >>>>> hibernateTransaction is null
[java] java.lang.NullPointerException
[java] at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1263)
[java] at mycompany.myclass.doReport(Myclass.java:327)
[java] at mycompany.myclass.fillDC(Myclass.java:232)
[java] at mycompany.myclass.doMain(Myclass.java:145)
[java] at mycompany.myclass.loadPss(Myclass.java:129)
[java] at mycompany.myclass.main(Myclass.java:118)
I've looked at the Hibernate source and noticed that the Hibernate SessionImpl class method beginTransaction has changed.
SessionImpl.beginTransaction() used to look like:Code:
public Transaction beginTransaction()
throws HibernateException
{
if(!isRootSession)
log.warn("Transaction started on non-root session");
Transaction tx = jdbcContext.beginTransaction();
interceptor.afterTransactionBegin(tx);
return tx;
}
SessionImpl.beginTransaction() now looks like in 3.1:Code:
public Transaction getTransaction() throws HibernateException {
return jdbcContext.getTransaction();
}
public Transaction beginTransaction() throws HibernateException {
if ( !isRootSession ) {
log.warn("Transaction started on non-root session");
}
Transaction result = getTransaction();
result.begin();
return result;
}
I get a null pointer because my TransactionFactory's createTransaction() method returns null (which used to work before, since this method wasn't really called) when JdbcContext.getTransaction is called (in 3.1):
JdbcContext.getTransaction() looks like:Code:
public Transaction getTransaction() throws HibernateException {
if (hibernateTransaction==null) {
hibernateTransaction = owner.getFactory().getSettings()
.getTransactionFactory()
.createTransaction( this, owner );
}
return hibernateTransaction;
}