Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Remove duplicate and unused code.

See #1695
  • Loading branch information
mp911de committed Dec 14, 2023
1 parent 04bf615 commit 95d3b63
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ private Condition mapEmbeddedObjectCondition(CriteriaDefinition criteria, MapSql

PersistentPropertyAccessor<Object> embeddedAccessor = persistentEntity.getPropertyAccessor(criteria.getValue());

String prefix = embeddedProperty.getEmbeddedPrefix();
Condition condition = null;
for (RelationalPersistentProperty nestedProperty : persistentEntity) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ Table getTable(AggregatePath path) {

Column getColumn(AggregatePath path) {
AggregatePath.ColumnInfo columnInfo = path.getColumnInfo();
AggregatePath.ColumnInfo columnInfo1 = path.getColumnInfo();
return getTable(path).column(columnInfo1.name()).as(columnInfo.alias());
return getTable(path).column(columnInfo.name()).as(columnInfo.alias());
}

Column getReverseColumn(AggregatePath path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@
* @author Bastian Wilhelm
* @author Mark Paluch
*/
public class SqlGeneratorEmbeddedUnitTests {
class SqlGeneratorEmbeddedUnitTests {

private final RelationalMappingContext context = new JdbcMappingContext();
JdbcConverter converter = new MappingJdbcConverter(context, (identifier, path) -> {
private JdbcConverter converter = new MappingJdbcConverter(context, (identifier, path) -> {
throw new UnsupportedOperationException();
});
private SqlGenerator sqlGenerator;

@BeforeEach
public void setUp() {
void setUp() {
this.context.setForceQuote(false);
this.sqlGenerator = createSqlGenerator(DummyEntity.class);
}
Expand All @@ -62,7 +62,7 @@ SqlGenerator createSqlGenerator(Class<?> type) {
}

@Test // DATAJDBC-111
public void findOne() {
void findOne() {
final String sql = sqlGenerator.getFindOne();

assertSoftly(softly -> {
Expand All @@ -85,7 +85,7 @@ public void findOne() {
}

@Test // DATAJDBC-111
public void findAll() {
void findAll() {
final String sql = sqlGenerator.getFindAll();

assertSoftly(softly -> {
Expand All @@ -108,7 +108,7 @@ public void findAll() {
}

@Test // DATAJDBC-111
public void findAllInList() {
void findAllInList() {
final String sql = sqlGenerator.getFindAllInList();

assertSoftly(softly -> {
Expand All @@ -131,7 +131,7 @@ public void findAllInList() {
}

@Test // DATAJDBC-111
public void insert() {
void insert() {
final String sql = sqlGenerator.getInsert(emptySet());

assertSoftly(softly -> {
Expand All @@ -153,7 +153,7 @@ public void insert() {
}

@Test // DATAJDBC-111
public void update() {
void update() {
final String sql = sqlGenerator.getUpdate();

assertSoftly(softly -> {
Expand All @@ -176,7 +176,7 @@ public void update() {

@Test // DATAJDBC-340
@Disabled // this is just broken right now
public void deleteByPath() {
void deleteByPath() {

final String sql = sqlGenerator
.createDeleteByPath(PersistentPropertyPathTestUtils.getPath("embedded.other", DummyEntity2.class, context));
Expand All @@ -193,15 +193,15 @@ public void deleteByPath() {
}

@Test // DATAJDBC-340
public void noJoinForEmbedded() {
void noJoinForEmbedded() {

SqlGenerator.Join join = generateJoin("embeddable", DummyEntity.class);

assertThat(join).isNull();
}

@Test // DATAJDBC-340
public void columnForEmbeddedProperty() {
void columnForEmbeddedProperty() {

assertThat(generatedColumn("embeddable.test", DummyEntity.class)) //
.extracting( //
Expand All @@ -217,28 +217,28 @@ public void columnForEmbeddedProperty() {
}

@Test // GH-1695
public void columnForEmbeddedPropertyWithPrefix() {
void columnForEmbeddedPropertyWithPrefix() {
assertThat(generatedColumn("nested.childId", WithEmbeddedAndAggregateReference.class))
.hasToString("a.nested_child_id AS nested_child_id");
}

@Test // DATAJDBC-340
public void noColumnForEmbedded() {
void noColumnForEmbedded() {

assertThat(generatedColumn("embeddable", DummyEntity.class)) //
.isNull();
}

@Test // DATAJDBC-340
public void noJoinForPrefixedEmbedded() {
void noJoinForPrefixedEmbedded() {

SqlGenerator.Join join = generateJoin("prefixedEmbeddable", DummyEntity.class);

assertThat(join).isNull();
}

@Test // DATAJDBC-340
public void columnForPrefixedEmbeddedProperty() {
void columnForPrefixedEmbeddedProperty() {

assertThat(generatedColumn("prefixedEmbeddable.test", DummyEntity.class)) //
.extracting( //
Expand All @@ -254,15 +254,15 @@ public void columnForPrefixedEmbeddedProperty() {
}

@Test // DATAJDBC-340
public void noJoinForCascadedEmbedded() {
void noJoinForCascadedEmbedded() {

SqlGenerator.Join join = generateJoin("embeddable.embeddable", DummyEntity.class);

assertThat(join).isNull();
}

@Test // DATAJDBC-340
public void columnForCascadedEmbeddedProperty() {
void columnForCascadedEmbeddedProperty() {

assertThat(generatedColumn("embeddable.embeddable.attr1", DummyEntity.class)) //
.extracting(c -> c.getName(), c -> c.getTable().getName(), c -> getAlias(c.getTable()), this::getAlias)
Expand All @@ -271,7 +271,7 @@ public void columnForCascadedEmbeddedProperty() {
}

@Test // DATAJDBC-340
public void joinForEmbeddedWithReference() {
void joinForEmbeddedWithReference() {

SqlGenerator.Join join = generateJoin("embedded.other", DummyEntity2.class);

Expand All @@ -286,7 +286,7 @@ public void joinForEmbeddedWithReference() {
}

@Test // DATAJDBC-340
public void columnForEmbeddedWithReferenceProperty() {
void columnForEmbeddedWithReferenceProperty() {

assertThat(generatedColumn("embedded.other.value", DummyEntity2.class)) //
.extracting( //
Expand Down Expand Up @@ -362,14 +362,15 @@ static class OtherEntity {
}

@Table("a")
private
record WithEmbeddedAndAggregateReference(@Id long id,
@Embedded.Nullable(prefix = "nested_") WithAggregateReference nested) {
}

record WithAggregateReference(AggregateReference<Child, Long> childId) {
private record WithAggregateReference(AggregateReference<Child, Long> childId) {
}

record Child(@Id long id) {
private record Child(@Id long id) {

}

Expand Down

0 comments on commit 95d3b63

Please sign in to comment.