-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Caching entities containing Blob (but not the Blob)
PostPosted: Thu May 26, 2005 4:16 pm 
Beginner
Beginner

Joined: Mon Sep 15, 2003 6:28 pm
Posts: 26
This is a feature request.

I have an entity (Picture) containing a java.sql.Blob. I'd like the entity data for my Picture to be cached in the 2nd level cache. I don't need or want the blob data itself to be cached, but I need to be able to fetch the attached entity data without a DB hit.

I can't put @Cache on my Picture entity (I'm using JBoss EJB3) because Blob is not cachable. But since java.sql.Blob is an interface, why not cache the entity and only trigger a DB query in the when the blob is accessed?

I suspect my use case is very common, especially with people developing web applications. HTML images are fetched separately from the page request. My Picture object is just an id, a caption, and the java.sql.Blob. Generating an HTML page with a dozen images requires all the ids and captions, but the actual binary image data is fetched as a series of separate HTTP requests which are likely cached (the browser, a reverse proxy, and a servlet all get a shot).

So my feature request: Allow entities containing java.sql.Blob (and Clob) to be cacheable, only triggering a DB query if the blob is accessed.

Thanks,
Jeff


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2005 11:40 pm 
Regular
Regular

Joined: Tue May 24, 2005 10:19 am
Posts: 65
see :http://www.hibernate.org/41.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 27, 2005 2:47 am 
Beginner
Beginner

Joined: Mon Sep 15, 2003 6:28 pm
Posts: 26
zesj wrote:


I appreciate the referece, but at best that's a workaround. Not a very elegant one, IMHO.

Actually, that pattern (as described) seems rather pointless. From what I understand (and verified myself in the Firebird JDBC driver), blobs typically aren't streamed with the query. Usually they are only streamed when the java.sql.Blob is accessed via getBinaryStream() or getBytes(). This makes sense because all databases that I am aware of store only a pointer to the blob in the row; the blob itself is stored in some other page or series of pages. Streaming the blob data along with the data rows would require jumping the disk head all over the db "file".

The inheritance strategy would probably make the Hibernate cache do what I want, but I'm not sure I can use it. I navigate to my Picture objects by traversing a relationship which presumably would have to be established to the full version of the Picture.

Thanks though.

Jeff


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 27, 2005 9:28 am 
Regular
Regular

Joined: Tue May 24, 2005 10:19 am
Posts: 65
you can:
1)make your cache.
2)hide you class change in navigation code(in iterator?)
3)try check hibernate 3 lazy property and projections.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.