Parameters, row mapping, single/optional/list, generated keys, batch via NamedParameterJdbcTemplate (JdbcClient has none), exception translation, transactions, an unclosed stream() exhausting a 2-connection pool, withMaxRows truncating silently, and spring.jdbc.template.* reaching the auto-configured JdbcClient. JdbcClient API diffed across 6.1.0, 6.2.19 and 7.0.0. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b5n3PRbPkUsiJybTeg
21 lines
2.3 KiB
Plaintext
21 lines
2.3 KiB
Plaintext
1 SELECT * into the Product record (in_stock -> inStock, created_on -> createdOn, stock_count -> stockCount):
|
|
Product[id=1, sku=KB-001, name=Mechanical Keyboard, price=4999.00, inStock=true, createdOn=2026-01-10, stockCount=12]
|
|
Product[id=2, sku=MS-002, name=Wireless Mouse, price=1299.50, inStock=true, createdOn=2026-02-14, stockCount=40]
|
|
Product[id=3, sku=MN-003, name=Monitor 27 inch, price=18999.00, inStock=false, createdOn=2026-03-01, stockCount=0]
|
|
Product[id=4, sku=HS-004, name=Headset, price=2499.00, inStock=true, createdOn=2026-03-22, stockCount=7]
|
|
Product[id=5, sku=WC-005, name=Webcam, price=3199.00, inStock=true, createdOn=2026-04-05, stockCount=3]
|
|
|
|
2 a record with fewer components than columns: Slim[sku=KB-001, name=Mechanical Keyboard]
|
|
3 a JavaBean with setters for three of the seven columns: Bean[sku=KB-001, price=4999.00, inStock=true]
|
|
4 a single column to a simple type: [12, 40, 0, 7, 3] and Wireless Mouse
|
|
5 a RowMapper lambda: MS-002 costs 1299.50
|
|
|
|
6 record asks for colourName, SELECT has no such column: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT sku FROM product WHERE id = 1] [root cause: JdbcSQLSyntaxErrorException: Column "colourName" not found [42122-240]]
|
|
7 record asks for primitive int missingCol, no such column: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT sku FROM product WHERE id = 1] [root cause: JdbcSQLSyntaxErrorException: Column "missingCol" not found [42122-240]]
|
|
8 VARCHAR column into a LocalDate component: org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [SELECT sku, name FROM product WHERE id = 1]; Cannot parse "DATE" constant "Mechanical Keyboard" [22007-240] [root cause: NumberFormatException: Error at index 0 in: "Mechanical Keyb"]
|
|
9 SQL NULL into the primitive int stockCount: org.springframework.core.convert.ConversionFailedException: Failed to convert from type [null] to type [int] for value [null] [root cause: IllegalArgumentException: A null value cannot be assigned to a primitive type]
|
|
the same NULL into Integer stockCount: NullBoxed[sku=KB-001, stockCount=null]
|
|
|
|
10 untyped listOfRows(): keys as the driver returns them: [SKU, IN_STOCK], value classes: [String, Boolean]
|
|
lookup is case-insensitive: row.get("sku") = KB-001
|