HHH-9017 correct HSQL pooled sequences
Conflicts: hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java
This commit is contained in:
parent
b873e56c20
commit
d22c60cc68
|
@ -29,6 +29,7 @@ import java.sql.Types;
|
||||||
|
|
||||||
import org.hibernate.JDBCException;
|
import org.hibernate.JDBCException;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.StaleObjectStateException;
|
import org.hibernate.StaleObjectStateException;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.function.AvgWithArgumentCastFunction;
|
import org.hibernate.dialect.function.AvgWithArgumentCastFunction;
|
||||||
|
@ -288,10 +289,27 @@ public class HSQLDialect extends Dialect {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HSQL will start with 0, by default. In order for Hibernate to know that this not transient,
|
||||||
|
* manually start with 1.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
protected String getCreateSequenceString(String sequenceName) {
|
protected String getCreateSequenceString(String sequenceName) {
|
||||||
return "create sequence " + sequenceName + " start with 1";
|
return "create sequence " + sequenceName + " start with 1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Because of the overridden {@link #getCreateSequenceString(String)}, we must also override
|
||||||
|
* {@link #getCreateSequenceString(String, int, int)} to prevent 2 instances of "start with".
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) throws MappingException {
|
||||||
|
if ( supportsPooledSequences() ) {
|
||||||
|
return "create sequence " + sequenceName + " start with " + initialValue + " increment by " + incrementSize;
|
||||||
|
}
|
||||||
|
throw new MappingException( getClass().getName() + " does not support pooled sequences" );
|
||||||
|
}
|
||||||
|
|
||||||
protected String getDropSequenceString(String sequenceName) {
|
protected String getDropSequenceString(String sequenceName) {
|
||||||
return "drop sequence " + sequenceName;
|
return "drop sequence " + sequenceName;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue