Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Creating BLOBs
Creating BLOBs [message #917807] Thu, 20 September 2012 12:58 Go to next message
Johannes Becker is currently offline Johannes BeckerFriend
Messages: 3
Registered: September 2012
Junior Member
Hi,

I'm trying to switch from Hibernate to EclipseLink. Now I'm facing the problem of creating BLOBs. With Hibernate I solved it this way:

import org.hibernate.LobHelper;
import org.hibernate.classic.Session;

...
  public Blob createBlob(InputStream inputStream, long length)
  {
    Session session = entityManager.unwrap(Session.class);
    LobHelper lobHelper = session.getLobHelper();
    Blob blob = lobHelper.createBlob(inputStream, length);
    return blob;
  }


Any hints how I can do this with EclipseLink? (I'm on an Oracle DB if this matters).

Jonny
Re: Creating BLOBs [message #923027 is a reply to message #917807] Tue, 25 September 2012 14:45 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Normally you can just treat a BLOB as a byte array (byte[]).

If you want the JDBC Blob you can use the unwrap(java.sql.Connection.class) to get the JDBC Connection.


James : Wiki : Book : Blog : Twitter
Re: Creating BLOBs [message #923049 is a reply to message #923027] Tue, 25 September 2012 15:05 Go to previous messageGo to next message
Johannes Becker is currently offline Johannes BeckerFriend
Messages: 3
Registered: September 2012
Junior Member
Hi James,

thanks for your reply.

> Normally you can just treat a BLOB as a byte array (byte[]).
I have large files, so the streaming ability of BLOBs would come handy.

> If you want the JDBC Blob you can use the unwrap(java.sql.Connection.class) to get the JDBC Connection.
Do you have an example? My knowledge in this particlar field isn't too deep.

Thanks
Jonny



Re: Creating BLOBs [message #923063 is a reply to message #923049] Tue, 25 September 2012 15:14 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Search for "JDBC BLOB examples", you basically just create a select Statement execute it to get the Blob and write into it.

Unless the file is extremely large, it would probably fit into memory as a byte[].


James : Wiki : Book : Blog : Twitter
Re: Creating BLOBs [message #923082 is a reply to message #923063] Tue, 25 September 2012 15:33 Go to previous message
Johannes Becker is currently offline Johannes BeckerFriend
Messages: 3
Registered: September 2012
Junior Member
Hi,

> Search for "JDBC BLOB examples", you basically just create a select Statement execute it to get the Blob and write into it.
Ok, I'll do that. Thanks. My hope was, that maybe EclipseLink provided such helper-classes as Hibernate.

Thanks
Jonny
Previous Topic:AggregateCollectionMapping in DyanmicMapping
Next Topic:Transform xml from one XSD version to another
Goto Forum:
  


Current Time: Wed Dec 17 23:23:04 GMT 2014

Powered by FUDForum. Page generated in 0.01748 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software