Jeff LaMarche <jeff_lamarch..ac.com> wrote:
> I've been using Cayenne for quite some time. Having at one time been a
> fair hand with WO/EOF, I haven't (before now) had any significant
> problems using Cayenne.
>
> I tried searching both this list and the web in general, but excuse me
> if this is a dumb question, or one that's been answered before.
>
> Currently, large data objects (blobs) are mapped to byte arrays.
> Unfortunately, this means that in order to get something into the
> database, you have to be able to hold it in memory. I've got a
> situation where I'm getting out of memory errors because I need to get
> a fairly large object into the database.
>
> Of course, increasing the maximum memory size for the JVM solves this
> problem it, but since the data I have is coming from a stream, I'd
> prefer to use the equivalent of the JDBC setBinaryStream functionality
> to stream the object right into the database without having the whole
> thing in the JVM's memory space. I can, of course, do this outside of
> Cayenne, but would prefer not to if possible, for a number of reasons.
>
> Is there any way to use streams instead of byte arrays for blobs in
> Cayenne?
I've never used Blobs, but I'd say that you just need to subclass
org.objectstyle.cayenne.access.types.ByteArrayType and override
setJdbcObject() to use setBinaryStream, and somehow provide that stream.
To install it, you probably need to extend your JDBCAdaptor's
configureExtendedTypes() method to register your replacement class.
There may be easier ways to do this, but that should get you started.
Possibly you could call
yourJDBCAdaptorInstance.getExtendedTypes().registerType(new
YourByteArrayType()) directly to register it, although I can't guarantee how
safe that is.
This archive was generated by hypermail 2.0.0 : Wed Feb 16 2005 - 16:45:48 EST