-->
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.  [ 8 posts ] 
Author Message
 Post subject: IndexOutOfBoundsException when querying
PostPosted: Wed May 12, 2004 7:21 am 
Regular
Regular

Joined: Wed Nov 26, 2003 6:22 am
Posts: 76
Location: Stockholm
Hi.

I'm using Hibernate 1.2.3, Spring framework 1.0.1, MySQL 4.xxx and Tomcat 4.1.27

I've been getting a java.lang.IndexOutOfBoundsException when executing a function inside a DAO.

A small part of the DEBUG-trace:

13:10:10,296 DEBUG BatcherImpl:241 - preparing statement
13:10:10,296 DEBUG BooleanType:46 - binding 'false' to parameter: 1
13:10:10,296 DEBUG Cascades:341 - id unsaved-value strategy NULL
13:10:10,296 DEBUG ClassType:46 - binding 'ks.rah.avik2.domain.Function' to parameter: 2
13:10:10,312 DEBUG SerializableType:46 - binding '2c6d8085f3f2808eeae1f6e1aeece1eee7aeccefeee7bb0b64104c0fa35f828081ca8
85f6e1ecf5e5f8f28090eae1f6e1aeece1eee7aecef5ede2e5f2062c159d8b14600b828080f8f08080808080808085' to parameter: 3

13:10:10,312 DEBUG BooleanType:46 - binding 'true' to parameter: 4
13:10:10,312 DEBUG JDBCTransaction:82 - rollback
13:10:10,312 DEBUG SessionImpl:572 - transaction completion
13:10:10,312 DEBUG JDBCTransaction:103 - re-enabling autocommit
13:10:10,312 DEBUG SessionImpl:560 - closing session
13:10:10,312 DEBUG SessionImpl:3327 - disconnecting session
13:10:10,328 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
13:10:10,328 DEBUG BatcherImpl:261 - closing statement
13:10:10,328 DEBUG SessionImpl:572 - transaction completion
13:10:10,328 ERROR DispatcherServlet:364 - Could not complete request
java.lang.ArrayIndexOutOfBoundsException: 3
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1955)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1977)
at com.mysql.jdbc.PreparedStatement.setBoolean(PreparedStatement.java:361)
at net.sf.hibernate.type.BooleanType.set(BooleanType.java:32)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)
at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:674)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:713)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:185)

The function:

public List findCommentedEvents(Function func) throws DataAccessException{

return getHibernateTemplate().find("from Event e where " +
"e.bossentryflg = ? "+
"and e.owner = ? and e.visible = ?",
new Object[]{new Boolean("true"), func, new Boolean("true")},
new Type[]{Hibernate.BOOLEAN, Hibernate.OBJECT, Hibernate.BOOLEAN});
}

Function mapping.

<hibernate-mapping>
<class
name="ks.rah.avik2.domain.Function"
table="function"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="id"
column="id"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="native">
</generator>
</id>

<property
name="description"
type="java.lang.String"
update="true"
insert="true"
column="funcdesc"
/>

<bag
name="functionnaires"
table="functionnaires"
lazy="false"
inverse="false"
cascade="save-update"
>

<key
column="func_fk"
/>

<composite-element
class="ks.rah.avik2.domain.support.UserFunctionNode"
>

<many-to-one
name="user"
class="ks.rah.avik2.domain.AvikUser"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
column="user_fk"
/>

<property
name="from"
type="date"
update="true"
insert="true"
column="fromdate"
/>

<property
name="until"
type="date"
update="true"
insert="true"
column="todate"
/>

<property
name="current"
type="boolean"
update="true"
insert="true"
column="iscurrent"
/>

</composite-element>

</bag>

<property
name="active"
type="boolean"
update="true"
insert="true"
column="active"
/>

</class>

</hibernate-mapping>

Any ideas why I get the funny 3:rd argument in the bind trace?

Sincerely,

