-1
我有這樣的代碼:休眠誤差節目是事務是活動的
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
...
public void commitTransaction() throws PersistenceException {
Transaction t = (Transaction) transaction.get();
if (t == null) {
throw new PersistenceException("Pas de transaction ouverte");
} else if (!t.isActive()) {
throw new PersistenceException("Transaction déjà fermée");
}
t.commit();
transaction.set(null);
closeSession();
}
但我在此行中的錯誤:
...} else if (!t.isActive()) {...
消息錯誤:
The method isActive() is undefined for the type Transaction
我使用hibernate-core-5.0.7.Final.jar
當我看在interface Transaction
有沒有函數isActive()
爲什麼在老版本的hibernate-core ..中存在?
'TransactionSynchronizationManager'用於Spring .. ?? – Mercer
我看你正在尋找冬眠。您將不得不使用會話對象來查詢session.getTransaction()。isActive()。 –