mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1268 - SQL Server fix for "for update" plus Sequences support plus refactor of sequences
This commit is contained in:
@@ -16,10 +16,13 @@ public class MatchingNamingConventionTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getColumnFromProperty_when_allQuoted() throws Exception {
|
||||
public void getColumnFromProperty_when_allQuoted() {
|
||||
|
||||
SqlServerPlatform platform = new SqlServerPlatform();
|
||||
platform.configure(new DbTypeConfig(), true);
|
||||
|
||||
ServerConfig config = new ServerConfig();
|
||||
config.setAllQuotedIdentifiers(true);
|
||||
platform.configure(config);
|
||||
|
||||
NamingConvention nc = new MatchingNamingConvention();
|
||||
nc.setDatabasePlatform(platform);
|
||||
@@ -29,7 +32,7 @@ public class MatchingNamingConventionTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getColumnFromProperty() throws Exception {
|
||||
public void getColumnFromProperty() {
|
||||
|
||||
String fkCol = "bridgetab_userId";
|
||||
String col = namingConvention.getColumnFromProperty(null, fkCol);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.ebean.config;
|
||||
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
import io.ebean.config.dbplatform.IdType;
|
||||
import org.avaje.datasource.DataSourceConfig;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -46,6 +47,7 @@ public class ServerConfigTest {
|
||||
props.setProperty("autoReadOnlyDataSource", "true");
|
||||
props.setProperty("disableL2Cache", "true");
|
||||
props.setProperty("notifyL2CacheInForeground", "true");
|
||||
props.setProperty("idType", "SEQUENCE");
|
||||
|
||||
serverConfig.loadFromProperties(props);
|
||||
|
||||
@@ -54,6 +56,7 @@ public class ServerConfigTest {
|
||||
assertTrue(serverConfig.isDbOffline());
|
||||
assertTrue(serverConfig.isAutoReadOnlyDataSource());
|
||||
|
||||
assertEquals(IdType.SEQUENCE, serverConfig.getIdType());
|
||||
assertEquals(PersistBatch.INSERT, serverConfig.getPersistBatch());
|
||||
assertEquals(PersistBatch.INSERT, serverConfig.getPersistBatchOnCascade());
|
||||
assertEquals(ServerConfig.DbUuid.BINARY, serverConfig.getDbTypeConfig().getDbUuid());
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package io.ebean.config.dbplatform.sqlserver;
|
||||
|
||||
import io.ebean.BackgroundExecutor;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.annotation.ForPlatform;
|
||||
import io.ebean.annotation.Platform;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class SqlServerStepSequenceTest extends BaseTestCase {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SqlServerStepSequenceTest.class);
|
||||
|
||||
@Ignore
|
||||
@ForPlatform(Platform.SQLSERVER)
|
||||
@Test
|
||||
public void seq() {
|
||||
|
||||
|
||||
server().createSqlUpdate("drop sequence if exists sqls_testseq_9876").execute();
|
||||
server().createSqlUpdate("create sequence sqls_testseq_9876 start with 1 increment by 50").execute();
|
||||
|
||||
BackgroundExecutor be = server().getBackgroundExecutor();
|
||||
DataSource ds = server().getPluginApi().getDataSource();
|
||||
|
||||
SqlServerStepSequence s = new SqlServerStepSequence(be, ds, "sqls_testseq_9876", 50);
|
||||
|
||||
Object id = s.nextId(null);
|
||||
assertThat(id).isEqualTo(1L);
|
||||
|
||||
for (int i = 0; i < 20; i++) {
|
||||
Object val = s.nextId(null);
|
||||
log.warn("val: "+val);
|
||||
}
|
||||
|
||||
log.warn("here");
|
||||
|
||||
for (int i = 0; i < 20; i++) {
|
||||
Object val = s.nextId(null);
|
||||
log.warn("val: "+val);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
Object val = s.nextId(null);
|
||||
log.warn("val: "+val);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user