Skip to content

Commit

Permalink
HSEARCH-4228 Use specific timestamp sql type with mssql
Browse files Browse the repository at this point in the history
  • Loading branch information
fax4ever authored and yrodiere committed Jul 22, 2021
1 parent 80ef309 commit b513879
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.jdbc.spi.JdbcServices;
Expand All @@ -44,6 +45,7 @@ public class OutboxAdditionalJaxbMappingProducer implements org.hibernate.boot.s
private static final String DEFAULT_CURRENT_TIMESTAMP = "CURRENT_TIMESTAMP";
private static final String DEFAULT_TYPE_TIMESTAMP = "TIMESTAMP";
private static final String MYSQL_TYPE_TIMESTAMP = "TIMESTAMP(6)";
private static final String MSSQL_TYPE_TIMESTAMP = "datetime2";

private static final String TYPE_TIMESTAMP_PLACEHOLDER = "{{type_timestamp}}";
private static final String CURRENT_TIMESTAMP_PLACEHOLDER = "{{current_timestamp}}";
Expand Down Expand Up @@ -90,7 +92,8 @@ public Collection<MappingDocument> produceAdditionalMappings(final MetadataImple
Dialect dialect = jdbcServices.getJdbcEnvironment().getDialect();
SQLFunction timestampFunction = dialect.getFunctions().get( "current_timestamp" );

String typeTimestamp = ( dialect instanceof MySQLDialect ) ? MYSQL_TYPE_TIMESTAMP : DEFAULT_TYPE_TIMESTAMP;
String typeTimestamp = ( dialect instanceof MySQLDialect ) ? MYSQL_TYPE_TIMESTAMP :
( dialect instanceof SQLServerDialect ) ? MSSQL_TYPE_TIMESTAMP : DEFAULT_TYPE_TIMESTAMP;
String currentTimestamp = ( timestampFunction == null ) ? DEFAULT_CURRENT_TIMESTAMP :
timestampFunction.render( null, Collections.emptyList(), null );

Expand Down

0 comments on commit b513879

Please sign in to comment.