Combo boxes with Hibernate

I'm looking for a better way to map combo field values ​​in a Mysql database that Hibernate objects are accessing.

We currently 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 cannot map this to Hibernate.

Has anyone been in this situation before?

+1


source to share


1 answer


Unless you've explicitly written a user interface that you can customize from the database, you shouldn't store combobox options in the database.

A combobox is simply a mechanism for selecting an option from an enumerated list. It is a UI artifact, not a data artifact.



What you have to keep is a list of renderer-independent enumerated parameters and pass them to your UI code that creates the combobox from them.

This way, if you decide to change the radio buttons or checkboxes or the command line interface later, only your UI code will change, not the database tables ...

+3


source







All Articles