Im searching for the best way to mantain combo box values within a Mysql Database accessed by Hibernate objects.
Currently we have the following table:
CREATE TABLE COMBO_VALUES( KEY VARCHAR(5) NOT NULL, COMBO_TYPE VARCHAR(20) NOT NULL, VALUE VARCHAR(100) NOT NULL PRIMARY KEY(KEY,COMBO_TYPE) ); INSERT INTO COMBO_VALUES VALUES('A1', 'COMBO1', 'VALUE1'); INSERT INTO COMBO_VALUES VALUES('A2', 'COMBO1', 'VALUE2'); INSERT INTO COMBO_VALUES VALUES('A3', 'COMBO1', 'VALUE3');
The problem with this table is that we are unable to map this with Hibernate.
Anyone has been in this situation before?
Unless you’re explicitly writing a user interface that you can configure from a database, you shouldn’t be storing combobox options in a database.
A combobox is simply a mechanism for selecting an option from an enumerated list. It’s a UI artifact, not a data artifact.
What you should store is a list of enumerated options independent of display mechanism, and pass these to your user interface code which creates a combobox from them.
That way, if you decide to change to radio buttons, or checkboxes, or a command-line interface later on, only your UI code will change and not the database tables…