Announcement Announcement Module
No announcement yet.
JdbcCursorInputSource and OutOfMemoryError Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31

    You can email them to nigel dot defreitas at gmail dot com.


    • #32
      It seems like there has to be some kind of setting in hibernate for this. With the jdbc version is changed the cursor to forward only from scroll sensitive. I'm assuming that hibernate must be using a scroll sensitive one as well. I'm not a hibernate expert, but it seems like there should be a way to control that.


      • #33
        You could also try using the normal DrivingQueryItemReader or JdbcCursorItemReader to grab the primary keys and use Hibernate in the Writer/Tranformer to load the object and do whatever is necessary in the context of a single commit interval.


        • #34
          Thanks for your answers, i will check if i can change the cursor to forward only.

          To avoid those problems in future I implemented a DrivingHibernateCursorReader. The example the iBatis implemention gave to me was quite easy to transfer to hibernate. I'am now using a SingleColumn KeyGenerator that gets all keys via a JdbcTemplate. Then i chunk those in my DrivingItemReader and read with a statement like this: "select from Table where id < n+1000 and id > n" the read object chunks are then transfered into a queue from which the read method then reads the elements. An implementation where i just read one object for a key at a time performed to slow. Is this a good way to implement it? The performance decrease compared to the Cursor implementation is approx. at 15-20%.


          • #35
            This is how the statement is executed in JdbcCursorReader:

            PHP Code:
            preparedStatement this.con.prepareStatement(sqlResultSet.TYPE_FORWARD_ONLYResultSet.CONCUR_READ_ONLYResultSet.HOLD_CURSORS_OVER_COMMIT); 
            This is how the cursor is opened in the HibernateReader:

            PHP Code:
            if (useStatelessSession) {
            statelessSession sessionFactory.openStatelessSession();
            cursor statelessSession.createQuery(queryString).scroll();
            } else {
            statefulSession sessionFactory.openSession();
            cursor statefulSession.createQuery(queryString).scroll();

            Maybe the Hibernate one should be opened by using this method

            org.hibernate.ScrollableResults scroll(org.hibernate.ScrollMode scrollMode) throws org.hibernate.HibernateException;

            with the following value:

            Should i file a bug report?


            • #36
              That looks like it would be correct, although I would want to do some testing with it to ensure rollbacks were handled correctly.

              Creating an issue with your full observations would be helpful.


              • #37
                Setting the cursor to FORWARD_ONLY does the trick. I will file a report.