I have a question regarding an ArrayList of Integers, or primitive types in general. Suppose I'm designing a POS program and each product may have several prices.
Let's assume I can represent a price value with int
s and in the Product
class I have the field ArrayList<Integer> prices
. What's the best way to map this with Hibernate?
I could map it to a product_prices
table with a field containing the price value and a field for the foreign key referencing the product in question, but this seems overkill.
On the other hand, I could concatenate all prices in a String
and store it as a field in the products
table, with the prices separated by semicolons, for instance. This way I'm saving one table and a future select
, but it doesn't seem quite OO.
What is the best to do here?