許哲瑋 发表于 2024-12-27 23:30:06

DAP中使用Mybatis, 查询不到资料,请问是什么问题导致的?

在云上数据库直接下SQL查得到资料, 但透过Mybatis, 未报错, 但资料笔数为0

許哲瑋 发表于 2024-12-27 23:30:06

以当前问题来说, 目前在application.properties, tenantEnabled为true
当tenantEnabled为true, 会将tenantColumnname所设定的值(一般是tenantsid)自动加到SQL的where条件中,
例如, select a from tableA where b = "1"会变成select a from tableA where b = "1" and tenantsid = "123456"
但你在服务的interfase又设定@AllowAnonymous(匿名调用)
当使用@AllowAnonymous, 平台不会验证服务呼叫者的合法性, 也就不会将资料纪录, 所以两相加的情况下, 就会把tenantsid = null组入导致没有资料
页: [1]
查看完整版本: DAP中使用Mybatis, 查询不到资料,请问是什么问题导致的?