spring-projects / spring-projects/spring-data-relational

Remove caching for table, schema and column names using SpEL expressions

Open
#1,549 1 comment 0 reactions 1 assignee View on GitHub

@schauder is already working on this.

Since Jul 3, 2023.

type: enhancement
Dominant language
Java
Stars
827
Forks
394
PR merge metrics
No merged PRs in 30d

Description

This is a followup to https://github.com/spring-projects/spring-data-relational/pull/1461

While the above ticket successfully enables SpEL for Table and Schema,
allowing us to have a lightweight solution for Multi Tenancy / Multi Schema,
it only works for queries / select statements.
(e.g. select .. from tenant_0, select ... from tenant_5)

For inserts, it will always use the first spel expression that was resolved
(e.g. always insert into tenant_0)

A lightweight alternative to achieve the goal of multi schema,
could have been the NamingStrategy.
Unfortunately, this also gets Cached inside the CachingNamingStrategy
and also evaluated only once.

Having a solution for either one of these, would be awesome.

Thx in advance

-- cut examples ---

https://github.com/table(name = "insurance", schema = "#{@tenantIdBean.getPrefix()}")

https://github.com/component
public class TenantIdBean {
public String getPrefix() {
return "tenant_" + HttpInterceptor.getTenantId();
}
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.