cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Reich <markus.re...@markusreich.at>
Subject Switch DbEntity schema at runtime
Date Fri, 18 Nov 2016 07:00:45 GMT
Hi,

I have a very special requirement :-)
We need to change the schema after logon (it's a JSF Tomcat WebApp)

I tried the following

After login

final String SESSION_CONTEXT_KEY =
SessionContextRequestHandler.class.getName() + ".SESSION_CONTEXT";
ObjectContext context = (ObjectContext)
session.getAttribute(SESSION_CONTEXT_KEY);
for (DbEntity dbEntity : context.getEntityResolver().getDbEntities()) {
if (dbEntity.getSchema().endsWith("crm")) {
if(Helper.getCrm()!=null) dbEntity.setSchema(Helper.getCrm());
} else if (dbEntity.getSchema().startsWith("simpleinv_")) {
if(Helper.getEupar()!=null) dbEntity.setSchema("simpleinv_" +
Helper.getEupar());
}
}
session.setAttribute(SESSION_CONTEXT_KEY, context);

The switching works, until a second session is opened! The first session
loses the schema and get the one from the second?

When I debug I have two different instances of the ObjectContext that's
perfect, but the DbEntities are the same :-/

regards
Meex

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