2015-11-10 92 views
0

我有一個表被刪除後,我遇到了一個討厭的問題。JPA DB2 - 在刪除表之後獲取SQLCODE「-204」,SQLSTATE「42704」和SQLCODE = -727,SQLSTATE = 56098

我想堅持的實體,但每次我打電話的堅持(...)就可以了,我得到這個錯誤信息:

產生的原因:com.ibm.db2.jcc.am.SqlException :隱式動作「3」期間發生錯誤。 SQLCODE「-204」,SQLSTATE「42704」和來自消息「MYDB2SCHEMA.TB_ABCD」的令牌。SQLCODE = -727,SQLSTATE = 56098,DRIVER = 4.12.56

看起來它無法找到「MYDB2SCHEMA .TB_ABCD「,當然不會像上週DBA放棄它。但這很奇怪,因爲我試圖堅持的實體與「MYDB2SCHEMA.TB_ABCD」實體沒有任何關係,我們稱之爲ABCDEntity。

爲了讓事情變得更加複雜,我刪除了ABCDEntity,以便不再有與它相關的實體,然後我在整個項目中搜索了「MYDB2SCHEMA.TB_ABCD」,並且沒有任何東西,但仍然得到同樣的錯誤。

我試圖堅持在DB2中的表與死表沒有任何關係,我不是DBA,但我相信如果它死表有任何關係,它將在刪除過程中被刪除。

那麼,爲什麼DB2或JPA仍然試圖查找該表,如果沒有與其相關的實體/表格了?

回答

0

數據庫中必須有一些其他對象,如觸發器或視圖,它們引用了已刪除的表。當DB2被引用時,DB2會嘗試重新驗證該對象。如果您追蹤持久性框架生成的確切SQL語句,您可能會更好地瞭解發生了什麼。

如果由於某種原因,你不能要求你的DB2,找出有問題的對象,你可以試試這個查詢查找其他對象仍取決於缺少的表:

with t(s,n) as (values ('YOURSCHEMA','YOURTABLE')) 
select 'control' as object_type, 
     dschema  as schema, 
     dname  as name, 
     case dtype when 'y' then 'row permission' when '2' then 'column mask' else 'unknown' end as depend_type 
from syscat.controldep join t on btype = 'T' and (bschema,bname) = (s,n) 
union all 
select 'datatype' as object_type, 
     typeschema as schema, 
     typename  as name, 
     case when typemodulename is not null then 'in module '|| typemodulename else '' end as depend_type 
from syscat.datatypedep join t on btype = 'T' and (bschema,bname) = (s,n) 
union all 
select 'index'  as object_type, 
     indschema as schema, 
     indname  as name, 
     ''   as depend_type 
from syscat.indexdep join t on btype = 'T' and (bschema,bname) = (s,n) 
union all 
select 'package' as object_type, 
     pkgschema as schema, 
     pkgname  as name, 
     ''   as depend_type 
from syscat.packagedep join t on btype = 'T' and (bschema,bname) = (s,n) 
union all 
select 'routine' as object_type, 
     routineschema as schema, 
     specificname  as name, 
     case when routinemodulename is not null then 'in module '|| routinemodulename else '' end as depend_type 
from syscat.routinedep join t on btype = 'T' and (bschema,bname) = (s,n) 
union all 
select 'table-ish' as object_type, 
     tabschema as schema, 
     tabname  as name, 
     case dtype when 'S' then 'MQT' 
        when 'T' then 'staging table' 
        when 'V' then 'view' 
        when '7' then 'synopsis table' 
        else dtype end as depend_type 
from syscat.tabdep join t on btype = 'T' and (bschema,bname) = (s,n) 
union all 
select 'trigger' as object_type, 
     trigschema as schema, 
     trigname  as name, 
     ''   as depend_type 
from syscat.trigdep join t on btype = 'T' and (bschema,bname) = (s,n) 
union all 
select 'global var'  as object_type, 
     varschema  as schema, 
     varname   as name, 
     case when varmodulename is not null then 'in module '|| varmodulename else '' end as depend_type 
from syscat.variabledep join t on btype = 'T' and (bschema,bname) = (s,n) 
相關問題