Add Money embeddable value object (corner-scenario enrichment)
This commit is contained in:
10
src/main/java/com/ankurm/sdjpa4demo/domain/Money.java
Normal file
10
src/main/java/com/ankurm/sdjpa4demo/domain/Money.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.ankurm.sdjpa4demo.domain;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
// A value object: no identity, just its two values. Records make ideal @Embeddable
|
||||
// types in Spring Data JPA 4 / Hibernate 7 - immutable, and equals()/hashCode() come free.
|
||||
@Embeddable
|
||||
public record Money(BigDecimal amount, String currency) {}
|
||||
Reference in New Issue
Block a user