I need to use two different schemas in one java app. For now I'm setting the value with static text:
@Table(name = "jhi_user", catalog = "some_catalog")
@Table(name = "jhi_persistent_audit_event", catalog = "some_other_catalog")
I want to read those values from class marked with @ConfigurationProperties
annotation but I don't have any ideas how to do it correctly.
I've tried to create enum with static subclass, but it only works with constant values.
public enum MyData {
DB1(Constants.DB1),
DB2(Constants.DB2);
public static class Constants {
public static final String DB1 = ApplicationProperties.getDb1(); //<--- : attribute value must be constant
public static final String DB2 = "db2"; //<----- works
}
}
Is it any way to change database catalog for different classes without compiling the code? I suppose, I can set it to blank and then change them with reflection, is there a better way?