When dealing with a denormalised (legacy) database table, whereby you have columns such as:
price_1, price_2, price_3, …, price_10
What is the most efficient and cleanest way of mapping such columns into a java collection (a List for example), instead of mapping them to corresponding price1, price2, … properties.
Is there a simple way of doing it that does not involve UserTypes.
I am talking about columns residing on the same table, not the usual one-to-many relationship between multiple entities.
What I’ve done once before in this situation is create a class to encapsulate the prices, like
Then just map the columns in the table to the individual fields and use the Java class to hide the actual structure from the rest of the code. You can access all the prices as a collection or individually or whatever is suitable.