我刚刚经历了几个特定请求后让我的应用程序冻结的可怕时间。 调试表明,该代码是没有上线的任何堆栈跟踪或线程终止它调用一个Spring bean的方法(单)打破:春季冻结应用程序
myDaoService.getUserById(id)
我想这是打破,不冷冻,因为表明探查同一个线程正在尝试处理后续请求。
追查是什么原因是不可能的。
幸运的是,我发现原因:我正在调用DAO方法之一的事务范围外,但它是以只读模式访问它。
现在,问题:
Do you have any clue why wasn't that traceable by debugger?
Why a method accessing db in read-only mode out of transaction caused such behavior?
Is there a way to completely forbid querying out of transaction scope?
无论我做错了,我真的很害怕的事实,在回应我的错误行为我没有得到任何异常抛出或任何其他错误输出!
我的Hibernate的配置:
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.connection.pool_size">32</property>
<property name="hibernate.jdbc.batch_size">20</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.connection.url">jdbc:postgresql://192.168.1.1/db_test</property>
<property name="hibernate.connection.password">xxxxxx</property>
<property name="hibernate.connection.username">xxxxxx</property>
春季版本是3.0
Hibernate的版本是3.6
的Tx管理器是org.springframework.orm.hibernate3.HibernateTransactionManager
因此,您所做的只是为您的DAO的方法添加了@Transactional批注? – 2011-02-10 14:25:35
@卢西亚诺Fiandesio,是) – forker 2011-02-10 15:03:37