No special formatting for generated keys. Use 'INSERT … RETURNING id' or 'INSERT … RETURNING *' to get generated keys.
1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/DatabaseConnection.java Mon Dec 23 16:14:03 2013 +0100
1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/DatabaseConnection.java Mon Dec 23 16:19:21 2013 +0100
1.3 @@ -85,16 +85,7 @@
1.4 formatter.writeStartUpdatesResult();
1.5 formatter.writeQuery(sqlCommand.getQuery());
1.6 formatter.writeParameters(sqlCommand.getParameters());
1.7 -
1.8 - int updatedRowsCount = ps.getUpdateCount();
1.9 - formatter.writeUpdatedRowsCount(updatedRowsCount);
1.10 -
1.11 - formatter.writeStartGeneratedKeys();
1.12 - try (ResultSet rs = ps.getGeneratedKeys()) {
1.13 - processResultSetRows(rs, formatter);
1.14 - }
1.15 - formatter.writeEndGeneratedKeys();
1.16 -
1.17 + formatter.writeUpdatedRowsCount(ps.getUpdateCount());
1.18 formatter.writeEndUpdatesResult();
1.19 }
1.20
2.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/AbstractFormatter.java Mon Dec 23 16:14:03 2013 +0100
2.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/AbstractFormatter.java Mon Dec 23 16:19:21 2013 +0100
2.3 @@ -55,8 +55,6 @@
2.4 * ...@query
2.5 * ...@parameters
2.6 * ...@updatedRowsCount
2.7 - * ...generatedKeys
2.8 - * ....resultSet (see above)
2.9 */
2.10 protected enum State {
2.11
2.12 @@ -64,8 +62,7 @@
2.13 DATABASE,
2.14 RESULT_SET,
2.15 ROW,
2.16 - UPDATES_RESULT,
2.17 - GENERATED_KEYS
2.18 + UPDATES_RESULT
2.19 }
2.20
2.21 /**
2.22 @@ -134,13 +131,13 @@
2.23
2.24 @Override
2.25 public void writeStartResultSet() {
2.26 - pushState(State.RESULT_SET, EnumSet.of(State.DATABASE, State.GENERATED_KEYS));
2.27 + pushState(State.RESULT_SET, EnumSet.of(State.DATABASE));
2.28 currentRowCount = 0;
2.29 }
2.30
2.31 @Override
2.32 public void writeEndResultSet() {
2.33 - popState(EnumSet.of(State.DATABASE, State.GENERATED_KEYS));
2.34 + popState(EnumSet.of(State.DATABASE));
2.35 currentColumnsHeader = null;
2.36 }
2.37
2.38 @@ -170,7 +167,7 @@
2.39
2.40 @Override
2.41 public void writeColumnsHeader(ColumnsHeader header) {
2.42 - peekState(EnumSet.of(State.RESULT_SET, State.GENERATED_KEYS));
2.43 + peekState(EnumSet.of(State.RESULT_SET));
2.44
2.45 if (currentColumnsHeader == null) {
2.46 currentColumnsHeader = header;
2.47 @@ -229,16 +226,6 @@
2.48 peekState(EnumSet.of(State.UPDATES_RESULT));
2.49 }
2.50
2.51 - @Override
2.52 - public void writeStartGeneratedKeys() {
2.53 - pushState(State.GENERATED_KEYS, EnumSet.of(State.UPDATES_RESULT));
2.54 - }
2.55 -
2.56 - @Override
2.57 - public void writeEndGeneratedKeys() {
2.58 - popState(EnumSet.of(State.UPDATES_RESULT));
2.59 - }
2.60 -
2.61 public FormatterContext getFormatterContext() {
2.62 return formatterContext;
2.63 }
3.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/Formatter.java Mon Dec 23 16:14:03 2013 +0100
3.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/Formatter.java Mon Dec 23 16:19:21 2013 +0100
3.3 @@ -51,9 +51,5 @@
3.4
3.5 void writeUpdatedRowsCount(int updatedRowsCount);
3.6
3.7 - void writeStartGeneratedKeys();
3.8 -
3.9 - void writeEndGeneratedKeys();
3.10 -
3.11 void writeEndUpdatesResult();
3.12 }