HIBERNATE, ORACLE, BLOB > 4k

Discussion in 'Java' started by chomiq, Oct 20, 2005.

  1. chomiq

    chomiq Guest

    How to put blob ( > 4k ) into Oracle9 using Hiberanete?

    I got problem with inserting BLOB > 4k into Oracle database.

    Example from http://www.hibernate.org/56.html do not works.

    I use Tomcata5.5, Hibernate2.1.7, Oracle9, Java 1.5.

    This line in my code:
    ( (oracle.sql.BLOB)atta.getData() ).putBytes(0,temp);

    throws ClassCastException , why??

    Is any other way to insert Blob into Oracle?

    Do I have to use some other driver then oracle.thin ?
    My context.xml looks like:

    <Resource
    name="jdbc/test"
    auth="Container"
    type="javax.sql.DataSource"
    username="migration"
    password="***"
    driverClassName="oracle.jdbc.driver.OracleDriver"
    url="jdbc:eek:racle:thin:mad:123.123.123.123:2222:TEST"
    maxActive="100"
    maxIdle="10"
    maxWait="3000"
    />


    Code is:

    session = HibetnateUtil.currentSession();
    tx = sessison.beginTransaction();
    ....
    atta.setData( Hibernate.createBlob("temporary".getBytes()) );
    session.save(atta);
    session.flush();
    byte[] temp = atta.getBytes();
    session.refresh( atta, LockMode.UPGRADE );
    ( (oracle.sql.BLOB)atta.getData() ).putBytes(0,temp);
    tx.commit();
    session.flush();
    chomiq, Oct 20, 2005
    #1
    1. Advertising

  2. chomiq

    Adam Maass Guest

    "chomiq" <> wrote:
    >
    > How to put blob ( > 4k ) into Oracle9 using Hiberanete?
    >


    Please google before posting questions that have obvious answers at obvious
    places.

    To save you the effort:

    http://www.hibernate.org/56.html


    Now, a slightly longer answer:

    Oracle LOBs do not behave in the way that the authors of the SQL spec or the
    JDBC spec expect. Oracle, to their credit, does a decent job of documenting
    what you must do to make LOBs work in Oracle. Note that you will be spinning
    a lot of custom code just for Oracle to use Oracle LOB types.


    -- Adam Maass
    Adam Maass, Oct 21, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Vabo

    .NET and Oracle BLOB

    Robert Vabo, Aug 20, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    6,020
    Mark Kamoski
    Aug 27, 2003
  2. AZNewsh
    Replies:
    1
    Views:
    7,469
    bioscom
    Oct 15, 2009
  3. Roedy Green
    Replies:
    0
    Views:
    4,125
    Roedy Green
    Aug 23, 2003
  4. Michael Meyer

    oracle blob with weblogic 6.1

    Michael Meyer, Dec 16, 2003, in forum: Java
    Replies:
    0
    Views:
    472
    Michael Meyer
    Dec 16, 2003
  5. Feyruz
    Replies:
    4
    Views:
    2,131
    Sherm Pendley
    Oct 14, 2005
Loading...

Share This Page