You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/05/21 08:30:21 UTC

[GitHub] [shardingsphere] shooray opened a new issue #5727: The int(or bigint) value is null, but jpa with shardingsphere-jdbc returns zero.

shooray opened a new issue #5727:
URL: https://github.com/apache/shardingsphere/issues/5727


   We use springboot & jpa to read records from MySQL 5.6.x. 
   There are several tables sharding by shardingsphere-jdbc with monthly strategy.
   Some int(or bigint) fields is nullable, and its value is NULL as well. When the record is read by JPA methods such as findAll(), the Integer(or Long) fields with null returns zero.
   
   I consider that is a bug, because other non-sharding tables can correctly return null value.
   
   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response **more than 7 days** and we cannot reproduce it on current information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   ### Expected behavior
   
   ### Actual behavior
   
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   ### Example codes for reproduce this issue (such as a github link).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuohai666 closed issue #5727: The int(or bigint) value is null, but jpa with shardingsphere-jdbc returns zero.

Posted by GitBox <gi...@apache.org>.
tuohai666 closed issue #5727:
URL: https://github.com/apache/shardingsphere/issues/5727


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] shooray edited a comment on issue #5727: The int(or bigint) value is null, but jpa with shardingsphere-jdbc returns zero.

Posted by GitBox <gi...@apache.org>.
shooray edited a comment on issue #5727:
URL: https://github.com/apache/shardingsphere/issues/5727#issuecomment-632575385


   Hi @kimmking . I don't quite agree with you.
   First of all, the value of the field is NULL and 0 have different meanings. Secondly, defining the object type and basic type in the Entity class also has different meanings. JPA and some ORMs can correctly handle basic types and object types. As the underlying facilities of the sub-library and table, the original data should also be kept.
   Yesterday I suggest you to modify
   org.apache.shardingsphere.shardingjdbc.jdbc.core.resultset.ShardingResultSet.java
   public long getLong (final int columnIndex) throws SQLException;
   The return value of Long is indeed wrong.
   
   But can it be used first when processing data
   java.sql.ResultSet
   of
   Object getObject (String paramString);
   Method to receive data, if it is null, it returns null. If not null, then return the value of the basic type?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] kimmking commented on issue #5727: The int(or bigint) value is null, but jpa with shardingsphere-jdbc returns zero.

Posted by GitBox <gi...@apache.org>.
kimmking commented on issue #5727:
URL: https://github.com/apache/shardingsphere/issues/5727#issuecomment-632121535


   Hi, @shooray 
   We can't modify this method return type, case it defined by JDBC(java.sql.ResultSet):
   
   ```
   /**
        * Retrieves the value of the designated column in the current row
        * of this <code>ResultSet</code> object as
        * an <code>int</code> in the Java programming language.
        *
        * @param columnIndex the first column is 1, the second is 2, ...
        * @return the column value; if the value is SQL <code>NULL</code>, the
        * value returned is <code>0</code>
        * @exception SQLException if the columnIndex is not valid;
        * if a database access error occurs or this method is
        *            called on a closed result set
        */
       int getInt(int columnIndex) throws SQLException;
   
       /**
        * Retrieves the value of the designated column in the current row
        * of this <code>ResultSet</code> object as
        * a <code>long</code> in the Java programming language.
        *
        * @param columnIndex the first column is 1, the second is 2, ...
        * @return the column value; if the value is SQL <code>NULL</code>, the
        * value returned is <code>0</code>
        * @exception SQLException if the columnIndex is not valid;
        * if a database access error occurs or this method is
        *            called on a closed result set
        */
       long getLong(int columnIndex) throws SQLException;
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] shooray commented on issue #5727: The int(or bigint) value is null, but jpa with shardingsphere-jdbc returns zero.

Posted by GitBox <gi...@apache.org>.
shooray commented on issue #5727:
URL: https://github.com/apache/shardingsphere/issues/5727#issuecomment-632575385


   Hi kimmking. I don't quite agree with you.
   First of all, the value of the field is NULL and 0 have different meanings. Secondly, defining the object type and basic type in the Entity class also has different meanings. JPA and some ORMs can correctly handle basic types and object types. As the underlying facilities of the sub-library and table, the original data should also be kept.
   Yesterday I suggest you to modify
   org.apache.shardingsphere.shardingjdbc.jdbc.core.resultset.ShardingResultSet.java
   public long getLong (final int columnIndex) throws SQLException;
   The return value of Long is indeed wrong.
   
   But can it be used first when processing data
   java.sql.ResultSet
   of
   Object getObject (String paramString);
   Method to receive data, if it is null, it returns null. If not null, then return the value of the basic type?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuohai666 commented on issue #5727: The int(or bigint) value is null, but jpa with shardingsphere-jdbc returns zero.

Posted by GitBox <gi...@apache.org>.
tuohai666 commented on issue #5727:
URL: https://github.com/apache/shardingsphere/issues/5727#issuecomment-645401445


   Closed because of no response anymore.
   
   Actually, I don't think your description makes sense.
   
   Of course, Null and 0 have diffenent meanings in database. But they have same meaning out of database. If you got a Null from JDBC, it is 0, vice versa. In other words, if you treat the result as a int , it is 0, while you treat it as an object, it is Null, it depends on you.
   
   Besides, Iet's make sure we get the consensus on Null is not 'Null'.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] kimmking commented on issue #5727: The int(or bigint) value is null, but jpa with shardingsphere-jdbc returns zero.

Posted by GitBox <gi...@apache.org>.
kimmking commented on issue #5727:
URL: https://github.com/apache/shardingsphere/issues/5727#issuecomment-633644923


   Partiallly agree with you about that getObject can return null.
   In another hand, you can't modify the method return type with long or int.
   
   So, check an int field is null via getObject or rs.wasNull to be a better way.
   And now, Can you try to fix it?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org