Adding Schema name to entity in Spring data?

entity-framework java oracle spring spring-data

Question

I am getting an error when using an Oracle DB and Spring Data. The error is:

ORA-00942: table or view does not exist

The cause of this error is that the user I am connecting with does not have access to the tables in the schemas I wish to connect to.

I read that 2 fixes to this are to create synonyms in my database or to specify the schema that each entity/table belongs to.

I am going to try the Schema approach first. How do I do so?

My example entity below, a Dog in the Vet Schema:

@Entity
@Table(name = "Dog")
public class Dog
{
    @Id
    private String id;

    @Column(name = "NAME")
    private String name;

    @Column(name = "Owner")
    private String owner;

  //getters and setters etc...
1
3
4/1/2016 12:28:16 PM

Accepted Answer

The @Table annotation provides the schema attribute:

@Table(name = "Dog", schema = "Vet")
9
4/1/2016 11:54:17 AM

Popular Answer

You must prefix your tables with the schema name and with a . inbetween them:

@Table(name = "VET.Dog")


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow