-->
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.  [ 5 posts ] 
Author Message
 Post subject: ArrayIndexOutOfBoundsException when setCacheable (true)
PostPosted: Fri May 18, 2007 1:44 am 
Newbie

Joined: Fri May 18, 2007 1:25 am
Posts: 7
Hibernate version: 3.2.1.ga

Code between sessionFactory.openSession() and session.close():

SQLQuery mySQLQuery = mySession.createSQLQuery (mySQL);
mySQLQuery.setCacheable (true);
mySQLquery.setCacheRegion (myRegion);

List myList = mySQLQuery.list ();


Full stack trace of any exception that occurs:

java.lang.ArrayIndexOutOfBoundsException: 0 at org.hibernate.type.TypeFactory.disassemble(TypeFactory.java:431) at
org.hibernate.cache.StandardQueryCache.put(StandardQueryCache.java:83)
...

Using ehcache.

When mySQLQuery.setCacheable (false), no error but obviously, does not use caching.

Does not matter what cache region - I get the same error with the default.

Any idea what is occuring?

_________________
Etienne


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 18, 2007 1:54 am 
Newbie

Joined: Fri May 18, 2007 1:25 am
Posts: 7
I looked at the code in Hibernate and it seems that it is trying to find the type of the result columns but since I did not set any -- expecting it to default all to objects -- it errors... That is the behavior with caching...

Is there a way to set the type (usually done with .setScalar ) without knowing what columns are there?

The scenario here is that the queries are defined externally and there is one method executing it - so I don't know what columns are there.

I really just want everything either as String or Object.

_________________
Etienne


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 18, 2007 7:45 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

try OScache. it is easy

Amila

(Don't forget to rating if this is helps)


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 18, 2007 12:26 pm 
Newbie

Joined: Fri May 18, 2007 1:25 am
Posts: 7
Thanks and I'll look at OSCache, can you tell me why you recommend this one over ehcache, what are the advantages?

However, concerning my problem, it is not the caching engine - it does not even get there... I found that it is because I don't set the "scalar" type - i.e., I don't tell Hibernate what columns I'm getting back and it errors because the "types" array in the TypesFactory is empty but it still try to access entries by index based on the columns returned by the query...

Really, that is a programming error since it is not required to set those values, the TypeFactory should not blindly try to read them.

This occurs only if setCacheable (true) is done.

_________________
Etienne


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 18, 2007 12:31 pm 
Beginner
Beginner

Joined: Fri May 18, 2007 10:28 am
Posts: 48
Location: Madison, WI
Why are you not setting the cache flag in HBM file. That will be more safer than manipulating it in your code.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.