Hi there,
I am doing a simple Hibernate test, also using the Spring framework. The app is going to track members of a club.
I have mapped a single class (Member), and can retrieve results from the database that I have entered manually.
I unfortunately get a java.lang.ArrayOutOfBoundsException when I try to use the SaveOrUpdate() method. Previous posts have indicated that this is a mapping problem, but I can't find any. My mapping is posted below, and I am using the database schema and code generated by the hibernate tools.
Other info:
Hibernate version: 2.1
Database: postgres
App environment: Tomcat 5
The mapping and a debug trace from my log is below.
Any help is much appreciated.
Luke.
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="org.ems.db.model.Member" table="MEMBER">
<id name="id" column="MEMBER_ID" type="long" unsaved-value="null" >
<generator class="sequence">
<param name="sequence">MEMBER_SEQUENCE</param>
</generator>
</id>
<property name="login" column="LOGIN" type="string"/>
<property name="password" column="PASSWORD" type="string"/>
<property name="firstName" column="FIRST_NAME" type="string"/>
<property name="lastName" column="LAST_NAME" type="string"/>
<property name="email" column="EMAIL" type="string"/>
<property name="birthdate" column="BIRTHDATE" type="date"/>
</class>
</hibernate-mapping>
2004-06-08 21:32:19,855 DEBUG [org.springframework.orm.hibernate.SessionFactoryUtils] - Opening Hibernate session
2004-06-08 21:32:19,855 DEBUG [net.sf.hibernate.impl.SessionImpl] - opened session
2004-06-08 21:32:19,864 DEBUG [net.sf.hibernate.impl.SessionImpl] - saveOrUpdate() unsaved instance
2004-06-08 21:32:19,865 DEBUG [net.sf.hibernate.impl.BatcherImpl] - about to open: 0 open PreparedStatements, 0 open ResultSets
2004-06-08 21:32:19,865 INFO [org.springframework.jdbc.datasource.DriverManagerDataSource] - Creating new JDBC connection to [jdbc:postgresql://127.0.0.1:5432/ems]
2004-06-08 21:32:19,936 DEBUG [net.sf.hibernate.SQL] - select nextval ('MEMBER_SEQUENCE')
2004-06-08 21:32:19,936 DEBUG [net.sf.hibernate.impl.BatcherImpl] - preparing statement
2004-06-08 21:32:19,938 DEBUG [net.sf.hibernate.id.SequenceGenerator] - Sequence identifier generated: 6
2004-06-08 21:32:19,938 DEBUG [net.sf.hibernate.impl.BatcherImpl] - done closing: 0 open PreparedStatements, 0 open ResultSets
2004-06-08 21:32:19,938 DEBUG [net.sf.hibernate.impl.BatcherImpl] - closing statement
2004-06-08 21:32:19,938 DEBUG [net.sf.hibernate.impl.SessionImpl] - generated identifier: 6
2004-06-08 21:32:19,942 DEBUG [net.sf.hibernate.impl.SessionImpl] - saving [org.ems.db.model.Member#6]
2004-06-08 21:32:19,951 DEBUG [org.springframework.orm.hibernate.HibernateTemplate] - Eagerly flushing Hibernate session
2004-06-08 21:32:19,951 DEBUG [net.sf.hibernate.impl.SessionImpl] - flushing session
2004-06-08 21:32:19,954 DEBUG [net.sf.hibernate.impl.SessionImpl] - Flushing entities and processing referenced collections
2004-06-08 21:32:19,956 DEBUG [net.sf.hibernate.impl.SessionImpl] - Processing unreferenced collections
2004-06-08 21:32:19,956 DEBUG [net.sf.hibernate.impl.SessionImpl] - Scheduling collection removes/(re)creates/updates
2004-06-08 21:32:19,957 DEBUG [net.sf.hibernate.impl.SessionImpl] - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
2004-06-08 21:32:19,957 DEBUG [net.sf.hibernate.impl.SessionImpl] - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2004-06-08 21:32:19,957 DEBUG [net.sf.hibernate.impl.Printer] - listing entities:
2004-06-08 21:32:19,957 DEBUG [net.sf.hibernate.impl.Printer] - org.ems.db.model.Member{firstName=Abbie, id=6, lastName=Matthews} 2004-06-08 21:32:19,957 DEBUG [net.sf.hibernate.impl.SessionImpl] - executing flush
2004-06-08 21:32:19,957 DEBUG [net.sf.hibernate.persister.EntityPersister] - Inserting entity: [org.ems.db.model.Member#6]
2004-06-08 21:32:19,958 DEBUG [net.sf.hibernate.impl.BatcherImpl] - about to open: 0 open PreparedStatements, 0 open ResultSets
2004-06-08 21:32:19,958 DEBUG [net.sf.hibernate.SQL] - insert into MEMBER (FIRST_NAME, LAST_NAME, MEMBER_ID) values (?, ?, ?)
2004-06-08 21:32:19,958 DEBUG [net.sf.hibernate.impl.BatcherImpl] - preparing statement
2004-06-08 21:32:19,958 DEBUG [net.sf.hibernate.persister.EntityPersister] - Dehydrating entity: [org.ems.db.model.Member#6]
2004-06-08 21:32:19,958 DEBUG [net.sf.hibernate.type.StringType] - binding 'Abbie' to parameter: 1
2004-06-08 21:32:19,959 DEBUG [net.sf.hibernate.type.StringType] - binding 'Matthews' to parameter: 2
2004-06-08 21:32:19,959 DEBUG [net.sf.hibernate.type.LongType] - binding '6' to parameter: 3
2004-06-08 21:32:19,959 DEBUG [net.sf.hibernate.impl.BatcherImpl] - Adding to batch
2004-06-08 21:32:19,959 DEBUG [net.sf.hibernate.impl.BatcherImpl] - Executing batch size: 1
2004-06-08 21:32:19,965 ERROR [net.sf.hibernate.impl.BatcherImpl] - 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 net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:54)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:122)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2417)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2367)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
at org.springframework.orm.hibernate.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:202)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:151)
at org.springframework.orm.hibernate.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:257)
|