table:
CREATE TABLE `table` (
`id` int(11) NOT NULL,
`status` enum('on','off') NOT NULL DEFAULT 'off',
PRIMARY KEY (`id`),
)
I can use the enum index value to update or insert:
update table set status=1 where id=12 (update id=2 status to on)
but in java,the Enum field type always return String (check here)
select status from table where id=2
or use resultSet.getObject("status") (java)
always return the String on, but I want to get the Integer 1
is this possible?
Pitfall: This is 1-based, so you will get 1 for
onand 2 foroffEdit
If you can’t use calculated fields (for whatever reason), create a view:
and direct your queries to this view, instead of the table.