You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "B.J. Reed (JIRA)" <ji...@apache.org> on 2009/02/16 17:39:00 UTC

[jira] Created: (OPENJPA-922) setByteArrayInputStream being used in stead of setBytes

setByteArrayInputStream being used in stead of setBytes
-------------------------------------------------------

                 Key: OPENJPA-922
                 URL: https://issues.apache.org/jira/browse/OPENJPA-922
             Project: OpenJPA
          Issue Type: Bug
    Affects Versions: 1.2.0, 2.0.0
         Environment: DB2 on Windows
            Reporter: B.J. Reed
            Assignee: B.J. Reed
             Fix For: 2.0.0, 1.2.0


I have an Entity and one of its fields is defined as CHAR(16) FOR BIT DATA NOT NULL.

When trying to persist the entity, I get the following error:

   Error: SQLCODE=-301, SQLSTATE=07006, SQLERRMC=1, DRIVER=3.50.152  
   {prepstmnt 1386959531 INSERT INTO NULLID.TESTTBL (tkiid) VALUES (?)  
   [params=(InputStream) java.io.ByteArrayInputStream@75947594]}

It seems that the wrong kind of set is being used to set the parameter on the prepared statement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-922) setByteArrayInputStream being used in stead of setBytes

Posted by "B.J. Reed (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-922?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

B.J. Reed updated OPENJPA-922:
------------------------------

    Attachment:     (was: OPENJPA-922-B.patch)

> setByteArrayInputStream being used in stead of setBytes
> -------------------------------------------------------
>
>                 Key: OPENJPA-922
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-922
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0, 2.0.0
>         Environment: DB2 on Windows
>            Reporter: B.J. Reed
>            Assignee: B.J. Reed
>             Fix For: 1.2.2, 1.3.0, 2.0.0
>
>         Attachments: OPENJPA-922-C.patch
>
>
> I have an Entity and one of its fields is defined as CHAR(16) FOR BIT DATA NOT NULL.
> When trying to persist the entity, I get the following error:
>    Error: SQLCODE=-301, SQLSTATE=07006, SQLERRMC=1, DRIVER=3.50.152  
>    {prepstmnt 1386959531 INSERT INTO NULLID.TESTTBL (tkiid) VALUES (?)  
>    [params=(InputStream) java.io.ByteArrayInputStream@75947594]}
> It seems that the wrong kind of set is being used to set the parameter on the prepared statement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (OPENJPA-922) setByteArrayInputStream being used in stead of setBytes

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-922?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Dick reassigned OPENJPA-922:
------------------------------------

    Assignee: Michael Dick  (was: B.J. Reed)

> setByteArrayInputStream being used in stead of setBytes
> -------------------------------------------------------
>
>                 Key: OPENJPA-922
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-922
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0, 2.0.0
>         Environment: DB2 on Windows
>            Reporter: B.J. Reed
>            Assignee: Michael Dick
>             Fix For: 1.3.0, 2.0.0
>
>         Attachments: OPENJPA-922-C.patch
>
>
> I have an Entity and one of its fields is defined as CHAR(16) FOR BIT DATA NOT NULL.
> When trying to persist the entity, I get the following error:
>    Error: SQLCODE=-301, SQLSTATE=07006, SQLERRMC=1, DRIVER=3.50.152  
>    {prepstmnt 1386959531 INSERT INTO NULLID.TESTTBL (tkiid) VALUES (?)  
>    [params=(InputStream) java.io.ByteArrayInputStream@75947594]}
> It seems that the wrong kind of set is being used to set the parameter on the prepared statement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-922) setByteArrayInputStream being used in stead of setBytes

Posted by "B.J. Reed (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-922?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

B.J. Reed updated OPENJPA-922:
------------------------------

    Attachment:     (was: OPENJPA-922.patch)

> setByteArrayInputStream being used in stead of setBytes
> -------------------------------------------------------
>
>                 Key: OPENJPA-922
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-922
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0, 2.0.0
>         Environment: DB2 on Windows
>            Reporter: B.J. Reed
>            Assignee: B.J. Reed
>             Fix For: 1.2.0, 2.0.0
>
>         Attachments: OPENJPA-922-B.patch
>
>
> I have an Entity and one of its fields is defined as CHAR(16) FOR BIT DATA NOT NULL.
> When trying to persist the entity, I get the following error:
>    Error: SQLCODE=-301, SQLSTATE=07006, SQLERRMC=1, DRIVER=3.50.152  
>    {prepstmnt 1386959531 INSERT INTO NULLID.TESTTBL (tkiid) VALUES (?)  
>    [params=(InputStream) java.io.ByteArrayInputStream@75947594]}
> It seems that the wrong kind of set is being used to set the parameter on the prepared statement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-922) setByteArrayInputStream being used in stead of setBytes

