cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From emanuele m <emamai...@gmail.com>
Subject Multi tenacy with schema per tenant with 'some' tables shared
Date Mon, 21 Dec 2015 21:18:40 GMT
Actually i have an application
using cayenne 3.1 stack, with postgress 9.3 as database,
 that implements multiteancy creating
a separate ServerRuntime per "Company" that relocates
DbEntities on a specific postgress schema, using an
XMLDataMapLoader with overrided load method as follow:

public DataMap load(Resource configurationResource) {
        DataMap map = super.load(configurationResource);
        map.setDefaultSchema(tenantSchema);
        for (DbEntity e : map.getDbEntities()) {
            e.setSchema(tenantSchema);
                String sequence =
tenantSchema.concat(".").concat(e.getPrimaryKeyGenerator().getGeneratorName());
                e.getPrimaryKeyGenerator().setGeneratorName(sequence);

        }

        return map;
}

As result i have a serverruntime per "Company" from which every user
obtains his own ObjectContext(s).

Now i would need to map some tables into a shared schema.

Was thinking about to point just the tables that must be separated per
company, into the company specific schema, leaving those that are meant to
be share into the public schema.
Clearly there are no relationships between the "shared" entities and the
"Company" ones.

Any advice orsuggestions will be greatly appreciated.

Thanks,
Emanuele

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message