For the complete documentation index, see llms.txt. This page is also available as Markdown.

Intermediate Table

Table Structure

create table t_user_and_role (user_id bigint, role_id int);

Bead Declaration

@Bean
public AssociativeService<Long, Integer> userAndRoleAssociativeService() {
    return new TemplateAssociativeService<>("t_user_and_role", "userId", "roleId");
}

Usage

Create a web api to invoke the userAndRoleAssociativeService:

@RestController
class AuthController {
    @Resource
    AssociativeService<Long, Integer> userAndRoleAssociativeService;

    @GetPostMapping("reallocateRolesForUser")
    public void reallocateRoles(Long userId, @RequestParam List<Integer> roleIds) {
        userAndRoleAssociativeService.reallocateForLeft(userId, roleIds);
    }
}

Access

Invoking this api will execute the following SQL statement

Last updated