I'm using Spring Boot with JPA to connect with my database. I need to set "catalog" property in @Table annotation on entities.
Basically is not a problem
@MappedSuperclass
@NoArgsConstructor
@Table(catalog = "catalog_name")
public abstract class AbstractEntity
but I have to find easy way to change the catalog value, cause that I have different values on different environments.
Could anyone know any other way how to change this by for example application.properties file instead of hardcoded string?
I would be grateful for any solution.
As far as I know you cannot edit annotation properties dynamically. Have a look at this post.
Maybe try having multiple abstract entities with it's own catalog name and do a
switch
based on anapplication.properties property
to get the right one.Maybe such approach will work:
Do something like this:
@Table(catalog = "${catalog.name}")