Announcement Announcement Module
No announcement yet.
RdbmsOperation & synchronized compile() Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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.

    Artem Bilan

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

  • #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.