Announcement Announcement Module
Collapse
No announcement yet.
Spring transaction with JPA and stored procedure Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring transaction with JPA and stored procedure

    HI,

    We are using jpa with spring transaction. (Oracle database)

    Within a transaction i am inserting record in one table(using jpa) then i am passing the id to stored procedure (spring storedprocedure handler). But inside the stored procedure, the data can't retrieved. because, no record exists with this id on that table.

    Note: Insertion is happening with jpa and stored procedure is being called using spring storedprocedure handler.

    Please guide me to go ahead. Anything i need to do with transactions and its configurations.

    Thanks in advance

  • #2
    From what you have described it seems like the insertion using JPA & select in SP are being done in different transactions. This is the reason data inserted by JPA is not visible in SP.

    Comment


    • #3
      Ya, But our implementation is that, after insertion of that table, we have the long process (need to check lots of table and some other table updation will be happened based on the insertions), at the same time, the insertion may happen from different modules. So, we are using procedure to do that long process to avoid the multiple database hits. (we don't want to use any triggers)

      Please suggest me if you have alternative .

      Thanks

      Comment


      • #4
        The only way to make this work is

        1.) Either both operations are done in same transaction (uncommitted data is visible only in same transaction, unless you are running the transaction with READ_UNCOMMITTED isolation level)
        2.) The JPA transaction that has inserted should have already committed its transaction before the SP goes & reterieves on ID

        If both JPA & SP are running in 2 seperate transactions then the JPA insert will not be visible to SP select.

        Comment


        • #5
          I have splited into to two different transactions (as 2nd approach)

          Thanks

          Comment

          Working...
          X