Hi!
I am currently working on a shop system in
JBoss Seam using Hibernate as ORM.
The shop has a stock list with many articles. All these articles have a default retail price. The articles are assigned to several lists where an article can be in none, one or many lists. Finally every customer has exactly one list that is assigned to him.
In general the retail price for the customer is the retail price of the article itself. But on every list the price of each article can be overwritten, so that the price of one article can differ from the original price and the other lists that can define own prices as well. At last a price for one article of a certain list can be overwritten for a single customer.
So if I want to look up a price I have to check (in that order) if a price of the article for the customer is set, if a price of the article for the list is set and otherwise the default retail price of the article is used.
Because the ressources of the server are limited I really need to reduce overhead and database traffic. So what do you think might be the best way to realize that structure?
I thought about using a 'Price' class for the article and two inherited classes 'ListPrice' and 'UserPrice'. But if an article lists consist of a few hundred articles the lookup might result in umpteen joins and database querys. But to cache all these values might result in a very large memory consumption.
What way would you propose me to choose?
Thank you in advance!