实习生勿喷,欢迎热烈讨论!,也想请教各位大佬怎么回事
jpa传入实体类参数,貌似不可以太多
@Transactional(rollbackFor = Exception.class)
@Modifying
@Query(value = "INSERT into cards (cid,catk,cdef,chp,cms,cas,chit,camp,cname,cpow,context,clevel) " +
"values (:#{#card.cid},:#{#card.catk},:#{#card.cdef},:#{#card.chp},:#{#card.cms}," +
":#{#card.cas},:#{#card.chit},:#{#card.camp},:#{#card.cname},:#{#card.cpow},:#{#card.context},:#{card.clevel})",nativeQuery = true)
int saveOne(@Param("card")Card card);
刚开始这样写的会报错
org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'card' cannot be found on object of type 'java.lang.Object[]' - maybe not public or not valid?
网上无论怎么百度都是与thymeleaf有关,然后我就把thymeleaf的依赖注释了,但是还是有。
最终重新写了这个语句,减少传参量,就好了
@Transactional(rollbackFor = Exception.class)
@Modifying
@Query(value = "INSERT into cards (cid,camp,cname,context) " +
"values (:#{#card.cid},:#{#card.camp},:#{#card.cname},:#{#card.context})",nativeQuery = true)
int saveOne(@Param("card")Card card);
目前我考虑的是,底层有传入参数的大小限制,可能超过这个限制,就没办法找到对应的实体类