I have two entities which some fields of one entity is a mirror of the same field in the other. Let say product and inventory:
Code:
class Product {
private int productID;
private String productCode;
private double price;
...
}
class Inventory {
private int productID;
private String productCode;
private double price;
...
// own fields
}
where productID, productCode and price in the inventory is the same as those in the product entity.
When a new product is entered in to DB, a new inventory entity also is created with those fields copied from the product entity.
Does any Hibernate mechanism can handle the data synchronization when a product entity is updated? The DB constraint "on update cascade" can deal with unique fields.