当前使用版本(必须填写清楚,否则不予处理)
3.2.0
该问题是怎么引起的?(最新版上已修复的会直接close掉)
使用kotlin时,用KtQueryWrapper 需要进行模糊查询 wrapper.and {itemWrapper-> itemWrapper.like(CustomerEntity::name, query.searchKey) .or() .like(CustomerEntity::phone, query.searchKey) } 报错
重现步骤
报错信息
Parameter specified as non-null is null: method com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper.
Comment From: miemieYaho
怎么用的列完整
Comment From: kewei24
private fun fillQueryWrapper(query: OpportunityWebPageQuery): KtQueryWrapper<CustomerEntity> {
val wrapper = KtQueryWrapper(CustomerEntity::class.java)
wrapper.eq(CustomerEntity::valid, query.valid)
if (!query.districtId.isNullOrEmpty()) {
wrapper.eq(CustomerEntity::districtId, query.districtId)
} else if (!query.cityId.isNullOrEmpty()) {
wrapper.eq(CustomerEntity::cityId, query.cityId)
} else if (!query.provinceId.isNullOrEmpty()) {
wrapper.eq(CustomerEntity::provinceId, query.provinceId)
} else if (!query.region.isNullOrEmpty() && RegionType.of(query.region!!.toInt())?.areaCodes?.toList().isNotNullOrEmpty()) {
wrapper.`in`(CustomerEntity::provinceId, RegionType.of(query.region!!.toInt())?.areaCodes?.toList())
}
wrapper.entity = CustomerEntity()
if (!query.searchKey.isNullOrEmpty()) {
wrapper.and { itemWrapper ->
itemWrapper.like(CustomerEntity::name, query.searchKey)
.or()
.like(CustomerEntity::phone, query.searchKey)
}
}
if (query.opportunityType != 0) {
wrapper.eq(CustomerEntity::type, query.opportunityType)
}
return wrapper
}
Comment From: kewei24
怎么用的列完整
private fun fillQueryWrapper(query: OpportunityWebPageQuery): KtQueryWrapper<CustomerEntity> {
val wrapper = KtQueryWrapper(CustomerEntity::class.java)
wrapper.eq(CustomerEntity::valid, query.valid)
if (!query.districtId.isNullOrEmpty()) {
wrapper.eq(CustomerEntity::districtId, query.districtId)
} else if (!query.cityId.isNullOrEmpty()) {
wrapper.eq(CustomerEntity::cityId, query.cityId)
} else if (!query.provinceId.isNullOrEmpty()) {
wrapper.eq(CustomerEntity::provinceId, query.provinceId)
} else if (!query.region.isNullOrEmpty() && RegionType.of(query.region!!.toInt())?.areaCodes?.toList().isNotNullOrEmpty()) {
wrapper.`in`(CustomerEntity::provinceId, RegionType.of(query.region!!.toInt())?.areaCodes?.toList())
}
wrapper.entity = CustomerEntity()
if (!query.searchKey.isNullOrEmpty()) {
wrapper.and { itemWrapper ->
itemWrapper.like(CustomerEntity::name, query.searchKey)
.or()
.like(CustomerEntity::phone, query.searchKey)
}
}
if (query.opportunityType != 0) {
wrapper.eq(CustomerEntity::type, query.opportunityType)
}
return wrapper
}
Comment From: craone
查看文档 插入或更新的字段有 空字符串 或者
KtUpdateWrapper(Member::class.java)
.set(Member::unionId, null)
.eq(Member::id, memberId)
是可以的,但是提示错误
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method com.baomidou.mybatisplus.extension.kotlin.KtUpdateWrapper.set, parameter value
at com.baomidou.mybatisplus.extension.kotlin.KtUpdateWrapper.set(KtUpdateWrapper.kt)
at com.baomidou.mybatisplus.extension.kotlin.KtUpdateWrapper.set(KtUpdateWrapper.kt:34)
at com.baomidou.mybatisplus.core.conditions.update.Update.set(Update.java:30)
Comment From: miemieYaho
使用 3.3.1.10-SNAPSHOT
Comment From: miemieYaho
使用 3.3.1