0

I'm starting with a Spring Boot + WebFlux + Postgresql project.

It is necessary to carry out the mapping of the bank schema, but in the @Table annotation the schema information is not present, thinking about it I wanted to understand how it would be possible to carry out the mapping for a table contained in a schema.

Table

select id, description from myschema.mytable;

Mapping

package br.com.myschema.example;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table
public class MyTableEntity {

    @Id
    private Long id;

    private String description;
}

How would it be possible to define for the spring-data that I am accessing the owner myschema?

  • Most probably unrelated, but: Postgres 9.1 is [no longer supported](https://www.postgresql.org/support/versioning/) you should plan an upgrade as soon as possible. –  Oct 20 '20 at 12:46

1 Answers1

0

Try to execute a initial script using ConnectionFactoryInitializer to select the schema to use.

CREATE SCHEMA IF NOT EXISTS tenant1 ; 
SHOW search_path;
SET search_path  TO tenant1;
Hantsy
  • 8,006
  • 7
  • 64
  • 109