Multi tenancy with schema per tenant

Hello,
I am tryign to run multi tenancy with schema per tenant. It seems to work good when tenant ID is set in XML as a property for persistance unit.
But I need to set tenant in code. Is that possible? How?
I found this article:
codecrafters.blogspot.it/2013/03/multi-tenant-cloud-applications-with.html
So I tried to set it in doBegin method in custom transaction manager. But that doesn't work. I guess relation descriptors aren't updated right.
I could provide more info with exception stack also but first... have I pick the right approach?
Thanks!
Martin

UPDATE 26.6.2015: This isn't completelly right solution. Read also comments below or go to my article at http://www.mafospace.com/articles/multi-tenancy-with-eclipselink-and-inherited-entities
I've solved it finally. Maybe it will be helpful for someone. I've done that in similar way as described in article I linked in first post. Through custom transaction manager.
import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
import org.eclipse.persistence.sessions.coordination.MetadataRefreshListener;
import org.eclipse.persistence.sessions.server.ServerSession;
import org.springframework.orm.jpa.JpaTransactionManager;
import sk.bantip.hotel.server.security.SecurityHelper;
import javax.persistence.EntityManager;
import java.util.HashMap;
import java.util.Map;
public class MultiTenantJpaTransactionManager extends JpaTransactionManager {
* NOTE:
* Maybe it would be also possible to replace existing entityManager in transaction with new but it
* isn't a good idea because of rollback and other problems.
* So when new tenant is required always start new transaction for it.
@Override
protected javax.persistence.EntityManager createEntityManagerForTransaction() {
EntityManager em = super.createEntityManagerForTransaction();
boolean refreshed = false;
String actualTenant = null;
ServerSession ss = ((EntityManagerImpl) em.getDelegate()).getServerSession();
Map sessionProp = ss.getProperties();
actualTenant = (String) sessionProp.get(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT);
// don't run it if tenant didn't change
// it should be quite faster then
if ((actualTenant == null && SecurityHelper.getActiveTenantSchema() != null) ||
(actualTenant != null && !actualTenant.equals(SecurityHelper.getActiveTenantSchema()))) {
// set new tenant as property for actual session
// while refreshing metadata it will be used from actual session for new session
sessionProp.put(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, SecurityHelper.getActiveTenantSchema());
MetadataRefreshListener mrl = ((EntityManagerImpl) em.getDelegate()).getServerSession().getRefreshMetadataListener();
// metadata refresh listener is empty if it was already run for actual transaction (same entity manager)
// because it is placed in createEntityManagerForTransaction now this shouldn't happen but to be sure...
if (mrl != null) {
Map<String, Object> prop = new HashMap<String, Object>();
// metadata will be refreshed for next created entity manager
mrl.triggerMetadataRefresh(prop);
refreshed = true;
// if metadata for "old" entity manager wasn't refreshed we don't need to create a new one
return refreshed ? super.createEntityManagerForTransaction() : em;
Everything seems to work except inheritance with strategy type JOINED now. To fix that use customizer.
import org.eclipse.persistence.annotations.TenantTableDiscriminatorType;
import org.eclipse.persistence.config.DescriptorCustomizer;
import org.eclipse.persistence.descriptors.ClassDescriptor;
import org.eclipse.persistence.descriptors.TablePerMultitenantPolicy;
* For some reason when using table per tenant with schema discriminator isn't set good for child
* entities with inheritance JOINED strategy. It stay as SUFFIX and therefore it doesn't work.
public class InheritanceJoinedMTFixCustomizer implements DescriptorCustomizer {
@Override
public void customize(ClassDescriptor descriptor) throws Exception {
// set discriminator to SCHEMA
((TablePerMultitenantPolicy) descriptor.getMultitenantPolicy())
.setTenantTableDiscriminatorType(TenantTableDiscriminatorType.SCHEMA);
And in child entities use it like this:
@Customizer(InheritanceJoinedMTFixCustomizer.class)
public class Person extends Contact {

Similar Messages

  • Multi-tenancy for a seperate business unit

    Apparently, we can't do multi-tenancy with SCSM 2012 R2 (see link below).  We'd like setup SCSM for one of our business units, but we don't want any of their stuff mingling with our IT stuff.  It looks like we'll have to create a
    new Management Group.  Is it possible to create a new Management Group on the same server as our current IT Management Group, or do we need a new server ?
    https://social.technet.microsoft.com/Forums/systemcenter/en-US/0891a803-c5f6-4e21-9958-ea4adc2381c6/scsm-2012-multitenant-architecture
    Also, to save some work, is there a way to export settings (eg. for the connectors) from our current IT Management Group to the new Management Group ?
    Thanks

    Hi,
    as per Microsoft Definition "The Service Manager management server and its associated Service Manager database make up a Service Manager management group." This means, that if you need additional Service Manager Management Groups, you have to install
    additional servers.
    I find it very handy, that you can leverage a single data warehouse Management Group and centralize your reporting if you register your many Service Manager management groups with a single data warehouse management group:
    "In your enterprise, you might create multiple Service Manager management groups. You can centralize reporting for multiple Service Manager management groups by registering multiple Service Manager management groups with a single data warehouse management
    group."
    Source:
    Planning for System Center 2012 - Service Manager Deployment
    https://technet.microsoft.com/en-us/library/hh519640.aspx
    About exporting your settings...They should be stored in management packs, which you can import in the new management group. About the connectors - you have to recreate them in the new environment and this shouldn't be a big administrative effort. It will
    take probably not more than 30 Minutes to recreate all possible connectors.
    I hope I could help you further.
    Best Regards,
    Stoyan

  • Sharepoint 2013 setup with multi tenancy

    Hi,
    Anybody have a proper guidance on how to setup SP 2013 with multi tenancy ? And aslo it should be with hosting mode, because we are the big hoster.
    We need hosting SP 2013 with multi tenancy.
    Thanks in advance.

    Hi,
    I have made setup a SharePoint 2013 multi-tenancy.
    I have some issues regarding SharePoint 2013. I have created one SharePoint site collection. I've designated myself as a site administrator.  I'm able to login to the new site collection, however when I try to add people from my created SharePoint
    site collection. It shows me "No results found".
    But In central administration, I can add people as well as can give the permissions.
    Any suggestions, How can I troubleshoot ?
    Thanks in Advance.
    /Harish R.

  • Anyone using multi-tenancy in 11.1.1.7?

      anyone using multi-tenancy in 11.1.1.7?
    What method are you using. I am looking at using the single schema with the TenantGUID column.

    Can you give me the URL to access that document?
    Thanks,

  • VPD - suitable for multi-tenancy?

    Would it be a bastardization of the intended capabilities of Oracle virtual private DB to try to use them to convert a single tenacy application into multi-tenancy? The idea would be that there not a 1:1 mapping of schemas to customer, but rather a single schema where all customers' data is retained. Bad idea?

    That would be perfectly in keeping with the intended use of VPD. That's one of the primary reasons for that functionality to exist.
    Justin

  • HANA multi-tenancy feature

    1. May i know if HANA supports multi-tenancy on production system now?
    2. Also, we found that 'HANA supports the multi-tenancy that built in the application (e.g. CRM) itself'.
       Is it about the SAP HANA cloud applications but not for on premises applications?
       Is this statement valid and what are the differences between the 1. and 2.?

    Hi Joey
    Wikipedia meaning:
    Multitenancy refers to a principle in software architecture where a single instance of the software runs on a server, serving multiple client-organizations (tenants). Multitenancy contrasts with multi-instance architectures where separate software instances (or hardware systems) operate on behalf of different client organizations. With a multitenant architecture, a software application is designed to virtually partition its data and configuration, and each client organization works with a customized virtual application.
    reference: Multitenancy - Wikipedia, the free encyclopedia
    1. May i know if HANA supports multi-tenancy on production system now?
    There is a pilot program ongoing for VMWare.
    So far, such scenario's are not yet officially supported to my knowledge for productive use.
    What I understand under multi-tenancy here is that I could for example serve two customers with one HANA appliance, by running both customers ERP on the same HANA appliance (each with their own DB so two HANA database installations on one HANA appliance) and be supported doing that.
    So, the word "multi-tenancy" is often misused in my opinion and it depends what the source understands under multi-tenancy, on which level that would be (VM wise or SAP software wise or ...).
    If you see multi-tenancy as running both ERP and CRM on a single HANA database then I cannot answer the question as I don't know how much progress was made to make this happen. This is still the vision where things need to move towards, running a single HANA database with all your SAP applications plugged into it.
    2. Also, we found that 'HANA supports the multi-tenancy that built in the application (e.g. CRM) itself'.
    I don't have the context here and the sentence sounds "strange" but if I had to guess, I would guess they mean that some products can run together. For example ERP sidecar scenario + BW can run on a single HANA database (thus instance).
    These combinations are described in SAP notes.
    Best regards
    Tom

  • SharePoint 2013 On premise Multi-Tenancy vs full SharePoint

    Hi,
    We have requirements coming in from joint ventures who need their own site collections/sites.
    Rather than trying to implement them on our current full Enterprise SharePoint environment we would setup a seperate SharePoint deployment in multi-tenancy mode with partitioned service applications.
    Before I offer this up as an option I need to let them know if there are any limitations to a multi-tenant environment over the full versions.  I have seen reference to PerformancePoint not being available and it being harder to migrate to O365 in the
    future if needed however I have not found a definitive list.
    Does anyone know where I can find a list of the limitations (if one exists!)?
    Thanks,
    Mark

    There is no specific list of limitations in one concise spot.  But if you read Spence Harbar's articles on Multi-tenancy (for 2010 and 2013) you will find lists of things that don't work in multi-tenancy.  For example, there are several services
    like the Visio graphics service that don't support partitioning of their databases and are therefore a problem for multi-tenancy.  As you mentioned PerformancePoint is another one.  Read both articles and you should be able to compile a list of what
    you need to know.
    http://www.harbar.net/articles/sp2010mt1.aspx
    http://www.harbar.net/articles/sp2013mt.aspx
    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

  • Error message while executing international payroll with schema x000

    Dear Team,
    I am getting the below error message while running international payroll with schema x000.
       "Jump from DAYPR to detailed log
       Incorrect generation of wage types"
    Request forum members to help me on the same.
    Thank you,
    Srinivas

    Hi,
    Thank you for the reply please find below i reviewed all the below tables please gothrough and advice me if any i missed out.
    1)     T555E-Message Descriptions----
    2) T551C-Period work schedule evaluation---
    Grpg        Period ws     Description     Start Date      End Date      Cntg Class
       01     PWTC         Period WS     01.01.1990      31.12.9999     1
    3) V_551C_B-Valuation class for Periodic work schedule
    Grpg  Period ws  Description     start Date       End Date       Val.Classfor PWS
    01      PWTC      Period WS       01.01.1990    31.12.9999       1
    4) V_t508A-Work schedule rule
    ESG    ES grpg for ws     Holiday      Text      PSG   WSrule    St Date          End Date
    2        Salaried Employee   TCD             TC         01     TCWR    01.01.1900   31.12.9999
    5) V_001P_H-Personnel Subarea grouping for Time Recording
    Personnel area  Personnel Area Text Personnel Subarea Pers.Subarea  Ps Group
    1100                 JEDDAH            1110              MAIN OFFICE           01
    6) V_T555Z- Time type Determination
    Can you advice me on this what I need to maintain here
    7) V_T510S-Time wage type selection rule
    Tm.WT  Dy Grpg          No                                                   Wagetype  Wage Type Long Text
    54       01               001                                              1010            Basic Pay
    Regards,
    Srinivas

  • Multi tenancy ACS

    Hello,
    Is it possible for Cisco ACS 5.4 (or any other version) to work in a multi-tenancy environment?
    I would like to have two ACS servers, one primary, one secondary, with completely different routing (but obviously keep access to each other for replication).
    This would allow me to have centralised management of ACS, but I need ACS to accept client devices request coming from potentially overlapping IP addresses.
    When I try on ACS5.4, it simply complains the second client device's IP clashes with the first.
    Is it possible?
    Steve.

    One definition of Multi-tenancy is an application and database that is built to hold multiple customer data in 1 database. Some apps are written such that only 1 client can use that database, going to a multi-tenancy model requires a complete database redesign and application redesign. How to build? Thats a huge question. My consulting rate is...... Thats a question that is almost impossible to answer without knowing the specifics of what you are trying to do, even then trying to answer it in a forum is almost impossible also.

  • Db schema for osb domain - 1 db schema per domain???

    Hi,
    I have recently started looking into osb10.3.
    domain 1
    created osb domain and assigned one schema to 'wlsbjmsrpDataSource' datasource.
    started the domain and it worked fine then i shutdown the domain.
    domain 2
    Created another domain and assigned same schema assigned previously to domain 1.
    started the domain and it worked fine.
    Now when i try to start domain 1 again the domain startup failed. Wondering if we need one schema per domain or i am missing something while creating datasource for domain?
    Please help as i cant really believe having one schema per osb domain?
    thanks in advance!
    salman

    Hi Manoj,
    Some more information below!
    CR231843
    An ALSB domain cannot boot and generates weblogic.transaction.loggingresource.LoggingResourceException if the domain is a new domain using the same database, schema, and LLR table as an existing domain.
    When you move a domain template to a different machine and use the template to create the new domain, the new domain is not able to boot and weblogic.transaction.loggingresource.LoggingResourceException is thrown. The following details outline the scenario:
    Create the original domain.
    Start the server for the original domain. At this point, the domain is now “used”—a domain is considered used once you have started the server for a domain after you have created it.
    Create the domain template. You can create it in several different ways—use the Domain Template Builder tool and the Configuration Wizard, the pack/unpack command, or the Weblogic Scripting Tool in offline mode.
    Move the domain template to a different machine.
    Create a new domain using the template. Again, you can create it in several different ways—use the Domain Template Builder tool and Configuration Wizard, the pack/unpack command, or the Weblogic Scripting Tool in offline mode.
    Start the server for the domain. If the new domain does not have the same name as the initial domain, the new domain cannot be started. This is because the JMS Reporting Provider provided with ALSB uses the Logging Last Resources (LLR) option. The new domain is attempting to use the same database, schema, and LLR table name to store LLR transaction records. LLR does not allow this to prevent different domains from corrupting each other's tables. To learn more about the LLR feature, see Understanding the Logging Last Resource Transaction Option in Configuring and Managing WebLogic JDBC.
    Note: You can access the Domain Template Builder, Configuration Wizard, and the WebLogic Scripting Tool from the BEA ProductsTools menu on your machine. The tools and the pack and unpack commands are located in the BEA_HOME/weblogic9xx/common/bin directory.
    According to this i have tested :
    domain 1 and domain 2 pointing at same schema ignoring Loggin Last Resource option in the reporting datasource.
    Now the only question is how much do we need Logging Last Resource option and for what purpose in OSB domain??? any comments?
    thanks
    salman

  • Multi threadin with VC++

    Multi threadin with VC++
    I have some problems with multi threading using the provider OraOLEDB.
    When I try to execute a CreateCommand for a CCommand<CManualAccessor> in a secondary thread I have a failure inside OraOLEDB.dll.
    There is no problem if I use the provider MSDAORA.
    I found a property for the OLE DB provider named DBPROP_DSOTHREADMODEL and must be DBPROPVAL_RT_FREETHREAD,
    is the provider OraOLEDB FREETHREAD?
    Thanks for helping me.

    Do I have this right?
    You want to start a Java application from the commandline, and this application creates multiple threads.
    Each thread executes methods from the ProcessBuilder or Runtime classes, which opens a terminal (cmd) window, starts an external (non-Java) .exe program. The exe writes to the cmd window.
    If that's correct, then you need to learn how to create a threaded program, and to use Either the ProcessBuilder or Runtime class.
    Here's a how-to on creating threaded (concurrent) Java programs
    http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html
    and here's an article on correct use of the Runtime class
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Multi mapping with out BPM

    HI ALL ,
           I am trying to do multi mapping with out using BPM .I will get message from the sender and i need to send that to two different target system. I have defined the mapping in the IR . In ID i  have created the configuration scenario and i have created the receiver determination .In receiver determination i have selected "EXTENDED" and when i select input help for mapping name it says "NO Object found". What else should i do get the mapping program here .
    Regards,
    Tarun.

    Bhavesh,
    I'm sorry but if he needs 2 different receivers, then it's not the case of using Enhanced Interface Determination.
    sapuser,
    if you scenario is asynchronous, then it's easily implemented.
    But it won't be achieved with multimapping.
    You'll have 2 receivers in receiver determination (normal RD, not enhanced). For each of those, you'll have to create a separate simple mapping (that will generate the message expected at each receiver system) and refer that mapping in the interface determination of each receiver.
    For example, you have input_message containing data1 and data 2. You'll have 2 simple mappings (not a multimapping), 1 generating output_message_1 containing data1 and the other generating output_message_2 containing data2. Then refer those mappings in the proper interface determinations.
    Regards,
    Henrique.

  • Xml validation with schema, unbounded and any order of elements

    Hi
    I want to validate a xml file the user creates. I am currently using schema to do this. However there needs to be the possibility of a totally random mix of three different types of elements in a parent element. I couldn't find out how to do this, maybe it is not possible with schema? I thought I could look at the error message generated and ignore it if it was caused by one of the three elements mentioned above, but while the error message generated says which element is expected, it does not say which element caused the error.
    Thanks in advance for any help.

    Ruskin wrote:
    However there needs to be the possibility of a totally random mix of three different types of elements in a parent element. Can you take your example to make it more clear? Does all three elements mutually exclusive?

  • How to open multi emails with Apple mail app ?

    Hi Everyone
    I wonder how can i open multi emails with Apple mail, in OS 10.9 very simple to use (command + ~) to switching between emails and mail app. Now it not working anymore.
    Anyone could help ?
    Thank you so much.
    Cheers
    Que

    Hi Barney,
    You are correct, with "Full Screen" mode only have one window open.
    Very uncomfortable for Mac-air user
    Thanks Barney,
    Cheers

  • Spliting files based on condition using multi mapping with BPM

    Hi All,
    Can any one please let me know How to <b>Splite the outbound records based on condition using multi mapping with Integration Process in BPM</b>?
    Thanks
    Govindu.

    Hi All,
    Sorry for mistake this question for Exchange infrastructure guys.
    Thanks,
    Govindu

Maybe you are looking for

  • How do I turn a FLA into a URL Button ?

    Hiya I have a FLA file with 4 layers 2 of the layers are Text Boxes 2 of them are masks to make the different words "Shine" Is there a way to make the whole file a button so when people click on it, it goes to a different page ? Thx Paul

  • AppleTV 2G as wireless access point

    Hi, I thought of the possibility to turn AppleTV 2G as wireless access point when not in use as entertainment, there is an ethernet port and an integrated wifi connection, why not? Need only develop the right application ..

  • Browser Plug-in / Paid Job

    I need a plug-in that calls up a web browser within PS, nothing more.  I will pay someone for the Job, I assume good knowledge of the SDK will be required. 

  • Adding A file back to dock.

    I removed the applications file from the dock. How can i put it back on the dock??

  • Trouble Getting OOF to work on Project Server 2013

    Hey all, I am working on getting OOF working on Project Server 2013. I have followed the steps on the TechNet guide. Once I have done this, I get an error from my manage queue jobs stating that it failed, but was not blocked for each resource. What a