FAQ
My concern is that it seems too low-level, accessing DataNode
directly (hence you have to manage connection state and all that).
But there is another more fundamental problem of a Blob becoming
invalid when the connection that generated it is closed.

So I wonder if instead of mapping a column directly as a Blob, we
should implement our own mapping primitive (BlobHolder?), that can re-
read the Blob as many times as requested. The other piece is a
callback interface that is provided with the regular Blob instance
guaranteed to be in the valid state (i.e. inside a Cayenne
transaction). A callback can read the stream, and do whatever with it
(like pushing data to HttpResponse):

interface (or class) BlobHolder {
void readBlob(BlobCallback callback);
}

interface BlobCallback {
// this is called within transaction span and the Blob is
guaranteed to be valid
void blobRead(Blob);
}

We can use a BlobFault similar to what you wrote as a way to
initialize BlobHolder with an object qualifier (so that it knows how
to fetch itself).

What do you think?

Andrus



On Nov 20, 2006, at 6:21 PM, Tore Halset (JIRA) wrote:
[ http://issues.apache.org/cayenne/browse/CAY-316?page=all ]

Tore Halset updated CAY-316:
----------------------------

Attachment: BlobFaultType.java
stream support for blob/clob
----------------------------

Key: CAY-316
URL: http://issues.apache.org/cayenne/browse/CAY-316
Project: Cayenne
Type: New Feature
Components: Cayenne Core Library
Versions: 1.2 [STABLE]
Reporter: Tore Halset
Assignee: Andrus Adamchik
Priority: Minor
Fix For: UNDEFINED FUTURE
Attachments: BlobFault.java, BlobFaultType.java

It would be nice if cayenne would support for streaming blob/clob.
It should at least be possible to prevent caching of blobs.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the
administrators:
http://issues.apache.org/cayenne/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira

Search Discussions

  • Tore Halset at Nov 22, 2006 at 8:12 am
    Hello.

    I agree that it is too low-level. I also see the problem in my
    solution that could happen if a Blob got invalidated while it is
    being read from. Lets go for the BlobCallback interface that you
    sketched out as it solves this problem.

    Do you think I could implement BlobHolder.readBlob with plain jdbc
    (generated from the model) as I did in BlobFault.getBlob()? The
    reason for doing this is that I need to bypass the ExtendedType stuff
    and have full control of the selecting transaction. Or is it possible
    to have the same level of control in a Query?

    Writing is pretty easy if you just provide a MemoryBlob and set it. I
    think streaming insert would require som special stuff for each jdbc-
    driver.

    BlobHolder could probably be the Fault like I did with BlobFault?

    Regards,
    - Tore.

    On Nov 22, 2006, at 5:20 , Andrus Adamchik wrote:
    My concern is that it seems too low-level, accessing DataNode
    directly (hence you have to manage connection state and all that).
    But there is another more fundamental problem of a Blob becoming
    invalid when the connection that generated it is closed.

    So I wonder if instead of mapping a column directly as a Blob, we
    should implement our own mapping primitive (BlobHolder?), that can
    re-read the Blob as many times as requested. The other piece is a
    callback interface that is provided with the regular Blob instance
    guaranteed to be in the valid state (i.e. inside a Cayenne
    transaction). A callback can read the stream, and do whatever with
    it (like pushing data to HttpResponse):

    interface (or class) BlobHolder {
    void readBlob(BlobCallback callback);
    }

    interface BlobCallback {
    // this is called within transaction span and the Blob is
    guaranteed to be valid
    void blobRead(Blob);
    }

    We can use a BlobFault similar to what you wrote as a way to
    initialize BlobHolder with an object qualifier (so that it knows
    how to fetch itself).
  • Andrus Adamchik at Nov 22, 2006 at 11:32 pm

    On Nov 22, 2006, at 3:11 AM, Tore Halset wrote:

    Do you think I could implement BlobHolder.readBlob with plain jdbc
    (generated from the model) as I did in BlobFault.getBlob()? The
    reason for doing this is that I need to bypass the ExtendedType
    stuff and have full control of the selecting transaction. Or is it
    possible to have the same level of control in a Query?
    If possible, stay away from JDBC code in the query. A raw row
    SQLTemplate with a manual Cayenne transaction should work as far as I
    can tell. I don't see why ExtendedTypes would interfere with it.

    Writing is pretty easy if you just provide a MemoryBlob and set it.
    I think streaming insert would require som special stuff for each
    jdbc-driver.
    Yeah, this may require some experimentation.
    BlobHolder could probably be the Fault like I did with BlobFault?
    Probably ok for now, but we will likely change it in the future, as
    with coming 3.0 POJO support faulting will be implemented differently.

    Andrus
  • Tore Halset at Nov 26, 2006 at 12:44 am

    On Nov 23, 2006, at 00:31, Andrus Adamchik wrote:

    If possible, stay away from JDBC code in the query. A raw row
    SQLTemplate with a manual Cayenne transaction should work as far as
    I can tell. I don't see why ExtendedTypes would interfere with it.
    It was not related to ExtendedTypes. Sorry. The problem was CAY-711.
    I have fixed CAY-711 and uploaded a new version that uses SQLTemplate
    and the callback/transaction stuff.

    - Tore.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categoriescayenne
postedNov 22, '06 at 4:20a
activeNov 26, '06 at 12:44a
posts4
users2
websitecayenne.apache.org

2 users in discussion

Andrus Adamchik: 2 posts Tore Halset: 2 posts

People

Translate

site design / logo © 2021 Grokbase