1

Hi I have an entity which maps from view in particular schema. Class definition:

@Entity
@Table(name = "VIEW_NAME", schema = "MY_SCHEMA")
public class MyEntity implements Serializable {
}

If I specify schema right on my MyEntity class everything woks it fetches records from database, but i wan't it to be more flexible and configurable from properties. I tried adding property to my properties file: spring.datasource.jpa.properties.hibernate.default_schema: MY_SCHEMA

It doesn't work when i try to fetch i get an exception:

java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

Did i used wrong property ? Is there another way to change schema dynamically on entity ?

  • 2
    Use `spring.jpa.properties.hibernate.default_schema = MY_SCHEMA` –  Jan 10 '19 at 12:19
  • 1
    Here is the response : https://stackoverflow.com/a/24278772/4373948 – Abder KRIMA Jan 10 '19 at 12:25
  • It doesn't work I get exception: Property spring.datasource.schema with value 'ServletContext resource [/MY_SCHEMA]' is invalid: The specified resource does not exist. I think it's because my table is actually view. – LiolikasBolikas Jan 10 '19 at 12:26

1 Answers1

5

The property name is spring.jpa.properties.hibernate.default_schema=<schema-name>

Aditya Narayan Dixit
  • 2,105
  • 11
  • 23