-->
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: ArrayIndexOutOfBoundsException in BatcherImpl
PostPosted: Tue Mar 23, 2004 4:23 pm 
Beginner
Beginner

Joined: Tue Mar 23, 2004 4:18 pm
Posts: 45
Hi!

I attempted to get the very simple sample code from http://www.onjava.com/pub/a/onjava/2004 ... rnate.html running in 2.1.2. Unfortunately when committing it throws an exception. I already contacted the author but he doesn't understand either.

Here's the stack trace:

21:14:23,379 INFO Environment:462 - Hibernate 2.1.2
21:14:23,393 INFO Environment:496 - loaded properties from resource hibernate.properties: {hibernate.connection.username=hibernate, hibernate.connection.password=hibernate, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.PostgreSQLDialect, hibernate.connection.url=jdbc:postgresql:hibernate, hibernate.connection.driver_class=org.postgresql.Driver}
21:14:23,428 INFO Environment:519 - using CGLIB reflection optimizer
21:14:23,496 INFO Configuration:329 - Mapping resource: test/hibernate/Product.hbm.xml
21:14:26,116 INFO Binder:229 - Mapping class: test.hibernate.Product -> products
21:14:26,515 INFO Configuration:595 - processing one-to-many association mappings
21:14:26,516 INFO Configuration:604 - processing one-to-one association property references
21:14:26,516 INFO Configuration:629 - processing foreign key constraints
21:14:26,617 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.PostgreSQLDialect
21:14:26,619 INFO SettingsFactory:62 - Use outer join fetching: true
21:14:26,681 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
21:14:26,682 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
21:14:26,727 INFO DriverManagerConnectionProvider:71 - using driver: org.postgresql.Driver at URL: jdbc:postgresql:hibernate
21:14:26,728 INFO DriverManagerConnectionProvider:72 - connection properties: {user=hibernate, password=hibernate}
21:14:26,738 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
21:14:27,381 INFO SettingsFactory:102 - Use scrollable result sets: true
21:14:27,382 INFO SettingsFactory:105 - Use JDBC3 getGeneratedKeys(): false
21:14:27,383 INFO SettingsFactory:108 - Optimize cache for minimal puts: false
21:14:27,383 INFO SettingsFactory:117 - Query language substitutions: {}
21:14:27,384 INFO SettingsFactory:128 - cache provider: net.sf.ehcache.hibernate.Provider
21:14:27,425 INFO Configuration:1080 - instantiating and configuring caches
21:14:28,116 INFO SessionFactoryImpl:119 - building session factory
21:14:32,251 INFO SessionFactoryObjectFactory:82 - no JNDI name configured
[Product] blah(null) price=123.0 amount=10
21:14:32,657 ERROR BatcherImpl:76 - 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:2385)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2335)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2204)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at test.InsertProduct.main(InsertProduct.java:34)
Exception in thread "main" 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:2385)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2335)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2204)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at test.InsertProduct.main(InsertProduct.java:34)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 24, 2004 7:02 am 
Beginner
Beginner

Joined: Tue Mar 23, 2004 4:18 pm
Posts: 45
Ok, maybe this will help:

DB schema as generated by SchemaExport:

create table products (
id char(32) not null,
name char(255) not null,
price double precision not null,
amount integer not null,
primary key (id)
)


The Java code:

// 1. Build a Product
Product p = new Product();
p.setName(args[0]);
p.setAmount(Integer.parseInt(args[1]));
p.setPrice(Double.parseDouble(args[2]));

// 2. Fire up Hibernate
Configuration cfg = new Configuration()
.addClass(Product.class);
SessionFactory sf = cfg.buildSessionFactory();

System.out.println(p);
// 3. Open Session
Session sess = sf.openSession();

// 4. Save Product and close Session
Transaction t = sess.beginTransaction();
sess.save(p);
t.commit();
sess.close();
System.out.println(p);



And finally the hibernate descriptor:

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

<hibernate-mapping>
<class name="test.hibernate.Product" table="products">

<!-- A 32 hex character is our surrogate key. It's automatically
generated by Hibernate with the UUID pattern. -->
<id name="id" type="string" unsaved-value="null" >
<column name="id" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>

<property name="name">
<column name="name" sql-type="char(255)" not-null="true"/>
</property>

<property name="price">
<column name="price" sql-type="double" not-null="true"/>
</property>

