I am trying to evolve a domain which it includes and Aggregate-root implemented with Java Records and I am not able to find a way to use the Domain Event
concept to propagate events from one Aggregate-root.
https://docs.spring.io/spring-data/jdbc/docs/current/reference/html/#core.domain-events
Compilation issue with the following syntax:
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;
import org.springframework.data.domain.AbstractAggregateRoot;
@Table("BALANCE")
public record Balance extends AbstractAggregateRoot<Balance> (
@Id
@Column("ID_BALANCE")
Long balanceId,
@Column("BALANCE")
BigDecimal balance,
@Column("ID_CUSTOMER")
Long customerId,
@Column("LAST_UPDATE")
Timestamp lastUpdate,
@Column("WITHDRAW_LIMIT")
BigDecimal withdrawLimit
) {
//Business logic
}
No problem with this syntax:
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;
import org.springframework.data.domain.AbstractAggregateRoot;
public class BalanceDemo extends AbstractAggregateRoot<BalanceDemo> {
@Id
@Column("ID_BALANCE")
Long balanceId;
@Column("BALANCE")
BigDecimal balance;
@Column("ID_CUSTOMER")
Long customerId;
@Column("LAST_UPDATE")
Timestamp lastUpdate;
@Column("WITHDRAW_LIMIT")
BigDecimal withdrawLimit;
//Constructors, Get, HashCode, Equals, toString
//Business Logic
}
What is wrong? Is it not possible to use Java records in combination with Domain Events
?