I have a problem with inserting entities, that use sequences, to a MSSQL 2014 database. I use hibernate that is shipped with Wildfly 10 CR4 (but in CR1 and CR2 I got the sam
Meanwhile the team does not solve this problem, you can create a custom dialect resolver:
public class ScopeStandardDialectResolver implements DialectResolver {
private static final long serialVersionUID = 1L;
@Override
public Dialect resolveDialect(DialectResolutionInfo info) {
Dialect customDialectResolver = customDialectResolver(info);
Log.getInstance().logInfo(Thread.currentThread().getStackTrace(), customDialectResolver.getClass().getName());
return customDialectResolver;
}
private Dialect customDialectResolver(DialectResolutionInfo info) {
final String databaseName = info.getDatabaseName();
final int majorVersion = info.getDatabaseMajorVersion();
if (isSqlServer2014(databaseName, majorVersion)) {
return new SQLServer2012Dialect();
} else {
return StandardDialectResolver.INSTANCE.resolveDialect(info);
}
}
private boolean isSqlServer2014(final String databaseName, final int majorVersion) {
return databaseName.startsWith("Microsoft SQL Server") && majorVersion == 12;
}
}
Then you configure in your persistence unit:
Based in this example: http://blog.exxeta.com/2016/03/23/dynamically-resolve-hibernate-database-dialect/