[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-6780) Wrong Query timeout calculation

Steve Ebersole (JIRA) noreply at atlassian.com
Tue Nov 29 10:25:19 EST 2011


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6780?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole closed HHH-6780.
-------------------------------


Thanks for verifying!

> 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
>            Assignee: Steve Ebersole
>              Labels: hibernate
>             Fix For: 4.0.0.next
>
>          Time Spent: 1h 16m
>
> {code:title=org.hibernate.engine.jdbc.internal.StatementPreparerImpl.StatementPreparationTemplate#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 );
>         }
>     }
> }
> {code}
> 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