Reputation: 2040
I am new to spring-data-jdbc
and just trying to port a small project, which currently uses JPA, for evaluation purposes.
My existing entities use a database schema which can easily be defined by JPAs @Table
annotation on the entity level.
I saw, that a @Table
annotation exists for spring-data-jpa
, but no schema can be specified.
The only approach I found so far is to override the naming Strategy in the JdbcConfiguration
:
@Bean
fun namingStrategy(): NamingStrategy {
return object : NamingStrategy {
override fun getSchema(): String {
return "my_schema"
}
}
}
I would rather prefer an approach, where the schema is specified directly at the entity, to be able to use the same configuration for different schemas.
Are there any other ways to specify the database schema for each aggregate separately?
Upvotes: 1
Views: 401
Reputation: 2040
The answer to my own question is rather trivial:
By using the annotation @Table(value = "my_schema.some_table")
on the entity level the proper schema is used.
Upvotes: 2