Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Creating BLOBs
Creating BLOBs [message #917807] Thu, 20 September 2012 08:58 Go to next message
Eclipse UserFriend
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 10:45 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Creating BLOBs [message #923049 is a reply to message #923027] Tue, 25 September 2012 11:05 Go to previous messageGo to next message
Eclipse UserFriend
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 11:14 Go to previous messageGo to next message
Eclipse UserFriend
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[].
Re: Creating BLOBs [message #923082 is a reply to message #923063] Tue, 25 September 2012 11:33 Go to previous message
Eclipse UserFriend
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: Mon Jul 07 05:51:37 EDT 2025

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

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

Back to the top