Page 4 of 4 FirstFirst ... 234
Results 31 to 37 of 37

Thread: JdbcCursorInputSource and OutOfMemoryError

  1. #31

    Default email

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

  2. #32
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    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.

  3. #33
    Join Date
    Jun 2005
    Posts
    4,231

    Default

    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.

  4. #34
    Join Date
    May 2008
    Posts
    5

    Default

    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%.

  5. #35
    Join Date
    May 2008
    Posts
    5

    Default

    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:
    FORWARD_ONLY

    Should i file a bug report?

  6. #36
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    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.

  7. #37
    Join Date
    May 2008
    Posts
    5

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •