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