+
Skip to content
This repository was archived by the owner on May 15, 2024. It is now read-only.
This repository was archived by the owner on May 15, 2024. It is now read-only.

当使用class作为实体,并且构造参数只有非表字段(加了@Ignore)并且为默认参数时, 生成错误的doCreateEntity代码 #7

Closed
@lookup-cat

Description

@lookup-cat

实体定义

@Table
public class Student(
    @Ignore
    public var createTime: LocalDateTime = LocalDateTime.now()
) {
    @PrimaryKey
    public var id: Int? = null
    public var name: String = ""
    public var age: Int = 0
}

实际生成doCreateEntity方法代码

public override fun doCreateEntity(row: QueryRowSet, withReferences: Boolean): Student {
    val constructor = Student::class.primaryConstructor!!
    val parameterMap = HashMap<KParameter, Any?>(1)
    for (parameter in constructor.parameters) {
        when (parameter.name) {
        }
    }
    val entity = constructor.callBy(parameterMap)
    entity.id = row[this.id]
    entity.name = row[this.name]!!
    entity.age = row[this.age]!!
    return entity
}

合理的生成代码应该是

public override fun doCreateEntity(row: QueryRowSet, withReferences: Boolean): Student {
    val constructor = Student::class.primaryConstructor!!
    val parameterMap = emptyMap<KParameter, Any?>()
    val entity = constructor.callBy(parameterMap)
    entity.id = row[this.id]
    entity.name = row[this.name]!!
    entity.age = row[this.age]!!
    return entity
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载