I'm using Java 1.6 and Hibernate 3.6.10.Final. I need to check the contents of several database tables against enums built into our application. (The database tables tend to get values added and deleted occasionally and nobody tells the developers.) So on startup I'd like to do something like this:
for (service myService : ListOfServices() ) {
enum MyEnum = GoGetCorrespondingEnum(myService);
Map<Character, String> databaseMap = myService.findAll();
if (databaseMap.size() != MyEnum.values().length) {
logger.error("Enum is out of sync with database tableand must be fixed!");
}
}
The catch is, in the second line, I don't know how to get the corresponding enum for the service I'm looking at. Can anyone suggest a method?