An SQL table with a compound primary key stores some data.
form a composite key, while VAL1 and VAL2 store values.
I want to create a class that has
String name; String val1; String val2;
, populate instances and do conversion between the SQL table and a collection of instances of the class. What would be a good implementation if such a class? I am choosing between these options:
abstract class Type
abstract class ID
, but this seems unnatural.
(2) Concatenate ID, TYPE and PAGE, but then first and second entries will clash. Concatenation with special characters like
would cause troubles with escaping these characters in the strings down the road.
(3) A class with five strings (one per each column) seems unnatural, because then I don't have a unique handle like
What is the most efficient way to turn SQL table with a composite key into a collection of instances of a class?