-->
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.  [ 1 post ] 
Author Message
 Post subject: Column(Collection) Updating error
PostPosted: Wed Aug 08, 2012 10:10 am 
Newbie

Joined: Wed Aug 08, 2012 10:04 am
Posts: 1
Hi there,
I meet a problem about Updating hibernate item(Collection). I use JPA. First, I want to create an int array as a column. But it seems using List is better. So I define a List<Integer> and I want to update the value of this column. But it doesn't work. Anyone can help?

It seems I make the binding parameter incorrect.

Here is the error info:
Code:
八月 08, 2012 3:13:10 下午 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 0, SQLState: 07001
八月 08, 2012 3:13:10 下午 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: No value specified for parameter 2
Updating Component - Platform Mapping failure
org.hibernate.exception.SQLGrammarException: No value specified for parameter 2
   at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:122)
   at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
   at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
   at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
   at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
   at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
   at $Proxy18.executeUpdate(Unknown Source)
   at org.hibernate.hql.internal.ast.exec.BasicExecutor.execute(BasicExecutor.java:95)
   at org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:413)
   at org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:282)
   at org.hibernate.internal.SessionImpl.executeUpdate(SessionImpl.java:1268)
   at org.hibernate.internal.QueryImpl.executeUpdate(QueryImpl.java:116)
   at com.forms.database.DBManager.updateMapping(DBManager.java:123)
   at com.forms.database.DBManager$updateMapping.call(Unknown Source)
   at com.forms.AHP.AHPManager.updateAHP(AHPManager.groovy:61)
   at com.forms.AHP.AHPManager$updateAHP.call(Unknown Source)
   at com.forms.launch.Run.main(Run.groovy:26)
Caused by: java.sql.SQLException: No value specified for parameter 2
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
   at com.mysql.jdbc.PreparedStatement.checkAllParametersSet(PreparedStatement.java:2595)
   at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2571)
   at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2418)
   at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2362)
   at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2347)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
   ... 12 more


Here is the Mapping class
Code:
@Entity
public class Components {

   ....
   private List<Integer> pltId;
   
   .....
   
   @ElementCollection
   @Column( name = "PLATFORM_ID" )
   public List<Integer> getPltId() {
      return pltId;
   }




Here is the updating code:
Code:
   public void updateMapping( int comId, List<Integer> pltId ) {
       
       try {       
 
         String hql = "update Components set pltId = :id1 where COMPONENTS_ID = :id2";
         
         Session session = HibernateUtil.getSessionFactory().openSession();
         session.beginTransaction();
         
         Query query = session.createQuery( hql ).setInteger( "id2", comId).setParameterList("id1", pltId);
         query.executeUpdate();
         
         session.getTransaction().commit();
......


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.