use of org.springframework.data.relational.core.sql.LockMode in project spring-data-jdbc by spring-projects.
the class SqlServerDialectRenderingUnitTests method shouldRenderSelectWithLockWrite.
// DATAJDBC-498
@Test
public void shouldRenderSelectWithLockWrite() {
Table table = Table.create("foo");
LockMode lockMode = LockMode.PESSIMISTIC_WRITE;
Select select = StatementBuilder.select(table.asterisk()).from(table).lock(lockMode).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT foo.* FROM foo WITH (UPDLOCK, ROWLOCK)");
}
use of org.springframework.data.relational.core.sql.LockMode in project spring-data-jdbc by spring-projects.
the class SqlServerDialectRenderingUnitTests method shouldRenderSelectWithLimitOffsetWithLockRead.
// DATAJDBC-498
@Test
public void shouldRenderSelectWithLimitOffsetWithLockRead() {
Table table = Table.create("foo");
LockMode lockMode = LockMode.PESSIMISTIC_READ;
Select select = StatementBuilder.select(table.asterisk()).from(table).limit(10).offset(20).lock(lockMode).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT foo.*, ROW_NUMBER() over (ORDER BY (SELECT 1)) AS __relational_row_number__ FROM foo WITH (HOLDLOCK, ROWLOCK) ORDER BY __relational_row_number__ OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY");
}
use of org.springframework.data.relational.core.sql.LockMode in project spring-data-jdbc by spring-projects.
the class SqlServerDialectRenderingUnitTests method shouldRenderSelectWithLimitOffsetWithLockWrite.
// DATAJDBC-498
@Test
public void shouldRenderSelectWithLimitOffsetWithLockWrite() {
Table table = Table.create("foo");
LockMode lockMode = LockMode.PESSIMISTIC_WRITE;
Select select = StatementBuilder.select(table.asterisk()).from(table).limit(10).offset(20).lock(lockMode).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT foo.*, ROW_NUMBER() over (ORDER BY (SELECT 1)) AS __relational_row_number__ FROM foo WITH (UPDLOCK, ROWLOCK) ORDER BY __relational_row_number__ OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY");
}
use of org.springframework.data.relational.core.sql.LockMode in project spring-data-jdbc by spring-projects.
the class SqlServerDialectRenderingUnitTests method shouldRenderSelectWithLimitOffsetAndOrderByWithLockWrite.
// DATAJDBC-498
@Test
public void shouldRenderSelectWithLimitOffsetAndOrderByWithLockWrite() {
Table table = Table.create("foo");
LockMode lockMode = LockMode.PESSIMISTIC_WRITE;
Select select = StatementBuilder.select(table.asterisk()).from(table).orderBy(table.column("column_1")).limit(10).offset(20).lock(lockMode).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT foo.* FROM foo WITH (UPDLOCK, ROWLOCK) ORDER BY foo.column_1 OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY");
}
use of org.springframework.data.relational.core.sql.LockMode in project spring-data-jdbc by spring-projects.
the class MySqlDialectRenderingUnitTests method shouldRenderSelectWithLimitWithLockWrite.
// DATAJDBC-498
@Test
public void shouldRenderSelectWithLimitWithLockWrite() {
Table table = Table.create("foo");
LockMode lockMode = LockMode.PESSIMISTIC_WRITE;
Select select = StatementBuilder.select(table.asterisk()).from(table).limit(10).lock(lockMode).build();
String sql = SqlRenderer.create(factory.createRenderContext()).render(select);
assertThat(sql).isEqualTo("SELECT foo.* FROM foo LIMIT 10 FOR UPDATE");
}