-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Getting a ArrayIndexOutOfBoundsException: -1 while iterating
PostPosted: Thu Jun 21, 2007 2:50 pm 
Newbie

Joined: Tue Jun 13, 2006 9:03 am
Posts: 18
I've created a hibernate query that returns a List. I can see the returned size of this list to be 100 items. When I try to iterate over this, I get the following exception:

java.lang.ArrayIndexOutOfBoundsException: -1


Not sure what the issue is here. Below is the snippet of my code:

Code:
session = sessionFactory.getCurrentSession();
Query query = session.createQuery("from Book book where "
   + "book.createTimestamp < :orderDate");
query.setDate("orderDate", orderDate);
query.setCacheMode(CacheMode.IGNORE);
List<Book> books = query.list();

for(Book book : books) {
  book......
}


I get the ArrayIndexOutOfBoundsException at the beginning of the for-loop. I checked that the returned List<Book> had the size of 100, so I know there are books in that List.

Any suggestions on how to troubleshoot and fix this? Thanks.

nefi


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 24, 2007 12:53 pm 
Newbie

Joined: Tue Jun 13, 2006 9:03 am
Posts: 18
I'm able to drill down this problem a little further. I think the ArrayIndexOutOfBounds issue has to do with the index column to designate the position of the record in the List semantic, i.e. @IndexColumn(name = "position", base = 1). I've just added this type of column in a few tables that already exist with data. The column is designated as not null, and hence all of the existing data has their values set to 0. Any new records added will either be 1 or greater. My gut tells me that this scenario may be causing the ArrayIndexOutOfBounds issue I'm getting, since the base = 1, and it grabs data with base = 0. When I changed to base = 0 in my annotations, I get the same issue regardless. Any further ideas on this? Thanks.

-nefi


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.