Files
spring-data-demo/mybatis/output/01-annotation-mapper.txt
T

59 lines
2.2 KiB
Plaintext

## findById(7)
==> Preparing: SELECT id, name, price, stock, active, category_id FROM product WHERE id = ?
==> Parameters: 7(Long)
<== Total: 1
result: Product[7, Product 07, 27.50, stock=9, active=true, categoryId=2]
## findById(999) (no such row, returns Optional)
==> Preparing: SELECT id, name, price, stock, active, category_id FROM product WHERE id = ?
==> Parameters: 999(Long)
<== Total: 0
result: Optional.empty
## findAll()
==> Preparing: SELECT id, name, price, stock, active, category_id FROM product ORDER BY id
==> Parameters:
<== Total: 45
rows: 45
## topPriced(3) -> List<ProductSummary> (a record)
==> Preparing: SELECT id, name, price FROM product WHERE active = TRUE ORDER BY price DESC LIMIT ?
==> Parameters: 3(Integer)
<== Total: 3
ProductSummary[id=45, name=Product 45, price=122.50]
ProductSummary[id=44, name=Product 44, price=120.00]
ProductSummary[id=43, name=Product 43, price=117.50]
## insert (id before: null)
==> Preparing: INSERT INTO product(name, price, stock, active, category_id) VALUES (?, ?, ?, ?, ?)
==> Parameters: Desk lamp(String), 39.90(BigDecimal), 12(Integer), true(Boolean), 2(Long)
<== Updates: 1
rows affected: 1
id after (written back by useGeneratedKeys): 46
## decrementStock(id=1, qty=3) (stock of product 1 is 7)
==> Preparing: UPDATE product SET stock = stock - ? WHERE id = ? AND stock >= ?
==> Parameters: 3(Integer), 1(Long), 3(Integer)
<== Updates: 1
rows affected: 1
## decrementStock(id=1, qty=500) (guard in WHERE: stock >= qty)
==> Preparing: UPDATE product SET stock = stock - ? WHERE id = ? AND stock >= ?
==> Parameters: 500(Integer), 1(Long), 500(Integer)
<== Updates: 0
rows affected: 0
## columns aliased to label / cost (id keeps its name)
with @Results: Product[7, Product 07, 27.50, stock=null, active=null, categoryId=null]
without @Results: Product[7, null, null, stock=null, active=null, categoryId=null]
## delete(1)
==> Preparing: DELETE FROM product WHERE id = ?
==> Parameters: 1(Long)
<== Updates: 1
rows affected: 1
findById(1) inside the same test transaction: Optional.empty
## a later test sees the original data again (rollback)
findAll().size() = 45, findById(1) present = true