15
15
16
16
import java .sql .Connection ;
17
17
18
- import static org .hibernate .Timeouts .NO_WAIT ;
19
18
import static org .hibernate .Timeouts .NO_WAIT_MILLI ;
20
19
import static org .hibernate .Timeouts .SKIP_LOCKED_MILLI ;
21
20
import static org .hibernate .Timeouts .WAIT_FOREVER ;
@@ -82,11 +81,9 @@ public Timeout getLockTimeout(Connection connection, SessionFactoryImplementor f
82
81
return Helper .getLockTimeout (
83
82
"show lock_timeout" ,
84
83
(resultSet ) -> {
85
- // see https://dev.mysql.com/doc/refman/8.4/en/innodb-parameters.html#sysvar_innodb_lock_wait_timeout
86
84
final int millis = resultSet .getInt ( 1 );
87
85
return switch ( millis ) {
88
- case 0 -> NO_WAIT ;
89
- case 100000000 -> WAIT_FOREVER ;
86
+ case 0 -> WAIT_FOREVER ;
90
87
default -> Timeout .milliseconds ( millis );
91
88
};
92
89
},
@@ -103,15 +100,14 @@ public void setLockTimeout(
103
100
Helper .setLockTimeout (
104
101
timeout ,
105
102
(t ) -> {
106
- // see https://dev.mysql.com/doc/refman/8.4/en/innodb-parameters.html#sysvar_innodb_lock_wait_timeout
107
103
final int milliseconds = timeout .milliseconds ();
108
104
if ( milliseconds == SKIP_LOCKED_MILLI ) {
109
105
throw new HibernateException ( "Connection lock-timeout does not accept skip-locked" );
110
106
}
111
- if ( milliseconds == WAIT_FOREVER_MILLI ) {
112
- return 100000000 ;
107
+ if ( milliseconds == NO_WAIT_MILLI ) {
108
+ throw new HibernateException ( "Connection lock-timeout does not accept no-wait" ) ;
113
109
}
114
- return milliseconds ;
110
+ return milliseconds == WAIT_FOREVER_MILLI ? 0 : milliseconds ;
115
111
},
116
112
"set lock_timeout = %s" ,
117
113
connection ,
0 commit comments