Suggestion for effective-dated product pricing design in Cuba

I’m trying to implement effective-dated product pricing with 2 related tables of Product and ProductPrices.

Any suggestion what is the best approach to create this representation in Cuba? If i create Product - ProductPrices as 1-To-Many composition, then how to control the price effective date is unique for a particular product?

Below is example of the 2 entity details.


  • Item No
  • Title


  • Effective date
  • Price

One possible solution is mentioned on this topic:

It is based on the screen logic:

An alternative (and perhaps more robust) solution would be creating a Before[Update|Insert]EntityListener on your ProductPrices entity and manipulating with all prices for a particular product in it.

Hi Konstantin,

Interesting customer-phones sample application. Thanks.

How about a 3rd method:

  • Pass the Product entity to the ProductPrice editor and do preCommit validation to check for duplicated price with same effective date. Any problem with this method?

For two methods mentioned (Action’s AfterCommitHandler and EntityListener), i’m not sure how to abort the commit to ProductPrice if validation is failed there. Still learning the Cuba framework.

If you want to inform a user that some value of Price is invalid due to a conflict with other instances of Price, then your 3rd method is really what you need. The other 2 do not allow you to interact with the user.