Posted by "Milosz Tylenda (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-922?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678274#action_12678274 ] 

Milosz Tylenda commented on OPENJPA-922:
----------------------------------------

Since the test case is likely to fail on databases other then DB2 (specific columnDefinition), it is a good idea to run it only when DB2 is connected. A few ideas:
1. Use the annotation described in OPENJPA-942.
2. Test whether DBDictionary is an instance of DB2Dictionary. Some other tests already use that approach.



> setByteArrayInputStream being used in stead of setBytes
> -------------------------------------------------------
>
>                 Key: OPENJPA-922
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-922
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0, 2.0.0
>         Environment: DB2 on Windows
>            Reporter: B.J. Reed
>            Assignee: B.J. Reed
>             Fix For: 1.2.2, 1.3.0, 2.0.0
>
>         Attachments: OPENJPA-922-B.patch
>
>
> I have an Entity and one of its fields is defined as CHAR(16) FOR BIT DATA NOT NULL.
> When trying to persist the entity, I get the following error:
>    Error: SQLCODE=-301, SQLSTATE=07006, SQLERRMC=1, DRIVER=3.50.152  
>    {prepstmnt 1386959531 INSERT INTO NULLID.TESTTBL (tkiid) VALUES (?)  
>    [params=(InputStream) java.io.ByteArrayInputStream@75947594]}
> It seems that the wrong kind of set is being used to set the parameter on the prepared statement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-922) setByteArrayInputStream being used in stead of setBytes

Posted by "B.J. Reed (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-922?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

B.J. Reed updated OPENJPA-922:
------------------------------

    Patch Info: [Patch Available]

> setByteArrayInputStream being used in stead of setBytes
> -------------------------------------------------------
>
>                 Key: OPENJPA-922
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-922
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0, 2.0.0
>         Environment: DB2 on Windows
>            Reporter: B.J. Reed
>            Assignee: B.J. Reed
>             Fix For: 1.3.0, 2.0.0
>
>         Attachments: OPENJPA-922-C.patch
>
>
> I have an Entity and one of its fields is defined as CHAR(16) FOR BIT DATA NOT NULL.
> When trying to persist the entity, I get the following error:
>    Error: SQLCODE=-301, SQLSTATE=07006, SQLERRMC=1, DRIVER=3.50.152  
>    {prepstmnt 1386959531 INSERT INTO NULLID.TESTTBL (tkiid) VALUES (?)  
>    [params=(InputStream) java.io.ByteArrayInputStream@75947594]}
> It seems that the wrong kind of set is being used to set the parameter on the prepared statement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-922) setByteArrayInputStream being used in stead of setBytes

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-922?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Dick updated OPENJPA-922:
---------------------------------

    Fix Version/s:     (was: 1.2.0)
                   1.3.0
                   1.2.2

> setByteArrayInputStream being used in stead of setBytes
> -------------------------------------------------------
>
>                 Key: OPENJPA-922
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-922
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0, 2.0.0
>         Environment: DB2 on Windows
>            Reporter: B.J. Reed
>            Assignee: B.J. Reed
>             Fix For: 1.2.2, 1.3.0, 2.0.0
>
>         Attachments: OPENJPA-922-B.patch
>
>
> I have an Entity and one of its fields is defined as CHAR(16) FOR BIT DATA NOT NULL.
> When trying to persist the entity, I get the following error:
>    Error: SQLCODE=-301, SQLSTATE=07006, SQLERRMC=1, DRIVER=3.50.152  
>    {prepstmnt 1386959531 INSERT INTO NULLID.TESTTBL (tkiid) VALUES (?)  
>    [params=(InputStream) java.io.ByteArrayInputStream@75947594]}
> It seems that the wrong kind of set is being used to set the parameter on the prepared statement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-922) setByteArrayInputStream being used in stead of setBytes

Posted by "B.J. Reed (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-922?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12676403#action_12676403 ] 

B.J. Reed commented on OPENJPA-922:
-----------------------------------

Was premature with the patch.  The "fix" breaks BLOBs so it's no good.  Basically, both unserialized BLOBS and byte arrays go through the ByteArrayValueHandler in stead of the BlobValueHandler (determined in MappingHandler.defaultHandler()) so the jdbc layer doesn't know there is a difference between the 2 and can't make the correct call to set the data....the use of ByteArrayValueHandler for both also happened on Derby so we need a way to differentiate between the two different kinds of byte[] (BLOBs and char for bit data) so that we know which method to use to set the data in the DB.

> setByteArrayInputStream being used in stead of setBytes
> -------------------------------------------------------
>
>                 Key: OPENJPA-922
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-922
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0, 2.0.0
>         Environment: DB2 on Windows
>            Reporter: B.J. Reed
>            Assignee: B.J. Reed
>             Fix For: 1.2.0, 2.0.0
>
>         Attachments: OPENJPA-922.patch
>
>
> I have an Entity and one of its fields is defined as CHAR(16) FOR BIT DATA NOT NULL.
> When trying to persist the entity, I get the following error:
>    Error: SQLCODE=-301, SQLSTATE=07006, SQLERRMC=1, DRIVER=3.50.152  
>    {prepstmnt 1386959531 INSERT INTO NULLID.TESTTBL (tkiid) VALUES (?)  
>    [params=(InputStream) java.io.ByteArrayInputStream@75947594]}
> It seems that the wrong kind of set is being used to set the parameter on the prepared statement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-922) setByteArrayInputStream being used in stead of setBytes

Posted by "B.J. Reed (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-922?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

B.J. Reed updated OPENJPA-922:
------------------------------

    Attachment: OPENJPA-922-B.patch

I have attached OPENJPA-922-B.patch as a second attempt to fix this problem (also includes the test case).  Basically, the DB2Dictionary needs to override the DBDictionary setBytes and getBytes methods.  For setBytes, it can check the Column definition to use the proper set, for getBytes, the Column is nowhere to be found so it just tries the original getBlob, but if that fails, then it tries to getBytes as a last resort.  I'm sure there's a better way for the get, but I haven't stumbled across it yet.

> setByteArrayInputStream being used in stead of setBytes
> -------------------------------------------------------
>
>                 Key: OPENJPA-922
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-922
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0, 2.0.0
>         Environment: DB2 on Windows
>            Reporter: B.J. Reed
>            Assignee: B.J. Reed
>             Fix For: 1.2.0, 2.0.0
>
>         Attachments: OPENJPA-922-B.patch, OPENJPA-922.patch
>
>
> I have an Entity and one of its fields is defined as CHAR(16) FOR BIT DATA NOT NULL.
> When trying to persist the entity, I get the following error:
>    Error: SQLCODE=-301, SQLSTATE=07006, SQLERRMC=1, DRIVER=3.50.152  
>    {prepstmnt 1386959531 INSERT INTO NULLID.TESTTBL (tkiid) VALUES (?)  
>    [params=(InputStream) java.io.ByteArrayInputStream@75947594]}
> It seems that the wrong kind of set is being used to set the parameter on the prepared statement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (OPENJPA-922) setByteArrayInputStream being used in stead of setBytes

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-922?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Dick resolved OPENJPA-922.
----------------------------------

    Resolution: Fixed

> setByteArrayInputStream being used in stead of setBytes
> -------------------------------------------------------
>
>                 Key: OPENJPA-922
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-922
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0, 2.0.0-M2
>         Environment: DB2 on Windows
>            Reporter: B.J. Reed
>            Assignee: Michael Dick
>             Fix For: 2.0.0
>
>         Attachments: OPENJPA-922-C.patch
>
>
> I have an Entity and one of its fields is defined as CHAR(16) FOR BIT DATA NOT NULL.
> When trying to persist the entity, I get the following error:
>    Error: SQLCODE=-301, SQLSTATE=07006, SQLERRMC=1, DRIVER=3.50.152  
>    {prepstmnt 1386959531 INSERT INTO NULLID.TESTTBL (tkiid) VALUES (?)  
>    [params=(InputStream) java.io.ByteArrayInputStream@75947594]}
> It seems that the wrong kind of set is being used to set the parameter on the prepared statement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-922) setByteArrayInputStream being used in stead of setBytes

Posted by "Donald Woods (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-922?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Donald Woods updated OPENJPA-922:
---------------------------------

    Fix Version/s:     (was: 2.0.0)
                   2.0.0-M3

> setByteArrayInputStream being used in stead of setBytes
> -------------------------------------------------------
>
>                 Key: OPENJPA-922
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-922
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0, 2.0.0-M2
>         Environment: DB2 on Windows
>            Reporter: B.J. Reed
>            Assignee: Michael Dick
>             Fix For: 2.0.0-M3
>
>         Attachments: OPENJPA-922-C.patch
>
>
> I have an Entity and one of its fields is defined as CHAR(16) FOR BIT DATA NOT NULL.
> When trying to persist the entity, I get the following error:
>    Error: SQLCODE=-301, SQLSTATE=07006, SQLERRMC=1, DRIVER=3.50.152  
>    {prepstmnt 1386959531 INSERT INTO NULLID.TESTTBL (tkiid) VALUES (?)  
>    [params=(InputStream) java.io.ByteArrayInputStream@75947594]}
> It seems that the wrong kind of set is being used to set the parameter on the prepared statement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-922) setByteArrayInputStream being used in stead of setBytes

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-922?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Dick updated OPENJPA-922:
---------------------------------

    Fix Version/s:     (was: 1.2.2)

> setByteArrayInputStream being used in stead of setBytes
> -------------------------------------------------------
>
>                 Key: OPENJPA-922
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-922
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0, 2.0.0
>         Environment: DB2 on Windows
>            Reporter: B.J. Reed
>            Assignee: B.J. Reed
>             Fix For: 1.3.0, 2.0.0
>
>         Attachments: OPENJPA-922-C.patch
>
>
> I have an Entity and one of its fields is defined as CHAR(16) FOR BIT DATA NOT NULL.
> When trying to persist the entity, I get the following error:
>    Error: SQLCODE=-301, SQLSTATE=07006, SQLERRMC=1, DRIVER=3.50.152  
>    {prepstmnt 1386959531 INSERT INTO NULLID.TESTTBL (tkiid) VALUES (?)  
>    [params=(InputStream) java.io.ByteArrayInputStream@75947594]}
> It seems that the wrong kind of set is being used to set the parameter on the prepared statement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-922) setByteArrayInputStream being used in stead of setBytes

Posted by "B.J. Reed (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-922?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

B.J. Reed updated OPENJPA-922:
------------------------------

    Attachment: OPENJPA-922.patch

For DB2, the DBDictionary useSetBytesForBlobs field is set to false.  Within setBytes, if this flag is true, setBinaryStream() is called regardless of what kind of column we really have (BYTES or BLOB_OBJECT).  Patch includes change to the if statement to also check the column type before using the setBinaryStream and a simple test case.

Please apply to both 1.2.x and trunk

> setByteArrayInputStream being used in stead of setBytes
> -------------------------------------------------------
>
>                 Key: OPENJPA-922
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-922
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0, 2.0.0
>         Environment: DB2 on Windows
>            Reporter: B.J. Reed
>            Assignee: B.J. Reed
>             Fix For: 1.2.0, 2.0.0
>
>         Attachments: OPENJPA-922.patch
>
>
> I have an Entity and one of its fields is defined as CHAR(16) FOR BIT DATA NOT NULL.
> When trying to persist the entity, I get the following error:
>    Error: SQLCODE=-301, SQLSTATE=07006, SQLERRMC=1, DRIVER=3.50.152  
>    {prepstmnt 1386959531 INSERT INTO NULLID.TESTTBL (tkiid) VALUES (?)  
>    [params=(InputStream) java.io.ByteArrayInputStream@75947594]}
> It seems that the wrong kind of set is being used to set the parameter on the prepared statement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-922) setByteArrayInputStream being used in stead of setBytes

Posted by "B.J. Reed (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-922?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

B.J. Reed updated OPENJPA-922:
------------------------------

    Attachment: OPENJPA-922-C.patch

Thanks Milosz.  I was so worried about the fix not breaking other DBs that I forgot about the test breaking other DBs.  Have attached the OPENJPA-922-C.patch to fix this.  When the annotation in OPENJPA-942 is working, it would probably be better to use that.

> setByteArrayInputStream being used in stead of setBytes
> -------------------------------------------------------
>
>                 Key: OPENJPA-922
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-922
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0, 2.0.0
>         Environment: DB2 on Windows
>            Reporter: B.J. Reed
>            Assignee: B.J. Reed
>             Fix For: 1.2.2, 1.3.0, 2.0.0
>
>         Attachments: OPENJPA-922-B.patch, OPENJPA-922-C.patch
>
>
> I have an Entity and one of its fields is defined as CHAR(16) FOR BIT DATA NOT NULL.
> When trying to persist the entity, I get the following error:
>    Error: SQLCODE=-301, SQLSTATE=07006, SQLERRMC=1, DRIVER=3.50.152  
>    {prepstmnt 1386959531 INSERT INTO NULLID.TESTTBL (tkiid) VALUES (?)  
>    [params=(InputStream) java.io.ByteArrayInputStream@75947594]}
> It seems that the wrong kind of set is being used to set the parameter on the prepared statement.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.