Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AAA execute same query 3 time for one permission check #27

Open
leeaee opened this issue Jul 19, 2018 · 1 comment
Open

AAA execute same query 3 time for one permission check #27

leeaee opened this issue Jul 19, 2018 · 1 comment

Comments

@leeaee
Copy link

leeaee commented Jul 19, 2018

When adding AAA required permission checking logic, the query user's SQL will execute three times for every time call.

    @GetAction("{id}")
    public Admin read(@NotNull Long id, String fields) {
        AAA.requirePermission(Permissions.PERM_ADMIN_READ);
        PropertySpec.current.set(fields);
        Admin admin = dao.findById(id);
        notFoundIfNull(admin, context.i18n(Messages.ENTITY_ID_NOT_FOUND, Admin.KEY, id));
        logger.debug("Read admin by id -> {}", id);
        return admin;
    }

When call read admin method. the logs shows the query login user with execute 3 times.

16:07:41.670 [XNIO-1 task-3] DEBUG e.logging.sql - SELECT ID, create_time, EMAIL, last_update, login_name, MOBILE, NAME, PASSWORD, PHONE, ROLES, SALT, STATE, VERSION FROM bb_admin WHERE (login_name = ?)
	bind => [admin]
16:07:41.672 [XNIO-1 task-3] DEBUG e.logging.sql - SELECT ID, create_time, EMAIL, last_update, login_name, MOBILE, NAME, PASSWORD, PHONE, ROLES, SALT, STATE, VERSION FROM bb_admin WHERE (login_name = ?)
	bind => [admin]
16:07:41.673 [XNIO-1 task-3] DEBUG e.logging.sql - SELECT ID, create_time, EMAIL, last_update, login_name, MOBILE, NAME, PASSWORD, PHONE, ROLES, SALT, STATE, VERSION FROM bb_admin WHERE (login_name = ?)
	bind => [admin]
16:07:41.675 [XNIO-1 task-3] DEBUG e.logging.sql - SELECT ID, create_time, EMAIL, last_update, login_name, MOBILE, NAME, PASSWORD, PHONE, ROLES, SALT, STATE, VERSION FROM bb_admin WHERE (ID = ?)
	bind => [1]
16:07:41.676 [XNIO-1 task-3] DEBUG c.b.n.a.AdminEndpoint - Read admin by id -> 1

Is there any way to optimize this?

@greenlaw110
Copy link
Contributor

@leeaee the cache mechanism introduced with #32 should fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants