[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6780) Wrong Query timeout calculation
Lukasz Antoniak (JIRA)
noreply at atlassian.com
Sat Oct 29 14:15:26 EDT 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6780?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44200#comment-44200 ]
Lukasz Antoniak commented on HHH-6780:
--------------------------------------
Pull request submitted: https://github.com/hibernate/hibernate-core/pull/205
> Wrong Query timeout calculation
> --------------------------------
>
> Key: HHH-6780
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6780
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 4.0.0.CR4, 4.0.0.CR5
> Environment: Hibernate 4.0.0.RC5, Spring 3.1.RC1
> Reporter: Ruben Garcia
> Labels: hibernate
>
> Class: org.hibernate.engine.jdbc.internal.StatementPreparerImpl.StatementPreparationTemplate
> Method: setStatementTimeout
> private void setStatementTimeout(PreparedStatement preparedStatement) throws SQLException {
> if ( transactionTimeOut > 0 ) {
> int timeout = (int) ( transactionTimeOut - ( System.currentTimeMillis() / 1000 ) );
> if ( timeout <= 0 ) {
> throw new TransactionException( "transaction timeout expired" );
> } else {
> preparedStatement.setQueryTimeout( timeout );
> }
> }
> }
> Test Code:
> Session session = openSession();
> Transaction transaction = session.getTransaction();
> transaction .setTimeout(20);
> This calculation will be always negative:
> int timeout = (int) ( transactionTimeOut - ( System.currentTimeMillis() / 1000 ) );
> resulting TransactionException( "transaction timeout expired" ) will be throw.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list