# @Embeddable record Money(amount, currency) inside Product
# Hibernate ORM 7.4.17.Final, H2 2.4.240, JDK 25

== Columns of table product
   AMOUNT | NUMERIC | null | 12 | 2 | YES
   CURRENCY | CHARACTER VARYING | 3 | null | null | YES
   ID | BIGINT | null | 64 | 0 | NO
   NAME | CHARACTER VARYING | 255 | null | null | YES

== Insert and load
-- persist Product(1, Keyboard, Money(10.5, INR))
   sql> insert into Product (name,amount,currency,id) values (?,?,?,?)
   => persisted
   in database: [10.50 | INR | 1 | Keyboard]
-- load Product 1 in a new session
   sql> select p1_0.id,p1_0.name,p1_0.amount,p1_0.currency from Product p1_0 where p1_0.id=?
   => Money[amount=10.50, currency=INR]
   in-memory Money(10.5, INR).equals(Money loaded back from NUMERIC(12,2)) = false

== Updating: replace the whole record
-- replace price with Money(12.00, INR)
   sql> select p1_0.id,p1_0.name,p1_0.amount,p1_0.currency from Product p1_0 where p1_0.id=?
   sql> update Product set name=?,amount=?,currency=? where id=?
   => replaced
-- replace price with an equal-valued Money(12.0, INR) (scale 1 vs 2)
   sql> select p1_0.id,p1_0.name,p1_0.amount,p1_0.currency from Product p1_0 where p1_0.id=?
   => replaced
   record equals says: false
   update issued: false
-- replace price with a really different Money(13.00, INR)
   sql> select p1_0.id,p1_0.name,p1_0.amount,p1_0.currency from Product p1_0 where p1_0.id=?
   sql> update Product set name=?,amount=?,currency=? where id=?
   => replaced
-- replace price with an identical new instance Money(13.00, INR)
   sql> select p1_0.id,p1_0.name,p1_0.amount,p1_0.currency from Product p1_0 where p1_0.id=?
   => replaced