/Cantor


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 12, 2004 8:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Use Hibernate.entity(Function.class) instead of Hibernate.OBJECT


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 12, 2004 10:20 am 
Regular
Regular

Joined: Wed Nov 26, 2003 6:22 am
Posts: 76
Location: Stockholm
OK.

Resulted in:

net.sf.hibernate.type.SerializationException: could not deserialize
at net.sf.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:197)
at net.sf.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:220)
at net.sf.hibernate.type.SerializableType.fromBytes(SerializableType.java:73)
at net.sf.hibernate.type.SerializableType.get(SerializableType.java:38)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:66)
at net.sf.hibernate.type.ComponentType.hydrate(ComponentType.java:386)
at net.sf.hibernate.loader.Loader.hydrate(Loader.java:611)
at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:552)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:511)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:426)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:209)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1536)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)

etc.etc..
Any idea what's causing this?

/C


Top
 Profile  
 
 Post subject: Contd...
PostPosted: Wed May 12, 2004 11:19 am 
Regular
Regular

Joined: Wed Nov 26, 2003 6:22 am
Posts: 76
Location: Stockholm
Further down the stack trace:

Caused by: java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2165)
at java.io.ObjectInputStream$BlockDataInputStream.readUTFBody(ObjectInputStream.java:2900)
at java.io.ObjectInputStream$BlockDataInputStream.readUTF(ObjectInputStream.java:2701)
at java.io.ObjectInputStream.readUTF(ObjectInputStream.java:999)
at java.io.ObjectStreamClass.readNonProxy(ObjectStreamClass.java:515)
at java.io.ObjectInputStream.readClassDescriptor(ObjectInputStream.java:762)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1503)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at net.sf.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:190)
... 74 more


Top
 Profile  
 
 Post subject: Lyrics
PostPosted: Wed May 12, 2004 12:51 pm 
Regular
Regular

Joined: Wed Nov 26, 2003 6:22 am
Posts: 76
Location: Stockholm
Aaaand...

Seems that

public List findReportedEvents(Function func) throws DataAccessException{

return getHibernateTemplate().find("from Event e where " +
"e.bossentryflg = ? " +
"and e.owner = ? and e.visible = ?",
new Object[]{new Boolean("false"), func, new Boolean("true")},
new Type[]{Hibernate.BOOLEAN, Hibernate.entity(Function.class), Hibernate.BOOLEAN});
}

whilst

public List findReportedEvents(Function func) throws DataAccessException{

return getHibernateTemplate().find("from Event e where " +
"e.bossentryflg = ? " +
"and e.owner = ? and e.visible = ?",
new Object[]{new Boolean("false"), func, new Boolean("true")},
new Type[]{Hibernate.TRUE_FALSE, Hibernate.entity(Function.class), Hibernate.TRUE_FALSE});
}

works perfectly fine.

T quote "Penny Lane" by The Beatles:

'Very strange.'

Sincerely,

/C


Top
 Profile  
 
 Post subject: Monologue
PostPosted: Thu May 13, 2004 4:32 am 
Regular
Regular

Joined: Wed Nov 26, 2003 6:22 am
Posts: 76
Location: Stockholm
"O-bla-di, o-bla-da, life goes on....bra?" ("bra" means "good" in Swedish;)

Seems it is not working after all. The

new Type[]{Hibernate.TRUE_FALSE, Hibernate.entity(Function.class), Hibernate.TRUE_FALSE});

clause does not retrieve any object though they're there.

If changed to

new Type[]{Hibernate.BOOLEAN, Hibernate.entity(Function.class), Hibernate.BOOLEAN});

it causes this....all the time:


[junit] org.springframework.orm.hibernate.HibernateSystemException: could not deserialize; nested exception is net.s
ibernate.type.SerializationException: could not deserialize
[junit] net.sf.hibernate.type.SerializationException: could not deserialize
[junit] at net.sf.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:197)
[junit] at net.sf.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:220)
[junit] at net.sf.hibernate.type.SerializableType.fromBytes(SerializableType.java:73)
[junit] at net.sf.hibernate.type.SerializableType.get(SerializableType.java:38)
[junit] at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
[junit] at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
[junit] at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:66)
[junit] at net.sf.hibernate.type.ComponentType.hydrate(ComponentType.java:386)
[junit] at net.sf.hibernate.loader.Loader.hydrate(Loader.java:611)
[junit] at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:552)
[junit] at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:511)
[junit] at net.sf.hibernate.loader.Loader.getRow(Loader.java:426)
[junit] at net.sf.hibernate.loader.Loader.doQuery(Loader.java:209)
[junit] at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
[junit] at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
[junit] at net.sf.hibernate.loader.Loader.list(Loader.java:946)
[junit] at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
[junit] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1536)
[junit] at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
[junit] at org.springframework.orm.hibernate.HibernateTemplate$21.doInHibernate(HibernateTemplate.java:382)
[junit] at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:150)
[junit] at org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:170)
[junit] at org.springframework.orm.hibernate.HibernateTemplate.find(HibernateTemplate.java:375)
[junit] at ks.rah.avik2.dao.impl.hibernate.EventDaoImpl.findReportedEvents(EventDaoImpl.java:74)
[junit] at ks.rah.avik2.logic.LogicFacadeImpl.findReportedEvents(LogicFacadeImpl.java:235)
[junit] at ks.rah.avik2.test.TestEventDao.testFindReportedEvents(TestEventDao.java:66)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] Caused by: java.io.EOFException
[junit] at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2165)
[junit] at java.io.ObjectInputStream$BlockDataInputStream.readUTFBody(ObjectInputStream.java:2900)
[junit] at java.io.ObjectInputStream$BlockDataInputStream.readUTF(ObjectInputStream.java:2701)
[junit] at java.io.ObjectInputStream.readUTF(ObjectInputStream.java:999)
[junit] at java.io.ObjectStreamClass.readNonProxy(ObjectStreamClass.java:515)
[junit] at java.io.ObjectInputStream.readClassDescriptor(ObjectInputStream.java:762)
[junit] at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1503)
[junit] at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
[junit] at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)
[junit] at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
[junit] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
[junit] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
[junit] at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
[junit] at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
[junit] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
[junit] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
[junit] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
[junit] at net.sf.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:190)
[junit] ... 51 more

I believe the main cause is Hibernate related.

Can anyone tell me what's generally cuasing this SerializationException?

Here's the (rather lengthy) mapping for the Event class:

<hibernate-mapping>
<class
name="ks.rah.avik2.domain.Event"
table="event"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="id"
column="id"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="native">
</generator>
</id>

<property
name="type"
type="ks.rah.avik2.domain.support.EventTypeType"
update="true"
insert="true"
column="eventtype"
/>

<property
name="status"
type="ks.rah.avik2.domain.support.EventStatusType"
update="true"
insert="true"
column="eventstatus"
/>

<property
name="createdDate"
type="date"
update="true"
insert="true"
column="created"
/>

<property
name="changedDate"
type="date"
update="true"
insert="true"
column="changed"
/>

<property
name="visible"
type="boolean"
update="true"
insert="true"
column="eventvisible"
/>

<property
name="diaryNumber"
type="java.lang.String"
update="true"
insert="true"
column="diarynb"
/>

<property
name="eventDate"
type="date"
update="true"
insert="true"
column="evdate"
/>

<property
name="eventTime"
type="time"
update="true"
insert="true"
column="evtime"
/>

<many-to-one
name="eventDept"
class="ks.rah.avik2.domain.Department"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="evdept"
/>

<many-to-one
name="eventLocation"
class="ks.rah.avik2.domain.Location"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="evloc"
/>

<property
name="eventDetails"
type="java.lang.String"
update="true"
insert="true"
column="evdet"
/>

