【发布时间】:2022-01-03 04:25:55
【问题描述】:
我在我的控制器类中创建了一些操作,我想存储 我从操作中得到的结果,但是当我存储这些列表时 它向我显示的错误如下所示
Type mismatch.
Required:
DepositMaterial!
Found:
List<Result>
这是我的控制器类
@PatchMapping("/pendingValue")
fun pend(@ModelAttribute request:ReqFindPending):ResponseEntity<*>{
val existingWithdraw = depositRepository.findPendingByWithDrawId(request.withDrawId)
if (existingWithdraw != null){
val upPending = depositRepository.getPending(withDrawId = request.withDrawId)
depositRepository.save(upPending)
return ResponseEntity(ResMessage("Pending update successfull"),HttpStatus.OK)
}else{
return ResponseEntity(ResMessage(" id getting null value"),HttpStatus.NOT_ACCEPTABLE)
}
}
我的仓库
package com.nilmani.workload.repository
import com.nilmani.workload.entity.DepositMaterial
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import org.springframework.transaction.annotation.Transactional
import org.springframework.web.bind.annotation.RequestParam
interface DepositRepository : JpaRepository<DepositMaterial, Long> {
@Query("SELECT wm.quantity ,dd.totalDeposit,wm.quantity -dd.totalDeposit AS pending FROM WithdrawMaterial wm INNER JOIN DepositMaterial dd ON wm.id = dd.withDrawId ")
fun getPending(@Param("withDrawId")withDrawId: Long?):List<Result>
}
这是我的结果模型
data class Result(
val pending: Long,
val quantity: Long,
val totalDeposit: Long
)
DepositMaterial 实体类
package com.nilmani.workload.entity
import com.nilmani.workload.enum.Material
import java.time.LocalDateTime
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
@Entity
data class DepositMaterial (
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
val id:Long=-1,
val withDrawId:Long=-1,
val totalDeposit:Long=-1,
val material:Int= Material.NONE.type,
val depositTime:LocalDateTime = LocalDateTime.now(),
val pending:Long = -1,
val isDeposited:Boolean=false,
)
这个问题是什么原因,我只想退回这三个 东西,并存储totalDeposit的结果减法结果和 待处理列中的数量以更新表但是,它给了我错误 存放押金材料
【问题讨论】:
标签: spring-boot kotlin jpql