openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miłosz Tylenda <mtyle...@o2.pl>
Subject Re: postgres : storing binary data using OID
Date Mon, 16 Mar 2009 17:36:33 GMT
Andiqo,

You could try using the so called streaming LOB support. However, this needs using InsputStream
instead of byte[] I think. There is a section on it in the manual [1]. Also, there is a test
case which can help you too [2].

Greetings,
Milosz

[1] http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_streamsupport
[2] http://fisheye6.atlassian.com/browse/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats



> Dear all, 
> 
> I am trying to persist large binary object using PostgreSQL database.
> With this mapping, no problem but performance are not optimum for large
> blobs:
> // Object:
> @Basic(fetch = FetchType.LAZY)
> @Column(name = "DATA")
> private byte[] data;
> // Database:
> CREATE TABLE SPLITBLOBPART (ID BIGSERIAL NOT NULL, DATA BYTEA, ..., PRIMARY
> KEY (ID));
> So I would like to use OIDs:
> http://jdbc.postgresql.org/documentation/83/binary-data.html
> I tried the following
> // Object:
> @Lob
> @Basic(fetch = FetchType.LAZY)
> @Column(name = "DATA", columnDefinition = "OID")
> private byte[] data;
> // Database:
> CREATE TABLE SPLITBLOBPART (ID BIGSERIAL NOT NULL, DATA OID, ..., PRIMARY
> KEY (ID)) WITH (OIDS=TRUE);
> But I still get:
> org.apache.openjpa.lib.jdbc.ReportingSQLException: ERREUR: la colonne « data
> » est de type oid mais l'expression est de type bytea {prepstmnt 435456241
> INSERT INTO SPLITBLOBPART (DATA, DATASIZE, ORDR, VERSION, PARENT_ID) VALUES
> (?, ?, ?, ?, ?) [params=(byte[]) [B@773c550f, (int) 8000000, (int) 5, (int)
> 1, (long) 1]} [code=0, state=42804]
> 	at
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:193)
> 	at
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:58)
> 	at
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:983)
> 	at
> org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
> 	at
> org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
> 	at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1533)
> 	at
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:220)
> 	at
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:113)
> What is the best way to achieve persistence using OIDs with PostgreSQL and
> OpenJPA?!
> Best regards,
> andiqo
> -- 
> View this message in context: http://n2.nabble.com/postgres-%3A-storing-binary-data-using-OID-tp2482851p2482851.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> 
> 

Mime
View raw message