Is it possible to cascade creation in Spring Data Jdbc as in Spring Data JPA for OneToMany and ManyToMany relationships? If not, what would be the strategy then ?
@Table("orders")
public class Order {
@Id private UUID id;
@MappedCollection(idColumn = "order_id")
private Set<OrderItem> orderItems = new HashSet<>();
private LocalDateTime lastModifiedDateTime;
public Order() {}
}
@Table("orders_items")
public class OrderItem {
private UUID productId;
private Integer quantity;
@Transient private Product product;
public OrderItem(Product product, Integer quantity) {
this.productId = product.getId();
this.quantity = quantity;
}
}
@Table("products")
public class Product {
@Id private UUID id;
private String title;
private String description;
private BigDecimal price;
private LocalDateTime lastModifiedDateTime;
public Product(String title, String description, BigDecimal price) {
this.id = id;
this.title = title;
this.description = description;
this.price = price;
}
}