Agatha Shevchenko
Agatha Shevchenko

Reputation: 1

Postgres database "information_schema" in JPA

I've created project using Postgres database. Tables are created in information_schema, that's why I need to add schema argument @Table or @JoinTable, like this:

@Entity
@Table(name = "book",  schema = "information_schema")
public class Book { ...
@ManyToMany
@JoinTable(
    name = "book_genre",
    schema = "information_schema",
    joinColumns = @JoinColumn(name = "book_id"),
    inverseJoinColumns = @JoinColumn(name = "genre_id"))
private List<Genre> genres = new ArrayList<>();

What setting should I change to avoid this? Maybe I should set it in settings of my application?
application.yml looks like this:

spring:
  datasource:
    url: "jdbc:postgresql://localhost:5432/postgres"
    username: ...
    password: ...

Upvotes: 0

Views: 293

Answers (1)

Shakirov Ramil
Shakirov Ramil

Reputation: 1543

spring:
  datasource:
    hikari:
      schema: ${database.schema}
  liquibase:
    default-schema: ${database.schema}
  jpa:
    properties:
      hibernate:
        default_schema: ${database.schema}

Upvotes: 1

Related Questions