We're updating the issue view to help you get more done. 

Able to change tenantId in the same session

Description

Hi,
My system has a feature that we need to reach more than one database schemas in the same request
Ex.:

1 2 3 4 5 6 7 8 9 10 11 12 // SomeDAO public List<Foo> getFoo(List<String> schemas, Integer id) { List<Foo> foos = new ArrayList<>(); Session session = getSession(); for (String schema: schemas) { session.setTenantId(schema); Foo foo = session.get(Foo.class, id); foos.add(foo); } return foos; }

Today, we close the Session and open another one for each schema, we'd like to avoid close/open sessions and use only one and still have all hibernate features as first level/second level etc

COA:

  • Need expose setTenantId for Session and ContextualJdbcConnectionAccess (or have only one place to set and get it)

  • Need add tenantId to EntityKey, CollectionKey and other classes that generate key for cache

  • Able to use transactions managers (by hibernate or Spring)

Environment

None

Status

Assignee

Unassigned

Reporter

Silvio Fragata da Silva

Affects versions

5.3.6

Priority

Major