我有一个从未遇到过的非常奇怪的问题。我在JSF中有一些标记为@Transactional
的方法。但是当我在下面的示例中调用fileDb.flush()函数时
@Transactional
public String toggleHide() {
fileBean.setFile(fileDb.updateFile(fileBean.getFile()));
if (getEvent().getSubType().equals("note")) {
// note
for (Note note : fileBean.getFile().getNotes()) {
if (note.getId() == getEvent().getEventId()) {
note.setHide(opposite(getEvent().isHidden()));
fileDb.flush();
break;
}
}
}
}
我收到以下错误
<openjpa-2.4.3-r422266:1833086 nonfatal user error> org.apache.openjpa.persistence.TransactionRequiredException: Can only perform operation while a transaction is active.
at org.apache.openjpa.kernel.BrokerImpl.assertActiveTransaction(BrokerImpl.java:4729)
at org.apache.openjpa.kernel.DelegatingBroker.assertActiveTransaction(DelegatingBroker.java:1385)
at org.apache.openjpa.persistence.EntityManagerImpl.flush(EntityManagerImpl.java:663)
at org.apache.webbeans.custom.persistence.EntityManager$$OwbNormalScopeProxy0.flush(javax/persistence/EntityManager.java)
at uk.me.kissy.database.db.file.FileDb.flush(FileDb.java:379)
at uk.me.kissy.database.db.file.FileDb$$OwbNormalScopeProxy0.flush(uk/me/kissy/database/db/file/FileDb.java)
at uk.me.kissy.file.beans.EventsBean.toggleHide(EventsBean.java:117)
有什么方法可以检查当前交易的状态吗?