Skip to content

Commit dba9d3f

Browse files
committed
DATAJDBC-195 - SqlGenerator now uses upper ase key words.
1 parent 2898e21 commit dba9d3f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/main/java/org/springframework/data/jdbc/core/SqlGenerator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ private String createFindAllInListSql() {
231231
}
232232

233233
private String createExistsSql() {
234-
return String.format("select count(*) from %s where %s = :id", entity.getTableName(), entity.getIdColumn());
234+
return String.format("SELECT COUNT(*) FROM %s WHERE %s = :id", entity.getTableName(), entity.getIdColumn());
235235
}
236236

237237
private String createCountSql() {
@@ -240,7 +240,7 @@ private String createCountSql() {
240240

241241
private String createInsertSql(Set<String> additionalColumns) {
242242

243-
String insertTemplate = "insert into %s (%s) values (%s)";
243+
String insertTemplate = "INSERT INTO %s (%s) VALUES (%s)";
244244

245245
LinkedHashSet<String> columnNamesForInsert = new LinkedHashSet<>(nonIdColumnNames);
246246
columnNamesForInsert.addAll(additionalColumns);
@@ -253,7 +253,7 @@ private String createInsertSql(Set<String> additionalColumns) {
253253

254254
private String createUpdateSql() {
255255

256-
String updateTemplate = "update %s set %s where %s = :%s";
256+
String updateTemplate = "UPDATE %s SET %s WHERE %s = :%s";
257257

258258
String setClause = columnNames.stream()//
259259
.map(n -> String.format("%s = :%s", n, n))//
@@ -263,7 +263,7 @@ private String createUpdateSql() {
263263
}
264264

265265
private String createDeleteSql() {
266-
return String.format("DELETE from %s where %s = :id", entity.getTableName(), entity.getIdColumn());
266+
return String.format("DELETE FROM %s WHERE %s = :id", entity.getTableName(), entity.getIdColumn());
267267
}
268268

269269
String createDeleteAllSql(PropertyPath path) {

src/test/java/org/springframework/data/jdbc/core/DefaultDataAccessStrategyUnitTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void additionalParameterForIdDoesNotLeadToDuplicateParameters() {
5858

5959
accessStrategy.insert(new DummyEntity(ORIGINAL_ID), DummyEntity.class, additionalParameters);
6060

61-
verify(jdbcOperations).update(eq("insert into DummyEntity (id) values (:id)"), paramSourceCaptor.capture(),
61+
verify(jdbcOperations).update(eq("INSERT INTO DummyEntity (id) VALUES (:id)"), paramSourceCaptor.capture(),
6262
any(KeyHolder.class));
6363
}
6464

@@ -74,8 +74,8 @@ public void additionalParametersGetAddedToStatement() {
7474
verify(jdbcOperations).update(sqlCaptor.capture(), paramSourceCaptor.capture(), any(KeyHolder.class));
7575

7676
assertThat(sqlCaptor.getValue()) //
77-
.containsSequence("insert into DummyEntity (", "id", ") values (", ":id", ")") //
78-
.containsSequence("insert into DummyEntity (", "reference", ") values (", ":reference", ")");
77+
.containsSequence("INSERT INTO DummyEntity (", "id", ") VALUES (", ":id", ")") //
78+
.containsSequence("INSERT INTO DummyEntity (", "reference", ") VALUES (", ":reference", ")");
7979
assertThat(paramSourceCaptor.getValue().getValue("id")).isEqualTo(ORIGINAL_ID);
8080
}
8181

0 commit comments

Comments
 (0)