<property name="amount">
<column name="amount" sql-type="integer" not-null="true"/>
</property>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 25, 2004 9:45 am 
Beginner
Beginner

Joined: Tue Mar 23, 2004 4:18 pm
Posts: 45
...and I do have the same problem with the cat example from http://www.hibernate.org/hib_docs/refer ... tart.html; the generated SQL is correct. What's the problem?! Please help!

[java] 14:42:57,480 INFO [Environment] Hibernate 2.1.2
[java] 14:42:57,484 INFO [Environment] hibernate.properties not found
[java] 14:42:57,489 INFO [Environment] using CGLIB reflection optimizer
[java] 14:42:57,542 INFO [Configuration] configuring from url: http://localhost:8080/hibernate.cfg.xml
[java] 14:42:57,850 INFO [Configuration] Mapping resource: Cat.hbm.xml
[java] 14:42:58,095 INFO [Binder] Mapping class: f4t.Cat -> CAT
[java] 14:42:58,290 INFO [Configuration] Configured SessionFactory: null
[java] 14:42:58,296 INFO [Configuration] processing one-to-many association mappings
[java] 14:42:58,297 INFO [Configuration] processing one-to-one association property references
[java] 14:42:58,299 INFO [Configuration] processing foreign key constraints
[java] 14:42:58,475 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.PostgreSQLDialect
[java] 14:42:58,479 INFO [SettingsFactory] Use outer join fetching: true
[java] 14:42:58,492 INFO [NamingHelper] JNDI InitialContext properties:{}
[java] 14:42:58,501 INFO [DatasourceConnectionProvider] Using datasource: java:comp/env/jdbc/hibernate
[java] 14:42:58,549 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
[java] 14:42:58,822 INFO [SettingsFactory] Use scrollable result sets: true
[java] 14:42:58,824 INFO [SettingsFactory] Use JDBC3 getGeneratedKeys(): false
[java] 14:42:58,825 INFO [SettingsFactory] Optimize cache for minimal puts: false
[java] 14:42:58,827 INFO [SettingsFactory] echoing all SQL to stdout
[java] 14:42:58,829 INFO [SettingsFactory] Query language substitutions: {}
[java] 14:42:58,831 INFO [SettingsFactory] cache provider: net.sf.ehcache.hibernate.Provider
[java] 14:42:58,854 INFO [Configuration] instantiating and configuring caches
[java] 14:42:59,260 INFO [SessionFactoryImpl] building session factory
[java] 14:43:00,488 INFO [SessionFactoryObjectFactory] no JNDI name configured
[java] Hibernate: insert into CAT (NAME, sex, weight, CAT_ID) values (?, ?, ?, ?)
[java] 14:43:00,717 ERROR [BatcherImpl] Exception executing batch:
[java] java.lang.ArrayIndexOutOfBoundsException: 1
[java] at org.postgresql.core.QueryExecutor.sendQuery(QueryExecutor.java:143)
[java] at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:65)
[java] at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:451)
[java] at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:281)
[java] at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:48)
[java] at org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:179)
[java] at org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:165)
[java] at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:80)
[java] at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:54)
[java] at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:122)
[java] at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2385)
[java] at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2335)
[java] at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2204)
[java] at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
[java] at f4t.view.CommandAction.execute(CommandAction.java:72)
[java] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
[java] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
[java] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
[java] at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[java] at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:354)
[java] at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:342)
[java] at f4t.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:35)
[java] at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:334)
[java] at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:286)
[java] at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
[java] at org.mortbay.http.HttpContext.handle(HttpContext.java:1808)
[java] at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:525)
[java] at org.mortbay.http.HttpContext.handle(HttpContext.java:1758)
[java] at org.mortbay.jetty.plus.PlusWebAppContext.handle(PlusWebAppContext.java:126)
[java] at org.mortbay.http.HttpServer.service(HttpServer.java:879)
[java] at org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
[java] at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:952)
[java] at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
[java] at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:197)
[java] at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
[java] at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:501)
[java] 14:43:00,741 ERROR [CommandAction] java.lang.ArrayIndexOutOfBoundsException: 1
[java] 14:43:00,837 WARN [SessionImpl] afterTransactionCompletion() was never called
[java] 14:43:00,837 WARN [SessionImpl] unclosed connection


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 25, 2004 11:40 am 
Beginner
Beginner

Joined: Tue Mar 23, 2004 4:18 pm
Posts: 45
Obivously an postgres JDBC driver bug. Works with 7.4.1.


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.