• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

java.sql.BatchUpdateException: ORA-02049

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone , i have a problem persisting to the database using jpa . I am getting this exception 11:32:09,508 ERROR [JDBCExceptionReporter] ORA-02049: timeout: transacci¾n distribuida esperando bloqueo

I have two entities with the following code:





The other entity is




This is where i persist





What i basically do here is :

1. populate and persist a Reintegro type object , so as to get a sequence number (idReintegro) from a sequence generator
2. find and persist other entities (No problem here)
3. Take the sequence obtained in step 1 (idReintegro) , assign it to aportePortafolioDos object (foreign key value)
4. Persist the aportePortafolioDos object


The thing is that once the persistence context is synchronized with the Oracle 11g database , it hangs for a few minutes and then throws the exception ORA-02049: , which indicates there is a lock . The lock occurs while trying to persist aportePortafolioDos on an insert statement.

If I disable the foreign key on the table mapped by AportePortafolioDos , everything works as expected . but if the foreign key is active then i get the deadlock.

I have been trying to find a solution for days , to no avail. Is there anything to do at all ? Please help!!!
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm no expert on ORM, so I'm just guessing based on what you wrote: did you index the foreign key? If you're deleting from a parent table (which I assume is happening when you persist), Oracle needs to lock entire child table if there is not an index on its foreign key.

Generally, foreign keys should always be indexed in Oracle. Only when you never delete from the parent table, you don't need the index on foreign key. And by "you delete from a table", I actually mean "your persistence framework deletes from a table".
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic