-->
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.  [ 3 posts ] 
Author Message
 Post subject: ArrayIndexOutOfBoundsException when use mysql
PostPosted: Mon Sep 15, 2003 11:30 pm 
Newbie

Joined: Thu Sep 11, 2003 2:07 am
Posts: 4
I met a strange question.


I have two class:

----------------------------------------------------------------------------------

<class name="rr.Chassis" table="CHASSIS">

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

<!-- A cat has to have a name, but it shouldn' be too long. -->
<property name="ip">
<column name="IP" sql-type="varchar(16)" not-null="true"/>
</property>

<set name="serverBlades" cascade="all" inverse="true" lazy="true">
<key column="SERIAL_NUMBER"/>
<one-to-many class="rr.ServerBlade"/>
</set>

</class>

----------------------------------------------------------------------------------
<class name="rr.ServerBlade" table="SERVERBLADE">

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

<!-- A cat has to have a name, but it shouldn' be too long. -->
<property name="ip">
<column name="IP" sql-type="varchar(16)" not-null="true"/>
</property>

<property name="mac1"/>

<property name="mac2"/>

<property name="slot"/>

<many-to-one name="chassis" class="rr.Chassis" column="SERIAL_NUMBER"/>

</class>
----------------------------------------------------------------------------------

when i execute the following code:
sessionFactory = new Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
transaction = session.beginTransaction();

Chassis chassis = new Chassis();
chassis.setIp("10.3.1.125");
session.save(chassis);

ServerBlade sb = new ServerBlade();

sb.setChassis(chassis);
sb.setMac1("mac1");
sb.setMac2("mac2");
sb.setSlot("1");
sb.setIp("10.3.1.125");
session.save(sb);

transaction.commit(); // thrown ArrayIndexOutOfBoundsException
session.close();

-----------------------------------------------------------------------------------
The following error message occurs:

java.lang.ArrayIndexOutOfBoundsException: 5
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:1955)
at com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:1120)
at net.sf.hibernate.type.StringType.set(StringType.java:22)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:45)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:30)
at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:367)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:444)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:20)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2063)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2035)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:1979)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:56)
at com.threeup.phoenix.rr.AddChassis.endTransaction(AddChassis.java:91)
at com.threeup.phoenix.rr.AddChassis.performExecute(AddChassis.java:41)
at com.threeup.phoenix.action.PhoenixAction.execute(PhoenixAction.java:64)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:480)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1420)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:502)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)

-------------------------------------------------------------------------------
mysql version is 4.0.15-max-nt, JDBC driver is 3.0.8. hibernate version is
2.0.2


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 16, 2003 1:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You need to use insert="false" update="false" on repeated column mappings. The latest version of Hibernate will catch this for you.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 16, 2003 4:24 am 
Newbie

Joined: Mon Sep 15, 2003 2:47 am
Posts: 3
i m learing hibernate start ,but where modify this?
gavin wrote:
You need to use insert="false" update="false" on repeated column mappings. The latest version of Hibernate will catch this for you.


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