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
Description
实体定义
@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
}