Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bug in HasTenantAdditionalCriteriaProvider #59

Copy link
Copy link
@ZuperKeurZ

Description

@ZuperKeurZ
Issue body actions

I made a ticket for this in Cuba forum before https://www.cuba-platform.com/discuss/t/bug-in-multitenancy-queries-tenant-id-no-tenant-is-applied-incorrectly/14547

    @Override
    public String getAdditionalCriteria(Class entityClass) {
        MetaProperty metaProperty = tenantEntityOperation.getTenantMetaProperty(entityClass);
        return String.format("(:tenantId = '%s' or this.%s = :tenantId)", TenantProvider.NO_TENANT, metaProperty.getName());
    }

should be replaced by

    @Override
    public String getAdditionalCriteria(Class entityClass) {
        MetaProperty metaProperty = tenantEntityOperation.getTenantMetaProperty(entityClass);
        return String.format("(this.%s = '%s' or this.%s = :tenantId)", metaProperty.getName(), TenantProvider.NO_TENANT, metaProperty.getName());
    }

However, during startup an anonymous login is mandatory. In the as is this results in a condition on the query

Copy
'no_tenant' = 'no_tenant'
after applying the fix we get

Copy
t1.TENANT_ID = 'no_tenant'
As the anonymous user has a null value in the tenant_id the condition returns false. no anymous user is found and the server fails to start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.