HHH-5933 : NoopOptimizer ignores negative allocationSize; uses default of 1 instead

This commit is contained in:
Gail Badner 2017-04-28 19:08:27 -07:00
parent 33a28188c6
commit dfbeb1ce37
3 changed files with 37 additions and 11 deletions

View File

@ -55,6 +55,9 @@ public final class NoopOptimizer extends AbstractOptimizer {
@Override
public boolean applyIncrementSizeToSourceValues() {
return false;
// We allow the increment size to be 0 for backward-compatibility with legacy
// ID generators; we don't apply a value of 0, so the default will be used instead.
// We don't apply an increment size of 1, since it is already the default.
return getIncrementSize() != 0 && getIncrementSize() != 1;
}
}

View File

@ -362,15 +362,35 @@ public class SequenceStyleGenerator
* @return The adjusted increment size.
*/
protected int determineAdjustedIncrementSize(String optimizationStrategy, int incrementSize) {
if ( incrementSize > 1 && StandardOptimizerDescriptor.NONE.getExternalName().equals( optimizationStrategy ) ) {
LOG.honoringOptimizerSetting(
StandardOptimizerDescriptor.NONE.getExternalName(),
INCREMENT_PARAM,
incrementSize
);
incrementSize = 1;
final int resolvedIncrementSize;
if ( Math.abs( incrementSize ) > 1 &&
StandardOptimizerDescriptor.NONE.getExternalName().equals( optimizationStrategy ) ) {
if ( incrementSize < -1 ) {
resolvedIncrementSize = -1;
LOG.honoringOptimizerSetting(
StandardOptimizerDescriptor.NONE.getExternalName(),
INCREMENT_PARAM,
incrementSize,
"negative",
resolvedIncrementSize
);
}
else {
// incrementSize > 1
resolvedIncrementSize = 1;
LOG.honoringOptimizerSetting(
StandardOptimizerDescriptor.NONE.getExternalName(),
INCREMENT_PARAM,
incrementSize,
"positive",
resolvedIncrementSize
);
}
}
return incrementSize;
else {
resolvedIncrementSize = incrementSize;
}
return resolvedIncrementSize;
}
/**

View File

@ -359,11 +359,14 @@ public interface CoreMessageLogger extends BasicLogger {
void hibernateConnectionPoolSize(int poolSize, int minSize);
@LogMessage(level = WARN)
@Message(value = "Config specified explicit optimizer of [%s], but [%s=%s; honoring optimizer setting", id = 116)
@Message(value = "Config specified explicit optimizer of [%s], but [%s=%s]; using optimizer [%s] increment default of [%s].", id = 116)
void honoringOptimizerSetting(
String none,
String incrementParam,
int incrementSize);
int incrementSize,
String positiveOrNegative,
int defaultIncrementSize
);
@LogMessage(level = DEBUG)
@Message(value = "HQL: %s, time: %sms, rows: %s", id = 117)