• <small id='iGqy5'></small><noframes id='iGqy5'>

    <i id='iGqy5'><tr id='iGqy5'><dt id='iGqy5'><q id='iGqy5'><span id='iGqy5'><b id='iGqy5'><form id='iGqy5'><ins id='iGqy5'></ins><ul id='iGqy5'></ul><sub id='iGqy5'></sub></form><legend id='iGqy5'></legend><bdo id='iGqy5'><pre id='iGqy5'><center id='iGqy5'></center></pre></bdo></b><th id='iGqy5'></th></span></q></dt></tr></i><div id='iGqy5'><tfoot id='iGqy5'></tfoot><dl id='iGqy5'><fieldset id='iGqy5'></fieldset></dl></div>
      • <bdo id='iGqy5'></bdo><ul id='iGqy5'></ul>
      <tfoot id='iGqy5'></tfoot>

    1. <legend id='iGqy5'><style id='iGqy5'><dir id='iGqy5'><q id='iGqy5'></q></dir></style></legend>

      1. OpenJPA 查询第二次失败(可能是因为字节数组参数)

        OpenJPA query fails second time (possibly because of byte array parameter)(OpenJPA 查询第二次失败(可能是因为字节数组参数))

        <small id='63FuB'></small><noframes id='63FuB'>

      2. <legend id='63FuB'><style id='63FuB'><dir id='63FuB'><q id='63FuB'></q></dir></style></legend>

            <tbody id='63FuB'></tbody>

          • <tfoot id='63FuB'></tfoot>

              <bdo id='63FuB'></bdo><ul id='63FuB'></ul>
              <i id='63FuB'><tr id='63FuB'><dt id='63FuB'><q id='63FuB'><span id='63FuB'><b id='63FuB'><form id='63FuB'><ins id='63FuB'></ins><ul id='63FuB'></ul><sub id='63FuB'></sub></form><legend id='63FuB'></legend><bdo id='63FuB'><pre id='63FuB'><center id='63FuB'></center></pre></bdo></b><th id='63FuB'></th></span></q></dt></tr></i><div id='63FuB'><tfoot id='63FuB'></tfoot><dl id='63FuB'><fieldset id='63FuB'></fieldset></dl></div>
                  本文介绍了OpenJPA 查询第二次失败(可能是因为字节数组参数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有以下 OpenJPA 查询(通过 db2 数据库):

                  I have following OpenJPA query (over db2 database):

                  Select number from Number number where number.uuid = :uuid
                  

                  列 uuid 定义为 VARCHAR FOR BIT DATA(16).在实体中它表示为 byte[] 类型字段.

                  Column uuid defined as VARCHAR FOR BIT DATA(16). In entity it represented as byte[] type field.

                  问题是,当我第一次使用该查询调用方法时(在 WebSphere 服务器启动后)它工作正常.后续调用会导致错误(我什至启用了跟踪日志,看看错误在哪里)

                  The problem is that when I call method with that query first time(after WebSphere server is up) it works fine. Consequential calls result in error (I even enabled trace log see where the error is)

                  1st time:> query is running, everything's ok
                  [11/25/15 13:27:03:803 IST] 0000001d Query         3   openjpa.Query: Trace: Executing query: [Select n from Number n where n.uuid = :uuid] with parameters: ?
                  [11/25/15 13:27:04:199 IST] 0000001d jdbc_SQL      3   openjpa.jdbc.SQL: Trace: <t 507109353, conn 1755254015> executing prepstmnt -1123134307 SELECT t0.NUMBER_ID, t0.comment, t0.EMPLOYEE_ID, t0.number, t0.RANGE_ID, t0.status, t0.uuid FROM PHONES.Number t0 WHERE (t0.uuid = ?)  [params=?]
                  [11/25/15 13:27:04:249 IST] 0000001d jdbc_SQL      3   openjpa.jdbc.SQL: Trace: <t 507109353, conn 1755254015> [50 ms] spent
                  [11/25/15 13:27:04:251 IST] 0000001d jdbc_JDBC     3   openjpa.jdbc.JDBC: Trace: <t 507109353, conn 1755254015> [0 ms] close
                  2nd time:>
                  [11/25/15 13:27:09:068 IST] 0000001d Query         3   openjpa.Query: Trace: Executing query: [Select n from Number n where n.uuid = :uuid] with parameters: ?
                  [11/25/15 13:27:09:556 IST] 0000001d BusinessExcep E   CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "approve" on bean "BeanId(PhoneAllocationEAR#PhoneAllocationEJB.jar#RangeProvider, null)". Exception data: <openjpa-2.1.2-SNAPSHOT-r422266:1548248 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Failed to execute query "Select n from Number n where n.uuid = :uuid". Check the query syntax for correctness. See nested exception for details.
                  

                  这是嵌套异常:

                  Caused by: java.lang.NullPointerException
                  at org.apache.openjpa.jdbc.sql.DB2Dictionary.setBytes(DB2Dictionary.java:1037)
                  at org.apache.openjpa.jdbc.sql.DBDictionary.setUnknown(DBDictionary.java:1481)
                  at org.apache.openjpa.jdbc.sql.DBDictionary.setUnknown(DBDictionary.java:1429)
                  at org.apache.openjpa.jdbc.kernel.PreparedSQLStoreQuery$PreparedSQLExecutor.executeQuery(PreparedSQLStoreQuery.java:114)
                  at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1005)
                  at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863)
                  ... 86 more 
                  

                  这是出现异常的代码:

                  public String findByUUID(UUID uuid) {
                  
                      TypedQuery<Number> query = em.createQuery("Select n from Number n where n.uuid = :uuid", Number.class);
                      ByteBuffer bb = ByteBuffer.allocate(16);
                      bb.putLong(uuid.getMostSignificantBits());
                      bb.putLong(uuid.getLeastSignificantBits());
                      byte[] parameter = bb.array();
                  
                      query.setParameter("uuid", parameter);
                  
                      List<Number> result = new ArrayList<Number>(query.getResultList());
                      return result;
                  }
                  

                  *附加信息:如果我从列描述中删除 BIT DATA - 我会收到另一个错误:

                  *additional info: If I drop BIT DATA from column description - I get another error :

                  nested exception is: javax.ejb.EJBException: See nested exception; nested exception is: org.apache.openjpa.persistence.PersistenceException: The value of input variable, expression or parameter number "1" cannot be used because of its data type.. SQLCODE=-301, SQLSTATE=07006, DRIVER=4.14.113 {prepstmnt 2039708348 SELECT t0.NUMBER_ID, t0.comment, t0.EMPLOYEE_ID, t0.number, t0.RANGE_ID, t0.status, t0.uuid FROM PHONES.Number t0 WHERE (t0.uuid = ?) [params=?]} [code=-301, state=07006]SQLCA OUTPUT[Errp=SQLRI4A4, Errd=-2145779603, 0, 0, 0, -3700, 0] The value of input variable, expression or parameter number "1" cannot be used because of its data type.. SQLCODE=-301, SQLSTATE=07006, DRIVER=4.14.113 FailedObject: Select n from Number n where n.uuid = :uuid [java.lang.String]
                  

                  我是通过查看 openJPA 但同时它对我没有帮助.

                  I learned it from looking at source of openJPA but it doesn't help me meanwhile.

                  推荐答案

                  尝试禁用准备好的查询缓存.众所周知,它非常有问题.如果需要,您可以搜索 OpenJPA JIRA 以查找详细信息.

                  Try to disable the prepared query cache. It's known to be quite buggy. You can search the OpenJPA JIRA to find details if you want.

                  <property name="openjpa.jdbc.QuerySQLCache" value="true(EnableStatistics=true)">

                  这篇关于OpenJPA 查询第二次失败(可能是因为字节数组参数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
                  Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
                  How to convert Integer to int?(如何将整数转换为整数?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
                  Inconsistent behavior on java#39;s ==(java的行为不一致==)
                  Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)
                    <tfoot id='y2mtr'></tfoot>
                      <tbody id='y2mtr'></tbody>
                    <i id='y2mtr'><tr id='y2mtr'><dt id='y2mtr'><q id='y2mtr'><span id='y2mtr'><b id='y2mtr'><form id='y2mtr'><ins id='y2mtr'></ins><ul id='y2mtr'></ul><sub id='y2mtr'></sub></form><legend id='y2mtr'></legend><bdo id='y2mtr'><pre id='y2mtr'><center id='y2mtr'></center></pre></bdo></b><th id='y2mtr'></th></span></q></dt></tr></i><div id='y2mtr'><tfoot id='y2mtr'></tfoot><dl id='y2mtr'><fieldset id='y2mtr'></fieldset></dl></div>
                        <bdo id='y2mtr'></bdo><ul id='y2mtr'></ul>

                        <legend id='y2mtr'><style id='y2mtr'><dir id='y2mtr'><q id='y2mtr'></q></dir></style></legend>

                        1. <small id='y2mtr'></small><noframes id='y2mtr'>