I've just set up my first little test program using the Event 'getting started' example as a reference. I'm scratching my head over a ArrayIndexOutOfBoundsException exception that is being thrown upon save.
I did find an earlier topic on this issue, but that seemed to involve a column that had been mapped multiple times and doesn't seem to apply here.
Environment: Win XP, Hibernate 3, JDK 1.5
The relevant mapping:
Code:
<?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>
<class name="beans.TitleBean" table="bddb_titles_hib">
<id name="id" column="id">
<generator class="native"/>
</id>
<property name="name" length="255" column="title_name"/>
<property name="category" length="31" column="title_categfory"/>
<property name="format" length="15" column="title_format"/>
<property name="transfer" length="15" column="title_transfer"/>
<property name="binder" column="title_binder"/>
<property name="page" column="title_page"/>
<property name="slot" column="title_slot"/>
<property name="pending" column="title_pending"/>
</class>
</hibernate-mapping>
The exception (with what I feel to be the relevant debug logging):
Code:
DEBUG - Inserting entity: [beans.TitleBean#1]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - insert into bddb_titles_hib (title_name, title_categfory, title_format, title_transfer, title_binder, title_page, title_slot, title_pending, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into bddb_titles_hib (title_name, title_categfory, title_format, title_transfer, title_binder, title_page, title_slot, title_pending, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
DEBUG - preparing statement
DEBUG - Dehydrating entity: [beans.TitleBean#1]
DEBUG - binding 'The Matrix' to parameter: 1
DEBUG - binding 'Movie' to parameter: 2
DEBUG - binding 'DVD-VIDEO' to parameter: 3
DEBUG - binding 'Digital' to parameter: 4
DEBUG - binding '1' to parameter: 5
DEBUG - binding '1' to parameter: 6
DEBUG - binding '1' to parameter: 7
DEBUG - binding 'false' to parameter: 8
DEBUG - binding '1' to parameter: 9
DEBUG - Adding to batch
DEBUG - Executing batch size: 1
ERROR - Exception executing batch:
java.lang.ArrayIndexOutOfBoundsException: 1
at org.postgresql.core.QueryExecutor.sendQuery(QueryExecutor.java:143)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:65)
at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:451)
at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:281)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:48)
at org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:179)
at org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:165)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:80)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:356)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at Main.createAndStoreTitle(Main.java:53)
at Main.main(Main.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - closing statement
And the calling code:
Code:
session.beginTransaction();
Title title = new TitleBean();
title.setName( "The Matrix" );
title.setCategory( "Movie" );
title.setFormat( "DVD-VIDEO" );
title.setTransfer( "Digital" );
title.setBinder( (short)1 );
title.setPage( (short)1 );
title.setSlot( (short)1 );
title.setPending( false );
session.save( title );
session.getTransaction().commit();
Is there something incredibly stupid that I'm doing? An obvious step that I missed?