Announcement Announcement Module
Collapse
No announcement yet.
Fetch Limit Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fetch Limit

    All,

    Im using Hibernate and DB2 in my application.
    I want to fetch a set of records from a table and process it.
    How do i fetch with a fetch limit?
    This is my configuration

    <bean id="hibernateInputSource"
    class="org.springframework.batch.io.cursor.Hiberna teCursorInputSource"
    scope="step">
    <property name="queryString" value="from TempTable" />
    <property name="sessionFactory" ref="sessionFactory" />
    <aop:scoped-proxy />
    </bean>

  • #2
    HibernateCursorItemReader currently does not allow to set fetch size, but it could be added easily I think - feel free to start a jira.

    Btw. I see from the configuration you're using quite old (development) framework version - recommend to update.

    Comment


    • #3
      Thanks Robert.

      created JIRA jira.springframework.org/browse/BATCH-649

      One more doubt, how does the chunk operations work?
      Is that chunk size equivalent to fetch limit?
      Last edited by jayasimhan; Jun 3rd, 2008, 04:30 AM.

      Comment


      • #4
        You really should consider upgrading versions, as it is no longer necessary to work with RepeatOperations directly in the newer versions.

        Comment


        • #5
          Hi

          I've upgraded to new version.
          Now tell me how to set the fetch limit
          Here is my configuration

          <bean id="hibernateItemReader"
          class="org.springframework.batch.item.database.Hib ernateCursorItemReader">
          <property name="queryString" value="from TempTable" />
          <property name="sessionFactory" ref="sessionFactory" />
          </bean>

          Comment


          • #6
            I'm not sure quite how to do that with Hibernate. Does it have to be hardcoded when creating the cursor, or can it be configured for hibernate as a whole?

            Comment


            • #7
              I need something like this

              <bean id="hibernateItemReader"
              class="org.springframework.batch.item.database.Hib ernateCursorItemReader">
              <property name="queryString" value="from TempTable" />
              <property name="sessionFactory" ref="sessionFactory" />
              <property name="fetchLimit" value="100"/>
              </bean>


              so that if there are some 20000 records available in the table, my item reader should fetch 100 records in first set and 100 in the next til it reaches 20000.

              Comment


              • #8
                That would need to be added specifically to the ItemReader, can you create in issue in Jira?

                Comment


                • #9
                  Lucas,

                  Already created a jira

                  http://jira.springframework.org/browse/BATCH-649

                  Please let me know whether there are any other options to implement this?
                  Is that chunk operations behaving similar to this requirement?

                  Comment


                  • #10
                    I think we added fetch limit as a config option, so thanks for the suggestion. But I suspect you are expecting it to do something which it isn't going to do. It is only an optimsation hint for the JDBC driver. Is that what you needed? It's nothing to do with transactions or chunking, as far as I am aware.

                    Comment


                    • #11
                      Dave,

                      Fetch limit is something which i needed.
                      My assumption is the select query which we are configuring is fetching records one by one.
                      For a single read i need to fetch some 10 or 50 records. That is to execute a single step i need 10 rows to be fetched from a table.
                      Is this also possible?

                      Comment

                      Working...
                      X