Java – How to Implement Partial Enum Backed by Database

databaseenumjava

I have following problem:

need to use enum in my java code, since I'll have to ask in my business logic things like if(someting == enumname.VALUE_ENUM){… but I don't have all the enum types at the compile time – that is I have them but there is too many enum types that I won't use in my business logic except in cases where I need to loop over all of the enum values for(enumname var : enumname.value()){…

This seems more like the real entity then (since in DB it has an Id and a lot more properties), but it looks ugly to type if(something == object.getByString("VALUE_ENUM"))

Is there some more pedant way of doing it?

Best Answer

Related Topic