babyfish-ct / jimmer

A revolutionary ORM framework for both java and kotlin.
Apache License 2.0
876 stars 88 forks source link

0.9.20 更新后保存树结构出现数组越界报错 #801

Open yangpanda opened 16 hours ago

yangpanda commented 16 hours ago

0.9.20 更新后 save 报错

java.lang.ArrayIndexOutOfBoundsException: Index 4 out of bounds for length 4
    at org.babyfish.jimmer.sql.ast.impl.mutation.EsNode.merge(EntitySet.java:353)
    at org.babyfish.jimmer.sql.ast.impl.mutation.EntitySet.add(EntitySet.java:77)
    at org.babyfish.jimmer.sql.ast.impl.mutation.ShapedEntityMap.add(ShapedEntityMap.java:73)
    at org.babyfish.jimmer.sql.ast.impl.mutation.UpsertPreHandler.onResolve(PreHandler.java:863)
    at org.babyfish.jimmer.sql.ast.impl.mutation.AbstractPreHandler.resolve(PreHandler.java:452)
    at org.babyfish.jimmer.sql.ast.impl.mutation.UpsertPreHandler.insertedMap(PreHandler.java:767)
    at org.babyfish.jimmer.sql.ast.impl.mutation.PreHandler$1.iterator(PreHandler.java:68)
    at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.saveSelf(Saver.java:204)
    at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.saveAllImpl(Saver.java:106)
    at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.savePreAssociation(Saver.java:160)
    at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.saveAllImpl(Saver.java:97)
    at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.savePostAssociation(Saver.java:195)
    at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.saveAllImpl(Saver.java:115)
    at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.savePostAssociation(Saver.java:195)
    at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.saveAllImpl(Saver.java:115)
    at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.lambda$save$0(Saver.java:48)
    at org.babyfish.jimmer.runtime.Internal.modifyDraft(Internal.java:173)
    at org.babyfish.jimmer.runtime.Internal.lambda$produce$1(Internal.java:42)
    at org.babyfish.jimmer.runtime.Internal.usingDraftContext(Internal.java:102)
    at org.babyfish.jimmer.runtime.Internal.produce(Internal.java:39)
    at org.babyfish.jimmer.sql.ast.impl.mutation.Saver.save(Saver.java:44)
    at org.babyfish.jimmer.sql.ast.impl.mutation.SimpleEntitySaveCommandImpl.executeImpl(SimpleEntitySaveCommandImpl.java:46)
    at org.babyfish.jimmer.spring.cfg.support.SpringConnectionManager.execute(SpringConnectionManager.java:31)
    at org.babyfish.jimmer.sql.ast.impl.mutation.SimpleEntitySaveCommandImpl.execute(SimpleEntitySaveCommandImpl.java:38)
    at org.babyfish.jimmer.sql.ast.impl.mutation.SimpleEntitySaveCommandImpl.execute(SimpleEntitySaveCommandImpl.java:17)
    at org.babyfish.jimmer.sql.kt.impl.KEntitiesImpl.save(KEntitiesImpl.kt:205)
    at org.babyfish.jimmer.sql.kt.KSqlClient.save(KSqlClient.kt:230)
    at org.babyfish.jimmer.sql.kt.KSaver.save$default(KSaver.kt:47)

树形结构, company的code 为key

        sqlClient.save(SysDepartment {
            code = "00002"
            name = "部门1"
            company { code = "00106" }
            children().addBy {
                code = "00007"
                name = "部门1-1"
                company { code = "00106" }
                children().addBy {
                    code = "00043"
                    name = "部门1-1-1"
                    company { code = "00106" }
                }
            }
            children().addBy {
                code = "00049"
                name = "部门1-2"
                company { code = "00106" }
            }
            children().addBy {
                code = "00050"
                name = "部门1-3"
                company { code = "00106" }
                children().addBy {
                    code = "00051"
                    name = "部门1-3-1"
                    company { code = "00106" }
                }
                children().addBy {
                    code = "00052"
                    name = "部门1-3-2"
                    company { code = "00106" }
                }
                children().addBy {
                    code = "00053"
                    name = "部门1-3-3"
                    company { code = "00106" }
                }
            }
        })

部门定义 image

yangpanda commented 12 hours ago

复现包 test.zip