ebean-orm / ebean

Ebean ORM
https://ebean.io
Apache License 2.0
1.47k stars 260 forks source link

why it don't work, setting TenantMode ? #2042

Closed liubinduo closed 4 years ago

liubinduo commented 4 years ago

GITHUB ISSUES ARE STRICTLY CONTROLLED FOR THIS PROJECT.

Refer to http://ebean-orm.github.io/support for the policies controlling the use of github issues. Please post issues to the Ebean group https://groups.google.com/forum/#!forum/ebean first.

Expected behavior

Actual behavior

Steps to reproduce

    DatabaseConfig config = new DatabaseConfig();

    config.setName("db");
    config.setCurrentUserProvider(currentUser);

//    // set the spring's datasource and transaction manager.
    config.setDataSource(dataSource);
    config.setExternalTransactionManager(new SpringJdbcTransactionManager());

    config.loadFromProperties();
    config.add(uuidGenerator);
    // set as default and register so that Model can be
    // used if desired for save() and update() etc
    config.setDefaultServer(true);
    config.setRegister(true);

    config.setTenantMode(TenantMode.PARTITION);
    config.setTenantPartitionColumn("TENANT_ID");
    config.setCurrentTenantProvider(tenantProvider);
    config.setTenantDataSourceProvider(tenantId -> dataSource);

    return config;
select t0.SHXYDM, t0.EXT, t0.ENTNAME, t0.OLDNAME, t0.FRDB, t0.ESDATE, t0.ENTSTATUS, t0.REGCAP, t0.DOM, t0.TEL, t0.EMAIL, t0.WEB_URL, t0.IS_JYZXGS, t0.REGCAPCUR, t0.ENTTYPE, t0.OPSCOPE, t0.REGORG, t0.OPFROM, t0.OPTO, t0.APPRDATE, t0.ENDDATE, t0.REVDATE, t0.CANDATE, t0.JWD, t0.INDUSTRY, t0.INDUSTRY_CODE, t0.PROVINCE, t0.ORGID, t0.ENGNAME, t0.WEBSITE, t0.tenant_id, t0.CREATE_BY, t0.UPDATE_BY, t0.CREATE_TIME, t0.UPDATE_TIME, t0.DELETED, t0.REVISION from company_basic t0 where t0.DELETED = false limit 10; --bind()
liubinduo commented 4 years ago

The issues is close. in the model add @TenantId.