简体   繁体   English

JPA DB2-删除表后获取SQLCODE“ -204”,SQLSTATE“ 42704”和SQLCODE = -727,SQLSTATE = 56098

[英]JPA DB2 - Getting SQLCODE “-204”, SQLSTATE “42704” and SQLCODE=-727, SQLSTATE=56098 after dropping table

I've got an annoying problem after had one of our tables dropped. 在我们的一张桌子掉下来之后,我遇到了一个烦人的问题。

I'm trying to persist an entity but every time I call the persist(...) on it I get this error message: 我试图持久化一个实体,但是每次我在其上调用persist(...)时,都会收到以下错误消息:

Caused by: com.ibm.db2.jcc.am.SqlException: An error ocurred during the implicit action "3". 引起原因:com.ibm.db2.jcc.am.SqlException:隐式操作“ 3”期间发生错误。 SQLCODE "-204", SQLSTATE "42704" and tokens from message "MYDB2SCHEMA.TB_ABCD".. SQLCODE=-727, SQLSTATE=56098, DRIVER=4.12.56 SQLCODE“ -204”,SQLSTATE“ 42704”和消息“ MYDB2SCHEMA.TB_ABCD”中的令牌。.SQLCODE = -727,SQLSTATE = 56098,DRIVER = 4.12.56

It looks like it is not able to find "MYDB2SCHEMA.TB_ABCD", of course it won't as DBA dropped it last week. 看起来找不到“ MYDB2SCHEMA.TB_ABCD”,当然,因为DBA上周删除了它,所以找不到。 But it is very weird because the entity I'm trying to persist has no relationship to "MYDB2SCHEMA.TB_ABCD" entity, lets call it ABCDEntity. 但这很奇怪,因为我要保留的实体与“ MYDB2SCHEMA.TB_ABCD”实体没有关系,我们称之为ABCDEntity。

To let things even more complicated, I deleted the ABCDEntity so that there is no entity related to it any more, then I searched for "MYDB2SCHEMA.TB_ABCD" in the entire project and there is nothing too, but still I get the same error. 为了使事情变得更加复杂,我删除了ABCDEntity,以使不再有与其相关的实体,然后在整个项目中搜索“ MYDB2SCHEMA.TB_ABCD”,也没有找到任何东西,但是仍然出现相同的错误。

The table I'm trying to persist in DB2 has no relationship to the dead table, I'm not a DBA but I believe if it the dead table had any relationship it would have been removed during the drop. 我试图保留在DB2中的表与死表没有关系,我不是DBA,但我相信如果死表具有任何关系,它将在删除期间删除。

So, why is DB2 or JPA still trying to looking for that table if there is no Entity/table related to it any more? 那么,如果不再有与之相关的实体/表,为什么DB2或JPA仍在尝试寻找该表?

There must be some other object in the database, such as trigger or view, that references the dropped table. 数据库中必须有其他引用删除表的对象,例如触发器或视图。 DB2 attempts to revalidate that object when it is referenced. 当引用该对象时,DB2尝试重新验证该对象。 You might get a better idea what is happening if you trace the exact SQL statement generated by your persistence framework. 如果您跟踪由持久性框架生成的确切SQL语句,可能会更好地了解情况。

If for some reason you cannot ask your DB2 to find out the offending object, you could try this query to find what other objects still depend on the missing table: 如果由于某种原因您不能要求您的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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM