HHH-14350 MariaDB103Dialect requires the lock wait timeout to be expressed in seconds

This commit is contained in:
nicklas.wallgren 2020-11-26 13:35:52 +01:00 committed by Sanne Grinovero
parent 3de7fb653e
commit 53a5c7fa97
2 changed files with 9 additions and 2 deletions

View File

@ -245,7 +245,7 @@ public class LockOptions implements Serializable {
* <p/>
* See {@link #getTimeOut} for a discussion of meaning.
*
* @param timeout The new timeout setting.
* @param timeout The new timeout setting, in milliseconds
*
* @return this (for method chaining).
*

View File

@ -6,6 +6,8 @@
*/
package org.hibernate.dialect;
import java.time.Duration;
import org.hibernate.LockOptions;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorMariaDBDatabaseImpl;
@ -72,7 +74,7 @@ public class MariaDB103Dialect extends MariaDB102Dialect {
}
if ( timeout > 0 ) {
return getForUpdateString() + " wait " + timeout;
return getForUpdateString() + " wait " + getLockWaitTimeoutInSeconds( timeout );
}
return getForUpdateString();
@ -88,4 +90,9 @@ public class MariaDB103Dialect extends MariaDB102Dialect {
return getForUpdateString( aliases ) + " nowait";
}
private static long getLockWaitTimeoutInSeconds(int timeoutInMilliseconds) {
Duration duration = Duration.ofMillis( timeoutInMilliseconds );
return duration.getSeconds();
}
}