Skip to content

[BUG] - An error occurred while I modified the list of many-to-many associated objects in Input.toEntity { } #969

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

Closed
L1yp opened this issue Mar 25, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@L1yp
Copy link

L1yp commented Mar 25, 2025

Jimmer Version

0.9.68

JDK Version

21

Database

MySQL

OS

Windows

Expected behavior

no error

Actual behavior

cannot save

Description

1

Reproduction steps

  1. git clone https://github.com/L1yp/jimmer-save-error
  2. executes init.sql in the root directory
  3. run JimmerSaveErrorApplication

// open in JetBrains In IntelliJ IDEA
4. open "use-save-error.http" file in the root directory
5. call the http method

Generated SQL

No response

Relation Model

create database if not exists `jimmer-err`;

create table if not exists user
(
    id         bigint unsigned auto_increment
        primary key,
    username   varchar(64)     not null,
    nickname   varchar(64)     not null,
    status     int default 0   not null,
    updated_at datetime        not null,
    updated_by bigint unsigned not null,
    created_at datetime        not null,
    created_by bigint          not null,
    constraint uidx_username
        unique (username)
);

create table if not exists role
(
    id         bigint unsigned auto_increment
        primary key,
    code       varchar(64)     not null,
    name       varchar(64)     not null,
    order_no   int default 0   not null,
    status     int default 0   not null,
    updated_at datetime        not null,
    updated_by bigint unsigned not null,
    created_at datetime        not null,
    created_by bigint unsigned not null,
    constraint uidx_code
        unique (code)
);

create table if not exists user_role_mapping
(
    user_id bigint unsigned not null,
    role_id bigint unsigned not null,
    primary key (user_id, role_id)
);

INSERT INTO role (id, code, name, order_no, status, updated_at, updated_by, created_at, created_by) VALUES (1, 'admin', '系统管理员', 1, 1, '2025-03-24 00:45:49', 1, '2025-03-24 00:45:45', 1);
INSERT INTO role (id, code, name, order_no, status, updated_at, updated_by, created_at, created_by) VALUES (2, 'default', '成员', 2, 1, '2025-03-24 00:46:10', 1, '2025-03-24 00:46:13', 1);

Screenshots

Image

Image

Logs

java.lang.IllegalStateException: The current draft has been resolved so it cannot be modified
at com.babyfish.jimmer.entity.RoleDraft$$$DraftImpl.setId(RoleDraft.kt:789) ~[main/:na]
at com.babyfish.jimmer.entity.RoleDraft$$$DraftImpl.__set(RoleDraft.kt:1109) ~[main/:na]
at org.babyfish.jimmer.sql.ast.impl.mutation.UpsertPreHandler.onResolve(PreHandler.java:985) ~[jimmer-sql-0.9.68.jar:na]
at org.babyfish.jimmer.sql.ast.impl.mutation.AbstractPreHandler.resolve(PreHandler.java:527) ~[jimmer-sql-0.9.68.jar:na]
at org.babyfish.jimmer.sql.ast.impl.mutation.UpsertPreHandler.insertedMap(PreHandler.java:904) ~[jimmer-sql-0.9.68.jar:na]
at org.babyfish.jimmer.sql.ast.impl.mutation.PreHandler$1.iterator(PreHandler.java:69) ~[jimmer-sql-0.9.68.jar:na]
at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.saveSelf(Saver.java:209) ~[jimmer-sql-0.9.68.jar:na]
at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.saveAllImpl(Saver.java:106) ~[jimmer-sql-0.9.68.jar:na]
at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.savePostAssociation(Saver.java:195) ~[jimmer-sql-0.9.68.jar:na]
at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.saveAllImpl(Saver.java:115) ~[jimmer-sql-0.9.68.jar:na]
at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.lambda$save$0(Saver.java:48) ~[jimmer-sql-0.9.68.jar:na]
at org.babyfish.jimmer.runtime.Internal.modifyDraft(Internal.java:173) ~[jimmer-core-0.9.68.jar:na]
at org.babyfish.jimmer.runtime.Internal.lambda$produce$1(Internal.java:42) ~[jimmer-core-0.9.68.jar:na]
at org.babyfish.jimmer.runtime.Internal.usingDraftContext(Internal.java:102) ~[jimmer-core-0.9.68.jar:na]
at org.babyfish.jimmer.runtime.Internal.produce(Internal.java:39) ~[jimmer-core-0.9.68.jar:na]
at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.save(Saver.java:44) ~[jimmer-sql-0.9.68.jar:na]
at org.babyfish.jimmer.sql.ast.impl.mutation.SimpleEntitySaveCommandImpl.executeImpl(SimpleEntitySaveCommandImpl.java:52) ~[jimmer-sql-0.9.68.jar:na]
at org.babyfish.jimmer.spring.cfg.support.SpringConnectionManager.execute(SpringConnectionManager.java:56) ~[jimmer-spring-boot-starter-0.9.68.jar:na]
at org.babyfish.jimmer.sql.ast.impl.mutation.SimpleEntitySaveCommandImpl.execute(SimpleEntitySaveCommandImpl.java:39) ~[jimmer-sql-0.9.68.jar:na]
at org.babyfish.jimmer.sql.ast.impl.mutation.SimpleEntitySaveCommandImpl.execute(SimpleEntitySaveCommandImpl.java:18) ~[jimmer-sql-0.9.68.jar:na]
at org.babyfish.jimmer.sql.kt.impl.KEntitiesImpl.save(KEntitiesImpl.kt:205) ~[jimmer-sql-kotlin-0.9.68.jar:na]

@L1yp L1yp added the bug Something isn't working label Mar 25, 2025
babyfish-ct added a commit that referenced this issue Mar 26, 2025
@babyfish-ct
Copy link
Owner

Try 0.9.69

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

2 participants