我正在运行以下代码;我无法显示完整的代码,因为它很长很复杂。
我遇到的问题是代码卡在entityManager.flush()
上。
触发保存命令的请求超时。
如何调试entityManager.flush()
?
/**
* @param saveKpi
* @return
*/
@Transactional
public KpiDefinition save(KpiDefinition saveKpi)
{
logger.info("Save KPI object");
try
{
entityManager.merge(saveKpi);
logger.info("Saved KPI object");
} catch (Exception e)
{
logger.error("Not able to save KPI object", e);
}
logger.debug("entityManager.flush()");
try {
//throw new Exception("get stacktrace");
entityManager.flush();
logger.debug("entityManager.flushed()");
} catch (Throwable t) {
logger.error("Exception caught");
logger.error(t.toString());
StackTraceElement[] stes = t.getStackTrace();
for(StackTraceElement ste : stes) {
logger.debug("stack: " + ste.toString());
}
}
return saveKpi;
}
没有例外。
我将根日志记录级别设置为DEBUG并获得以下输出,但是我不确定它的哪一部分适用于我的问题:
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open Result
Sets: 0, globally: 0)
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open Resul
tSets: 1, globally: 1)
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (op
en PreparedStatements: 1, globally: 2)
DEBUG: org.hibernate.engine.StatefulPersistenceContext - initializing non-lazy c
ollections
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Initiating transactio
n commit
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Committing JPA transa
ction on EntityManager [org.hibernate.ejb.EntityManagerImpl@28ce8c30]
DEBUG: org.hibernate.transaction.JDBCTransaction - commit
DEBUG: org.hibernate.transaction.JDBCTransaction - re-enabling autocommit
DEBUG: org.hibernate.transaction.JDBCTransaction - committed JDBC Connection
DEBUG: org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connec
tion
DEBUG: org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open
PreparedStatements: 0, globally: 1) (open ResultSets: 0, globally: 0)]
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Closing JPA EntityMan
ager [org.hibernate.ejb.EntityManagerImpl@28ce8c30] after transaction
DEBUG: org.springframework.orm.jpa.EntityManagerFactoryUtils - Closing JPA Entit
yManager
DEBUG: org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Creating new transact
ion with name [com.monitor.app.dao.kpi.DbConnectionDAO.fetchNonActiveDataba
se]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
DEBUG: org.hibernate.impl.SessionImpl - opened session at timestamp: 63791047098
12224
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Opened new EntityMana
ger [org.hibernate.ejb.EntityManagerImpl@74d5355b] for JPA transaction
DEBUG: org.hibernate.transaction.JDBCTransaction - begin
DEBUG: org.hibernate.jdbc.ConnectionManager - opening JDBC connection
DEBUG: org.hibernate.transaction.JDBCTransaction - current autocommit status: tr
ue
DEBUG: org.hibernate.transaction.JDBCTransaction - disabling autocommit
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Exposing JPA transact
ion as JDBC transaction [org.springframework.orm.jpa.vendor.HibernateJpaDialect$
HibernateConnectionHandle@7cc457d2]
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (ope
n PreparedStatements: 0, globally: 1)
DEBUG: org.hibernate.SQL - select CONNECTION_NAME from _MONITORING_CONFIGUR
ATION.DB_CONNECTION where DB_CONNECTION_ID in (select DB_CONNECTION_ID from RATO
R_MONITORING.DB_CONNECTION_STATUS where STATUS != 'G')
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open Result
Sets: 0, globally: 0)
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open Resul
tSets: 1, globally: 1)
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (op
en PreparedStatements: 1, globally: 2)
DEBUG: org.hibernate.engine.StatefulPersistenceContext - initializing non-lazy c
ollections
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Initiating transactio
n commit
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Committing JPA transa
ction on EntityManager [org.hibernate.ejb.EntityManagerImpl@74d5355b]
DEBUG: org.hibernate.transaction.JDBCTransaction - commit
DEBUG: org.hibernate.transaction.JDBCTransaction - re-enabling autocommit
DEBUG: org.hibernate.transaction.JDBCTransaction - committed JDBC Connection
DEBUG: org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connec
tion
DEBUG: org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open
PreparedStatements: 0, globally: 1) (open ResultSets: 0, globally: 0)]
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Closing JPA EntityMan
ager [org.hibernate.ejb.EntityManagerImpl@74d5355b] after transaction
DEBUG: org.springframework.orm.jpa.EntityManagerFactoryUtils - Closing JPA Entit
yManager
INFO : com.monitor.app.controller.LoginController - Request timeOut ajaxCa
l Details Url Name :: saveKpi Date :: May 9, 2019 12:43:33 PM CEST
DEBUG: org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
DEBUG: org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
DEBUG: org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
DEBUG: org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Creating new transact
ion with name [com.monitor.app.dao.kpi.DbConnectionDAO.fetchNonActiveDataba
se]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
DEBUG: org.hibernate.impl.SessionImpl - opened session at timestamp: 63791051573
65760
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Opened new EntityMana
ger [org.hibernate.ejb.EntityManagerImpl@93a6370] for JPA transaction
DEBUG: org.hibernate.transaction.JDBCTransaction - begin
DEBUG: org.hibernate.jdbc.ConnectionManager - opening JDBC connection
DEBUG: org.hibernate.transaction.JDBCTransaction - current autocommit status: tr
ue
DEBUG: org.hibernate.transaction.JDBCTransaction - disabling autocommit
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Exposing JPA transact
ion as JDBC transaction [org.springframework.orm.jpa.vendor.HibernateJpaDialect$
HibernateConnectionHandle@3a650f29]
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (ope
n PreparedStatements: 0, globally: 1)
DEBUG: org.hibernate.SQL - select CONNECTION_NAME from _MONITORING_CONFIGUR
ATION.DB_CONNECTION where DB_CONNECTION_ID in (select DB_CONNECTION_ID from RATO
R_MONITORING.DB_CONNECTION_STATUS where STATUS != 'G')
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open Result
Sets: 0, globally: 0)
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open Resul
tSets: 1, globally: 1)
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (op
en PreparedStatements: 1, globally: 2)
DEBUG: org.hibernate.engine.StatefulPersistenceContext - initializing non-lazy c
ollections
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Initiating transactio
n commit
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Committing JPA transa
ction on EntityManager [org.hibernate.ejb.EntityManagerImpl@93a6370]
DEBUG: org.hibernate.transaction.JDBCTransaction - commit
DEBUG: org.hibernate.transaction.JDBCTransaction - re-enabling autocommit
DEBUG: org.hibernate.transaction.JDBCTransaction - committed JDBC Connection
DEBUG: org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connec
tion
DEBUG: org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open
PreparedStatements: 0, globally: 1) (open ResultSets: 0, globally: 0)]
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Closing JPA EntityMan
ager [org.hibernate.ejb.EntityManagerImpl@93a6370] after transaction
DEBUG: org.springframework.orm.jpa.EntityManagerFactoryUtils - Closing JPA Entit
yManager
DEBUG: org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
DEBUG: org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Creating new transact
ion with name [com.monitor.app.dao.kpi.DbConnectionDAO.fetchNonActiveDataba
se]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
DEBUG: org.hibernate.impl.SessionImpl - opened session at timestamp: 63791053242
44992
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Opened new EntityMana
ger [org.hibernate.ejb.EntityManagerImpl@a30844] for JPA transaction
DEBUG: org.hibernate.transaction.JDBCTransaction - begin
DEBUG: org.hibernate.jdbc.ConnectionManager - opening JDBC connection
DEBUG: org.hibernate.transaction.JDBCTransaction - current autocommit status: tr
ue
DEBUG: org.hibernate.transaction.JDBCTransaction - disabling autocommit
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Exposing JPA transact
ion as JDBC transaction [org.springframework.orm.jpa.vendor.HibernateJpaDialect$
HibernateConnectionHandle@122d433e]
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (ope
n PreparedStatements: 0, globally: 1)
DEBUG: org.hibernate.SQL - select CONNECTION_NAME from _MONITORING_CONFIGUR
ATION.DB_CONNECTION where DB_CONNECTION_ID in (select DB_CONNECTION_ID from RATO
R_MONITORING.DB_CONNECTION_STATUS where STATUS != 'G')
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open Result
Sets: 0, globally: 0)
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open Resul
tSets: 1, globally: 1)
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (op
en PreparedStatements: 1, globally: 2)
DEBUG: org.hibernate.engine.StatefulPersistenceContext - initializing non-lazy c
ollections
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Initiating transactio
n commit
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Committing JPA transa
ction on EntityManager [org.hibernate.ejb.EntityManagerImpl@a30844]
DEBUG: org.hibernate.transaction.JDBCTransaction - commit
DEBUG: org.hibernate.transaction.JDBCTransaction - re-enabling autocommit
DEBUG: org.hibernate.transaction.JDBCTransaction - committed JDBC Connection
DEBUG: org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connec
tion
DEBUG: org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open
PreparedStatements: 0, globally: 1) (open ResultSets: 0, globally: 0)]
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Closing JPA EntityMan
ager [org.hibernate.ejb.EntityManagerImpl@a30844] after transaction
DEBUG: org.springframework.orm.jpa.EntityManagerFactoryUtils - Closing JPA Entit
yManager
DEBUG: org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
DEBUG: org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
更新:
我添加了行entityManager.setFlushMode(javax.persistence.FlushModeType.AUTO);
,并在服务器重新启动后进行保存。我对此不太满意,因为我不知道实际发生了什么。