I have all my tables in the same schema in a SQLServer database, so I would rather not have to specify the schema in every @Table annotation. I have put the schema name in my connection string:
spring.datasource.url=jdbc:sqlserver://localhost;instanceName=SQLEXPRESS;databaseSchema=TST;databaseName=TestDB;integratedSecurity=true;
When my annotation is @Table(name="MY_TABLE")
, and Hibernate attempts an insert I get an Invalid object name 'MY_TABLE'.
error message.
If the annotation is @Table(name="MY_TABLE", schema="TST")
then the insert works as expected.
Does the SQLServer dialect not honor the schema in the connection string?
Here are all the Spring/Hibernate properties:
spring.datasource.url=jdbc:sqlserver://localhost;instanceName=SQLEXPRESS;databaseSchema=EXP;databaseName=YRC_PILOT2;integratedSecurity=true;
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.database-platform = org.hibernate.dialect.SQLServerDialect
spring.jpa.show-sql=true
If I have to specify the schema for every table, so be it. But that seems a bit kludgey if I ever want to switch schema names.