返回列表 發布新帖

DAP中使用Mybatis, 查詢不到資料,請問是什麼問題導致的?

178 1
發表於 2025-2-27 11:26 | 查看全部 閱讀模式
問答

緊急程度

已完結
在雲端上資料庫直接下SQL查得到資料, 但透過Mybatis, 未報錯, 但資料筆數為0

最佳答案

查看完整內容

以當前問題來說, 目前在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, 平台不會驗證服務呼叫者的合法性, 也就不會將資料紀錄, 所以 ...

評論1

許哲瑋樓主Lv.9 發表於 2025-2-27 11:26 | 查看全部
以當前問題來說, 目前在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組入導致沒有資料

回復

您需要登錄後才可以回帖 登錄 | 立即注册

本版積分規則

  • 加入Line諮詢
Copyright © 2026 鼎新數智股份有限公司 版權所有 All Rights Reserved. Powered by Discuz! X5.0
關燈 在本版發帖
即将开放
返回頂部
快速回復 返回頂部 返回列表