Polishing.

Simplified the code structure.
Ensured backward compatibility by recreating some methods often immediately deprecating them.

Moved new classes to the places where they belong, so that the package ...core.sql.render depends on ...core.dialect and not the other way round.
This causes dependency cycles because dependencies in the other direction already exists.
This will be properly fixed by #1105.
For now the offending classes are ignored by the DependencyTests.

See #777
See #1105

Polishing
This commit is contained in:
Jens Schauder
2021-11-29 12:01:51 +01:00
parent 7551cbd763
commit 61c6438bc3
16 changed files with 132 additions and 112 deletions

View File

@@ -93,14 +93,12 @@ class SqlGenerator {
SqlGenerator(RelationalMappingContext mappingContext, JdbcConverter converter, RelationalPersistentEntity<?> entity,
Dialect dialect) {
final RenderContextFactory renderContextFactory = new RenderContextFactory(dialect);
this.mappingContext = mappingContext;
this.entity = entity;
this.sqlContext = new SqlContext(entity);
this.sqlRenderer = SqlRenderer.create(renderContextFactory.createRenderContext());
this.renderContext = new RenderContextFactory(dialect).createRenderContext();
this.sqlRenderer = SqlRenderer.create(renderContext);
this.columns = new Columns(entity, mappingContext, converter);
this.renderContext = renderContextFactory.createRenderContext();
}
/**

View File

@@ -888,9 +888,11 @@ public class JdbcAggregateTemplateIntegrationTests {
assertThat(loaded.testTime).isEqualTo(entity.testTime);
}
@Test // DATAJDBC-557
@Test // GH-777
public void insertWithIdOnly() {
WithIdOnly entity = new WithIdOnly();
assertThat(template.save(entity).id).isNotNull();
}

View File

@@ -219,7 +219,7 @@ public class DefaultDataAccessStrategyUnitTests {
assertThat(generatedId).isEqualTo(GENERATED_ID);
verify(namedJdbcOperations).update(eq("INSERT INTO \"DUMMY_ENTITY\" VALUES ()"),
verify(namedJdbcOperations).update(eq("INSERT INTO \"DUMMY_ENTITY\" VALUES (DEFAULT)"),
paramSourceCaptor.capture(), any(KeyHolder.class));
}

View File

@@ -398,18 +398,19 @@ class SqlGeneratorUnitTests {
SqlGenerator sqlGenerator = createSqlGenerator(IdOnlyEntity.class, PostgresDialect.INSTANCE);
String insertSqlStatement = sqlGenerator.getInsert(emptySet());
String insert = sqlGenerator.getInsert(emptySet());
assertThat(insertSqlStatement).endsWith(" VALUES (DEFAULT) ");
assertThat(insert).endsWith(" VALUES (DEFAULT)");
}
@Test //DATAJDBC-557
@Test // GH-777
void gerInsertForEmptyColumnListMsSqlServer() {
SqlGenerator sqlGenerator = createSqlGenerator(IdOnlyEntity.class, SqlServerDialect.INSTANCE);
String insertSqlStatement = sqlGenerator.getInsert(emptySet());
String insert = sqlGenerator.getInsert(emptySet());
assertThat(insertSqlStatement).endsWith(" DEFAULT VALUES ");
assertThat(insert).endsWith(" DEFAULT VALUES");
}
@Test // DATAJDBC-334