From 26041f49e1278b31d45daa9460627f13efe1f298 Mon Sep 17 00:00:00 2001 From: Vlad Mihalcea Date: Tue, 21 Nov 2017 15:02:45 +0200 Subject: [PATCH] HHH-12111 - Oracle does not support positive/negative initial sequence values for descending/ascending sequences unless MAXVALUE/MINVALUE is defined as well --- .../hibernate/dialect/Oracle8iDialect.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java index 0d79399dd7..35cc868541 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java @@ -395,6 +395,39 @@ public class Oracle8iDialect extends Dialect { return "create sequence " + sequenceName; } + @Override + protected String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) { + if ( initialValue < 0 && incrementSize > 0 ) { + return + String.format( + "%s minvalue %d start with %d increment by %d", + getCreateSequenceString( sequenceName ), + initialValue, + initialValue, + incrementSize + ); + } + else if ( initialValue > 0 && incrementSize < 0 ) { + return + String.format( + "%s maxvalue %d start with %d increment by %d", + getCreateSequenceString( sequenceName ), + initialValue, + initialValue, + incrementSize + ); + } + else { + return + String.format( + "%s start with %d increment by %d", + getCreateSequenceString( sequenceName ), + initialValue, + incrementSize + ); + } + } + @Override public String getDropSequenceString(String sequenceName) { return "drop sequence " + sequenceName;