Announcement Announcement Module
Collapse
No announcement yet.
RdbmsOperation & synchronized compile() Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • RdbmsOperation & synchronized compile()

    Hello, Spring Team!

    I've got such scenario:

    1. I don't want compile() my StoredProcedure objects on context initialization in super.afterPropertiesSet() for some reason of my project architecture.
    2. So, they will be compiled on first call of execute(...)
    3. In my case one Procedure is called from async tasklet in spring-batch job
    4. And several thraeds call RdbmsOperation.compile() concurrently.
    5. And in the end I've got some confused problems in SqlCall.callString property like this:

    Compiled stored procedure. Call string is [{call MY_PROCEDURE(?, ?, , , , ?, ?, , ?, , , ?, ?, ?, ?, ?, ?)}]
    So, I propose to make RdbmsOperation.compile() synchronized for preventing concurrent read/write of properties of SqlCall instances.

    Thanks,
    Artem Bilan

    P.S. My workaround is (code in Groovy):
    Code:
    class MyStoredProcedure extends StoredProcedure {
    
        @Override
        protected void checkCompiled() {
            if (!compiled) {
                synchronized (this) {
                    compile()
                }
            }
        }
    }

  • #2
    Why no one replied to this yet? It seems quite interesting problem, which I think I'll also have.

    I add that this compile should in fact be synchronized and should not be invoked by RdbmsOperation on afterPropertiesSet as, at least in StoredProcedure case, it is not necessary, unexpected and not documented. At least StoredProcedure could override afterPropertiesSet and not call compile.

    Comment

    Working...
    X