<property
name="discovDate"
type="date"
update="true"
insert="true"
column="discdate"
/>

<property
name="discovTime"
type="time"
update="true"
insert="true"
column="disctime"
/>

<many-to-one
name="discovDept"
class="ks.rah.avik2.domain.Department"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="discdept"
/>

<many-to-one
name="discovLocation"
class="ks.rah.avik2.domain.Location"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="discloc"
/>

<property
name="discovDetails"
type="java.lang.String"
update="true"
insert="true"
column="discdet"
/>

<component
name="reporter"
class="ks.rah.avik2.domain.support.Reporter"
>
<property
name="dept"
type="ks.rah.avik2.domain.Department"
update="true"
insert="true"
column="repdept"
/>

<many-to-one
name="pos"
class="ks.rah.avik2.domain.Position"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="reppos"
/>

<property
name="name"
type="java.lang.String"
update="true"
insert="true"
column="repname"
/>

<property
name="reportdate"
type="date"
update="true"
insert="true"
column="repdate"
/>

</component>

<many-to-one
name="owner"
class="ks.rah.avik2.domain.Function"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
column="owner"
/>

<component
name="patient"
class="ks.rah.avik2.domain.support.Patient"
>
<property
name="patName"
type="java.lang.String"
update="true"
insert="true"
column="patname"
/>

<property
name="pernr"
type="java.lang.String"
update="true"
insert="true"
column="patnr"
/>

<property
name="informed"
type="boolean"
update="true"
insert="true"
column="patinfo"
/>

<property
name="comment"
type="text"
update="true"
insert="true"
column="patcomment"
/>

</component>

<property
name="bossentryflg"
type="boolean"
update="true"
insert="true"
column="bossentry"
/>

<property
name="bossreportdate"
type="date"
update="true"
insert="true"
column="bossdate"
/>

<property
name="eventDescr"
type="text"
update="true"
insert="true"
column="ev_descr"
/>

<property
name="whyComment"
type="text"
update="true"
insert="true"
column="ev_why"
/>

<property
name="conseqComment"
type="text"
update="true"
insert="true"
column="ev_conseq"
/>

<property
name="preventComment"
type="text"
update="true"
insert="true"
column="ev_prevent"
/>

<bag
name="entries"
table="optionentries"
lazy="false"
inverse="false"
cascade="save-update"
>

<key
column="event_fk"
/>

<composite-element
class="ks.rah.avik2.domain.support.EventFieldOptionNode"
>

<many-to-one
name="field"
class="ks.rah.avik2.domain.ui.PageField"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="field_fk"
/>

<many-to-one
name="option"
class="ks.rah.avik2.domain.ui.FieldOption"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="option_fk"
/>

<property
name="created"
type="java.util.Date"
update="true"
insert="true"
column="created"
/>

<many-to-one
name="creator"
class="ks.rah.avik2.domain.AvikUser"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="user_fk"
/>

</composite-element>

</bag>

<set
name="textEntries"
lazy="false"
inverse="true"
cascade="none"
sort="unsorted"
>

<key
column="event_fk"
/>

<one-to-many
class="ks.rah.avik2.domain.support.TextEntry"
/>
</set>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Event.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


/C


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 13, 2004 6:00 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Quote:
<property
name="dept"
type="ks.rah.avik2.domain.Department"
update="true"
insert="true"
column="repdept"
/>


are you sure this should not be
type="ks.rah.avik2.domain.DepartmentTpye" or an association mapping or something. Anyways, the error is somewhere in your type declarations, Hibernate is trying to fall back to the default "Serializable" type for one of the properties.


Top
 Profile  
 
 Post subject: Thnx
PostPosted: Thu May 13, 2004 6:29 am 
Regular
Regular

Joined: Wed Nov 26, 2003 6:22 am
Posts: 76
Location: Stockholm
That was it.

Thank you ever so much!

/C


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