how to pass schema dynamically in the entity when the server is already running

Viewed 170

i need to pass the schema name dynamically to the entity

 @Entity
 @Table(name = "customer_table" schema="${dynamicSchemaName}")
 @JsonIgnoreProperties

 public class Customer implements Serializable {
      //....
 }

how can i replace ${dynamicSchemaName} with the schema that will be picked by the code where this entity is called?

1 Answers

The simple answer is that you can't. Although there are hacks and ways to inject dynamic data into an annotation, that doesn't exist for Hibernate. Annotations are defined at compile time and read at run time.

Related