我正在使用mariadb作为我的ORM。我正在使用jpa在表中使用主键删除一行。这是一个简单的本机删除查询。看起来,如果不存在匹配的行,则结果集处理会出现此问题。但是,该行为并不一致,并不经常发生。
@Query(value ="Delete from table where id = :paramId",nativeQuery =true)
java.lang.ArrayIndexOutOfBoundsException: null
at org.mariadb.jdbc.internal.com.read.Buffer.getLengthEncodedBytes(Buffer.java:318) ~[mariadb-java-client-2.2.0.jar!/:na]
at org.mariadb.jdbc.internal.com.read.resultset.ColumnInformation.getString(ColumnInformation.java:242) ~[mariadb-java-client-2.2.0.jar!/:na]
at org.mariadb.jdbc.internal.com.read.resultset.ColumnInformation.getName(ColumnInformation.java:258) ~[mariadb-java-client-2.2.0.jar!/:na]
at org.mariadb.jdbc.MariaDbResultSetMetaData.getColumnLabel(MariaDbResultSetMetaData.java:187) ~[mariadb-java-client-2.2.0.jar!/:na]
at org.hibernate.dialect.ColumnAliasExtractor$1.extractColumnAlias(ColumnAliasExtractor.java:39) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.loader.custom.JdbcResultMetadata.getColumnName(JdbcResultMetadata.java:59) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.loader.custom.ScalarResultColumnProcessor.performDiscovery(ScalarResultColumnProcessor.java:39) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:487) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.loader.Loader.getResultSet(Loader.java:2125) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1900) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1876) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.loader.Loader.doQuery(Loader.java:919) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2617) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2600) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2429) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.loader.Loader.list(Loader.java:2424) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:336) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1967) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:322) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:125) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:606) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final]
at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:529) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final]
表结构:
创建表inst
(
INST_ID
INT(11)NOT NULL AUTO_INCREMENT,
STATUS_ID
SMALLINT(6)NULL缺省NULL,
MODULE_ID
SMALLINT(6)NULL缺省值'2',
STAGE_CONFIG_ID
MEDIUMINT(9)NULL缺省NULL,
COMMENTS
VARCHAR(1000)NULL缺省NULL,
IS_LOCKED
VARCHAR(1)NULL缺省NULL,
LOCKED_BY
VARCHAR(100)NULL缺省NULL,
RECORD_DATE
DATETIME(6)NOT NULL,
VERSION
INT(11)NULL缺省NULL,
ROLE_ID
MEDIUMINT(9)NULL缺省NULL,
主键(INST_ID
),
唯一索引INST_PK
(INST_ID
),
索引INST_MODULE_FK
(MODULE_ID
),
索引INST_WKF_STAGE_CONFIG_FK1
(STAGE_CONFIG_ID
),
索引INST_ID
(INST_ID
,STAGE_CONFIG_ID
),
约束INST_MODULE_FK
外键(MODULE_ID
)参考module
(MODULE_ID
),
约束INST_WKF_STAGE_CONFIG_FK1
外键(STAGE_CONFIG_ID
)参考stage_config
(STAGE_CONFIG_ID
)
)