-->
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.  [ 4 posts ] 
Author Message
 Post subject: Object is not mapped : java.lang.IndexOutOfBoundsException
PostPosted: Thu May 11, 2006 12:43 pm 
Beginner
Beginner

Joined: Thu Jul 22, 2004 8:09 am
Posts: 20
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping default-lazy="false">
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="com.xxx.bean.Associatedsample"
table="ASSOCIATEDSAMPLES"
dynamic-update="true"
dynamic-insert="true"
>

<meta attribute="implement-equals" inherit="false">true</meta>

<id
name="associatedsamplesid"
type="java.lang.Long"
column="ASSOCIATEDSAMPLESID"
>
<generator class="native">
<param name="sequence">ASSOCIATEDSAMPLESID_SEQ</param>
</generator>
</id>

<property
name="associatedsampleNumber"
type="java.lang.String"
column="ASSOCIATEDSAMPLE_NUMBER"
length="50"
/>
<property
name="defectStatus"
type="java.lang.String"
column="DEFECT_STATUS"
length="1"
/>

<!-- Associations -->


<!-- bi-directional many-to-one association to Sampleassociationcontext -->
<many-to-one
name="sampleassociationcontext"
class="com.xxx.bean.Sampleassociationcontext"
not-null="true"
>
<column name="SAMPLEASSOCIATIONCONTEXTID"/>
</many-to-one>

</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
String hqlUpdate = "update AssociatedSample set defectStatus = :defectStatus " +
" where datadeliverabletracking = :param2 and associatedsamplesid in (:param3)" ;

Transaction tx = null;
try {
Session session = getSession();
tx = session.beginTransaction();
Query qry = session.createQuery(hqlUpdate);

qry.setParameter("defectStatus", defectStatus);
qry.setParameter("param2", ddtId);

List results = new ArrayList();
for (int i = 0; i < sampleIds.length; i++) {
results.add(sampleIds[i]);
}
qry.setParameterList("param3", results);

qry.executeUpdate();
tx.commit();
} catch (HibernateException he) {
try {
tx.rollback();
} catch (HibernateException e) {
throw new RuntimeException(e.getMessage(), e);
}
throw new RuntimeException(he.getMessage(), he);
}

Full stack trace of any exception that occurs:
11:31:58,323 ERROR [PARSER] *** ERROR: AssociatedSample is not mapped.
11:34:56,826 ERROR [ExesExceptionHandler] java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at org.hibernate.hql.ast.HqlSqlWalker.postProcessUpdate(HqlSqlWalker.java:390)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:164)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:865)
at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:89)

Name and version of the database you are using:
Oracle 9

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Any help is appreciated.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 1:03 pm 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
If you are configuring SessionFactory from config file, check whether you have following element.

<mapping resource="AssociatedSample.hbm.xml"/>

If getSession() has implementation to configure programmatically check respective information is configured.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 1:21 pm 
Beginner
Beginner

Joined: Thu Jul 22, 2004 8:09 am
Posts: 20
I have it defined in the application context file where I configure the sessionfactory.

<value>hibernate/Associatedsample.hbm.xml</value>


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 1:50 pm 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
You should test if your SessionFactory is getting that file.

try this below code and verify if it contains com.xxx.bean.Associatedsample.

Code:
SessionFactory sf = session.getSessionFactory();
Map metadata = sf.getAllClassMetadata();
Iterator it = metadata.entrySet().iterator();
while ( it.hasNext() ) {
   Map.Entry entry = (Map.Entry) it.next();
   System.out.println("key = " + entry.getKey() + ", value = " + entry.getValue());
}


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