Skip to content

Micronaut Data JDBC Multitenancy #1263

Discussion options

You must be logged in to vote

I would create an abstract InventoryRepository something like:

@JdbcRepository(dialect = Dialect.POSTGRES)
public abstract class InventoryRepository {

  TenantContentProvider provider;

  public Inventory findById(UUID id) {
       return findByIdAndUserId(id, provider.getId());
  }

  // This will use compile-time query
  protected abstract Inventory findByIdAndUserId(UUID id, UUID userId);

}

You would need to implement all repository methods in a similar fashion.

We might support something like:
`@Where("userId = #tenancyId")'
And allow bind query parameters from something else than method parameters.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rafaelrenanpacheco
Comment options

Answer selected by rafaelrenanpacheco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants