Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3894F1001E for ; Tue, 24 Sep 2013 11:21:46 +0000 (UTC) Received: (qmail 83737 invoked by uid 500); 24 Sep 2013 11:21:19 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 83691 invoked by uid 500); 24 Sep 2013 11:21:12 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 83649 invoked by uid 99); 24 Sep 2013 11:21:06 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Sep 2013 11:21:06 +0000 Date: Tue, 24 Sep 2013 11:21:06 +0000 (UTC) From: "Dag H. Wanvik (JIRA)" To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DERBY-6341) LOB streaming not working with ClientDriver - IOException: object already closed MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-6341?page=3Dcom.atlassian= .jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1377= 6218#comment-13776218 ]=20 Dag H. Wanvik commented on DERBY-6341: -------------------------------------- The OpenJPA manual for version 2.2.2, section 7.7.11 LOB Streaming states: LOB streaming is supported on the following databases. =E2=80=A2 MySQL =E2=80=A2 Oracle =E2=80=A2 PostgreSQL =E2=80=A2 SQL Server =E2=80=A2 DB2 so it seems it's not supported for Derby. =20 > LOB streaming not working with ClientDriver - IOException: object already= closed > -------------------------------------------------------------------------= ------- > > Key: DERBY-6341 > URL: https://issues.apache.org/jira/browse/DERBY-6341 > Project: Derby > Issue Type: Bug > Components: JDBC > Affects Versions: 10.10.1.1 > Reporter: Gary Shank > > I have a small test program using OpenJPA v2.2.2 with Derby database 10.1= 0.1.1 and the Derby org.apache.derby.jdbc.ClientDriver. I also tried Clien= tDriver40. > My entity is defined like this: > @Entity(name =3D "BLOB_TEST") > public class BlobTest implements java.io.Serializable { > public BlobTest() {} > @Id @Column(name =3D "PRIM_KEY", columnDefinition=3D"VARCHAR(10)") > private String primKey =3D null; > public void setKey(String key) { primKey =3D key; } > public String getKey() { return primKey; } > @Persistent @Column(name =3D "DATA") > private InputStream data =3D null; > public void setData(InputStream data) { this.data =3D data; } > public InputStream getData() { return data; } > } > Putting data into the database works fine: > EntityManager em =3D open(); // performs configuration and emf.createEnti= tyManager(); > em.getTransaction().begin(); > FileInputStream fis =3D new FileInputStream("someInputFile"); > BlobTest bt =3D new BlobTest(); > bt.setKey("1"); > bt.setData(fis); > em.persist(bt); > em.getTransaction().commit(); > em.close(); > Getting the data fails with "IOException: The object is already closed." = when any InputStream.read method is called: > EntityManager em =3D open(); // performs configuration and emf.createEnti= tyManager(); > BlobTest bt =3D em.find(BlobTest.class, "1"); // the record is found > InputStream is =3D bt.getData(); > while ( (bytesRead =3D is.read(buffer, 0, len)) !=3D -1 ) > java.io.IOException: The object is already closed. > at org.apache.derby.client.am.CloseFilterInputStream.read(Unknown Source) > Getting the data works if I use JDBC directly like this: > EntityManager em =3D open(); // performs configuration and emf.createEnti= tyManager(); > Connection conx =3D (Connection)org.apache.openjpa.persistence.OpenJPAPer= sistence.cast(em).getConnection(); > PreparedStatement pstmt =3D conx.prepareStatement("select DATA from BLOB_= TEST where PRIM_KEY=3D'1'"); > ResultSet rs =3D pstmt.executeQuery(); > InputStream is =3D rs.getBinaryStream(1); > while ( (bytesRead =3D is.read(buffer, 0, len)) !=3D -1 ) > Is this a bug or am I just doing something wrong? My code has to work wi= th multiple databases so I can't really use JDBC directly - which is I opte= d for using OpenJPA. I'm not sure if this is an OpenJPA issue or Derby iss= ue but, at the moment, I'm assuming is a problem with the client driver. B= y the way, I did not test with the embedded driver since we need it to work= with the client driver. I've looked at the following other issues: > DERBY-3646 mentions "object already close" and the CloseFilterInputStream > OPENJPA-1248 - LOB streaming does not work as expected > OPENJPA-130 - use of InputStream for LOB streaming -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs For more information on JIRA, see: http://www.atlassian.com/software/jira