Skip to content

[BUG] - <title> 在中间表的逻辑删除中,UUID 无法插入 binary(16) #1025

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

Open
FoldingFan opened this issue May 7, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@FoldingFan
Copy link

Jimmer Version

0.9.81

JDK Version

21

Database

MySQL

OS

Windows

Expected behavior

预期中间表执行SQL

insert into sys_user_role(sys_user_id, sys_role_id, deleted) values(1369619356736032768, 1000, 0x00000000000000000000000000000000)

Actual behavior

实际执行

insert into sys_user_role(sys_user_id, sys_role_id, deleted) values(1369619356736032768, 1000, '00000000-0000-0000-0000-000000000000')

Description

我添加了此配置,正常的实体逻辑删除没问题

class JimmerCustomizer : KCustomizer {

    override fun customize(dsl: KSqlClientDsl) {
        dsl.addScalarProvider(ScalarProvider.uuidByByteArray())
    }
}

在中间表中,使用了这个配置,执行的SQL报错 Data truncation: Data too long for column 'deleted'

    @ManyToMany
    @JoinTable(
        //  .......
        logicalDeletedFilter = JoinTable.LogicalDeletedFilter(
            columnName = "deleted",
            type = UUID::class  // 这里不会生效自定义的配置
        ),
    )

Reproduction steps

表结构

CREATE TABLE `sys_role_menu` (
    `sys_role_id` BIGINT UNSIGNED NOT NULL COMMENT '绑定角色',
    `sys_menu_id` BIGINT UNSIGNED NOT NULL COMMENT '绑定菜单',
    `deleted`     BINARY(16)      NOT NULL DEFAULT (X'00000000000000000000000000000000') COMMENT '逻辑删除字段 为0代表没删除',
    PRIMARY KEY (`sys_menu_id`, `sys_role_id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = `utf8mb4`
  COLLATE = `utf8mb4_unicode_ci` COMMENT = '角色菜单绑定表'
  ROW_FORMAT = DYNAMIC;

配置项

class JimmerCustomizer : KCustomizer {

    override fun customize(dsl: KSqlClientDsl) {
        dsl.addScalarProvider(ScalarProvider.uuidByByteArray())
    }
}

关联关系注解

    @ManyToMany
    @JoinTable(
        //  .......
        logicalDeletedFilter = JoinTable.LogicalDeletedFilter(
            columnName = "deleted",
            type = UUID::class  // 这里不会生效自定义的配置
        ),
    )

Generated SQL

No response

Relation Model

No response

Screenshots

No response

Logs

No response

@FoldingFan FoldingFan added the bug Something isn't working label May 7, 2025
babyfish-ct added a commit that referenced this issue May 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant