Announcement Announcement Module
Collapse
No announcement yet.
Unable to Query the Table Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to Query the Table

    Hi All,
    I am trying a small sample,

    My Job.xml is

    <code>

    <job id="Batch_ControllerJob" restartable="true"
    xmlns="http://www.springframework.org/schema/batch">

    <step id="TestWithIdentity">
    <tasklet ref="testWithIdentity" />
    </job>

    <bean id="testWithIdentity"
    class="batch.core.tasklet.TestWithIdentity">
    <property name="batchDao">
    <ref bean="batchDao" />
    </property>
    </bean>

    </code>

    BatchRun.hbm :

    <code>

    <hibernate-mapping>
    <class name="commoncomponent.domain.BatchRunDo"
    table="BatchRun">
    <id name="runNumber" type="long" column="runId">
    <generator class="identity" />
    </id>
    <property name="runType">
    <column name="runType" />
    </property>
    </class>
    </hibernate-mapping>
    </code>

    In the TestWithIdentity classs, I am recording BatchRunDo object to the database. BatchRunDo have an identity column. When i reach the
    Session.saveOrUpdate(BatchRunDo), I am unable to query the BatchRun table.
    Once my step is completed, then i am able to query the table.
    This is not happening for the table, which doesn't contain identity column.

    [I am Using Hibernate3.jar and got the Session from the sessionFactoryUtils.]

    Any Table level locking is happenning?
    can u please clarify this?

  • #2
    When Session.saveOrUpdate(BatchRunDo) is issued, the transaction is not committed. It happens after a complete chunk is processed. Perhaps that is the reason of your lock (and it fits your story, that you can query the DB after the step is completed). If I misunderstood your problem, give us a log which contains only entries for the following classes:
    • org.springframework.orm.hibernate3.LocalSessionFac toryBean
    • org.springframework.orm.hibernate3.HibernateTransa ctionManager
    • org.hibernate.id.IdentifierGeneratorHelper
    • org.hibernate.transaction.JDBCTransaction
    Perhaps you will get the answer when looking at log sequence...

    Comment


    • #3
      Thanks for your prompt reply.

      I am attaching the logs mentioned.

      But, what still disturbs me is the fact that this issue occurs only in case of Mapping with identity column. It is perfectly fine with the other generators (like assigned, increment..).

      Comment


      • #4
        Originally posted by arun4 View Post
        I am attaching the logs mentioned.
        arun4, I've tried to analyse the logs and failed: I was a bit stupid when suggested to filter by above mentioned list of classes, because Spring Batch also writes the information, and I can't separate who is doing what. Perhaps attaching the full log (DEBUG level, no filters) will bring some light.

        Also for your batch configuration you are using batch.core.tasklet.TestWithIdentity, which I believe is in-house developed (I first thought it is a part of String Batch core, but I was wrong). I suppose you had a strong reason to implement it, however I assume you can use the standard tasklet. Perhaps you can reconfigure your application, so it uses the standard approach, e.g. if you need to save some business information (use new transaction via TransactionTemplate), why not to do it in ChunkListener.afterChunk()? Right now I see only the top of the iceberg, but if you use the standard approaches (reader / processor / writer), it would be easier to diagnose the problem.

        But, what still disturbs me is the fact that this issue occurs only in case of Mapping with identity column. It is perfectly fine with the other generators (like assigned, increment..).
        I think, we need to look for other possible pitfalls, not concentrating on one.

        Comment

        Working...
        X