I have a Spring Boot api that connects to a database in postgresql,In the database I have two schemes, one of my own and the public. when inserting the table that I have in my scheme is created in the public and inserted there. I have tried to put in the entity the name of my scheme but it gives me an error and says that it does not exist, I do not know if it is necessary to do so:
@Entity
@Table( name = "rules" , schema = "eschema1")
This is my application.properties:
spring.datasource.url=jdbc:postgresql://15.98.0.65:5432/database
spring.datasource.username=postgres
spring.datasource.password=
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=none
I see three solutions:
add ?currentSchema=eschema1
to the connection URL
permanently change the search path for that user:
alter user postgres set search_path = 'public,eschema1';
Tell your obfuscation layer (=ORM) to prefix the tables with the schema you have configured. How exactly that is done, I don't know.
I would strongly suggest you use a different user than postgres
- even if it's just for testing purposes.