From 0a3f62abbffacb0fcd8d611942fce46f5dea5761 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Sat, 17 Aug 2019 19:38:30 +0300 Subject: [PATCH] HHH-13588 Add missed functions to MySQL Dialect: weight_string, to_base64, from_base64, regexp_replace, regexp_instr, regexp_substr --- .../main/java/org/hibernate/dialect/MySQL57Dialect.java | 7 +++++++ .../src/main/java/org/hibernate/dialect/MySQL8Dialect.java | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/MySQL57Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/MySQL57Dialect.java index 2adf0514bc..8f9ac9742a 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/MySQL57Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/MySQL57Dialect.java @@ -9,7 +9,9 @@ package org.hibernate.dialect; import java.sql.Types; import org.hibernate.dialect.function.SQLFunction; +import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.StaticPrecisionFspTimestampFunction; +import org.hibernate.type.StandardBasicTypes; /** * @author Gail Badner @@ -64,6 +66,11 @@ public class MySQL57Dialect extends MySQL55Dialect { // from_unixtime(), timestamp() are functions that return TIMESTAMP that do not support a // fractional seconds precision argument (so there's no need to override them here): + + registerFunction( "weight_string", new StandardSQLFunction( "weight_string", StandardBasicTypes.STRING ) ); + + registerFunction( "to_base64", new StandardSQLFunction( "to_base64", StandardBasicTypes.STRING ) ); + registerFunction( "from_base64", new StandardSQLFunction( "from_base64", StandardBasicTypes.STRING ) ); } /** diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/MySQL8Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/MySQL8Dialect.java index 4d145c11fc..dcda2359b6 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/MySQL8Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/MySQL8Dialect.java @@ -7,6 +7,8 @@ package org.hibernate.dialect; import org.hibernate.LockOptions; +import org.hibernate.dialect.function.StandardSQLFunction; +import org.hibernate.type.StandardBasicTypes; /** * @author Vlad Mihalcea @@ -33,6 +35,10 @@ public class MySQL8Dialect extends MySQL57Dialect { registerKeyword("PERSIST_ONLY"); registerKeyword("RANK"); registerKeyword("ROW_NUMBER"); + + registerFunction( "regexp_replace", new StandardSQLFunction( "regexp_replace", StandardBasicTypes.STRING ) ); + registerFunction( "regexp_instr", new StandardSQLFunction( "regexp_instr", StandardBasicTypes.INTEGER ) ); + registerFunction( "regexp_substr", new StandardSQLFunction( "regexp_substr", StandardBasicTypes.STRING ) ); } @Override