Saving Enum in the Database MYSQL

Software Programmer
Software Programmer used Ask the Experts™
on
I insert a row in the table as follows

final SqlParameterSource namedParameters = new MapSqlParameterSource.addValue("xParam", X.getName).addValue("yParam", Y.getName).addValue("zParam", Z.getName);

I have a enum colum in the database which is of enum OrderStatusEnum

I have an enum as follows

public enum OrderStatusEnum {
    ACTIVE("A","Active Order"),
    AWAITING("I","Awaiting Order")

I want to save ACTIVE, AWAITING in the database. Also retrieve the same on query

I'm facing exception when entity is getting set as enum and saved via JdbcTemplate. Data Truncate exception

Questions

1. Do i need to save ACTIVE/AWAITING in the database or Active Order/Awaiting Order i.e enum description ??
2. How to save the enum value and not sure how to save it

If i put Types.VARCHAR as an additional parameter the value is getting saved as ACTIVE/AWAITING ORDER and seems description is getting saved

Which one is the right approach - saving enum value or description. I think saving enum value would be the right option. However unable to save the enum using the above

Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial