CMP entity bean to set a BLOB field

Discussions

EJB programming & troubleshooting: CMP entity bean to set a BLOB field

  1. CMP entity bean to set a BLOB field (4 messages)

    I used a CMP entity bean to manipulate a Oracle table with a BLOB column: content. But when I call setContent(bytes) in my client call, I got the following exception:
    java.io.IOException: ORA-22920: row containing the LOB value is not locked
    ORA-06512: at "SYS.DBMS_LOB", line 700

    Can any help me to fix this problem?

    Thanks in advance!

    Hong Jia

  2. You most likely need to tell your application server that you are dealing with blobs. This is application server specific... what app server are you using?

    Daniel.
  3. Thanks Daniel. I am using WebLogic4.1sp2 as my aplication server. I did specify the blob type in the deploy descript file: weblogic-cmp-rdbms-jar.xml with the following nodes:

        <field-map>
          <cmp-field>content</cmp-field>
          <dbms-column>content</dbms-column>
          <dbms-column-type>OracleBlob</dbms-column-type>
        </field-map>

    Acturally the error message is pretty clear, that the row needs to be locked. My question is how do achieve this in CMP entity bean?
  4. Sorry, a typo in my reply. Server should be WLS6.1sp2
  5. Ok, your WLS version is OK.

    You will need to add this into the weblogic-ejb-jar.xml (add it just before the </weblogic-ejb-jar> tag).

    <transaction-isolation>
      <isolation-level>TRANSACTION_READ_COMMITTED_FOR_UPDATE</isolation-level>
      <method>
    <ejb-name>**YourEJBName**</ejb-name>
    <method-name>**YourSetMethodForBlob**</method-name>
      </method>
    </transaction-isolation>

    Where **YourEJBName** should be the name of your ejb as set in the xml, and **YourSetMethodForBlob** should be "setContent".

    One more warning: Weblobic 6.1 has what I think is a bug in dealing with BLOBS. It can only store serialised objects. This is O.K. while you are only using java to access the DB, but if you try to access the same BLOB column with both java and something else, it isn't going to work. Hopefully they'll fix this some time.

    Hope that helps,

    Daniel.