-->
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: sql-insert Invalid argument: parameter index is out of range
PostPosted: Wed Apr 21, 2010 5:06 pm 
Newbie

Joined: Tue Apr 20, 2010 4:01 pm
Posts: 2
Location: Omaha, NE
I'm trying to write a custom insert statement with the <sql-insert> statement. I get the following error. What I'm trying to do is use the database to generate a timestamp that has the precision of nanoseconds. I can't use the <timestamp source="db"> attribute because it throws a SQL error when it tries to run "VALUES current timestamp". Any suggestions on how I can get this to work?

How does hibernate know what values to insert into the ?'s or your query?

Code:

main 2010-04-21 15:53:40,597 DEBUG en.hibernate.util.HibernateDAO attaching clean class com.data.RecentActivityPersist instance
Hibernate: INSERT INTO ACTV_LOG ( PACL_ID_TS, PACL_TGT_PG_ID_TS, PACL_TYPE_CD, PACL_STATUS, PACL_USER_ID, PACL_SCNTRCT_ID, PACL_POL_ID, PACL_ACTV_REQ_TS, PACL_CONTENT) VALUES (CURRENT_TIMESTAMP, ?, ?, ?, ?, ?, ?, ?, ?)
Apr 21, 2010 3:53:40 PM org.hibernate.type.NullableType nullSafeSet
INFO: could not bind value '1111-11-11 10:11:11' to parameter: 9; Invalid argument: parameter index 9 is out of range.
Apr 21, 2010 3:53:40 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: -99999, SQLState: null
Apr 21, 2010 3:53:40 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Invalid argument: parameter index 9 is out of range.
Apr 21, 2010 3:53:40 PM org.hibernate.event.def.AbstractFlushingEventListener performExecutions
SEVERE: Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not insert: [com.data.RecentActivityPersist]
   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2267)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
   at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
   at



Mapping:
Code:
<hibernate-mapping>
    <class name="com.data.RecentActivityPersist" table="ACTV_LOG"
    >
        <comment>ACTIVITY LOG</comment>
        <id name="activityForeignKey" type="timestamp" >
            <column name="PACL_ACTV_REQ_TS" length="26" not-null="true" >
                <comment>DATA AND TIME OF ACTIVITY REQUEST</comment>
            </column>
            
         </id>
         
       <property name="tsUnique"  type="timestamp"  >
            <column name="PACL_ID_TS"></column>
            
         </property>
        <property name="targetPages" type="timestamp">
            <column name="PACL_TGT_PG_ID_TS" length="26">
                <comment>RECORD ID - TIMESTAMP</comment>
            </column>
        </property>
     
        <property name="recentActivityType" type="com.woodmen.hibernate.types.NullToZeroDecimal">
            <column name="PACL_TYPE_CD" not-null="true">
                <comment>ACTIVITY TYPE CODE</comment>
            </column>
        </property>
        <property name="activityStatus" type="string">
            <column name="PACL_STATUS" length="15" not-null="true">
                <comment>STATUS OF ACTIVITY</comment>
            </column>
        </property>
        <property name="userIdPrefix" type="string">
            <column name="PACL_USER_ID" length="8" not-null="true">
                <comment>USER ID</comment>
            </column>
        </property>
        <property name="subcontractorSuffix" type="com.woodmen.hibernate.types.NullToZeroDecimal">
            <column name="PACL_SCNTRCT_ID" length="3" not-null="false">
                <comment>SUBCONTRACTOR SUFFIX OF REQUESTOR</comment>
            </column>
        </property>
        <property name="certificateNumber" type="string">
            <column name="PACL_POL_ID" length="10" not-null="true">
                <comment>POLICY ID</comment>
            </column>
        </property>
       
        <property name="activityDetailContent" type="string">
            <column name="PACL_CONTENT" length="1000" not-null="true">
                <comment>STORE THE CONTENTS OF THE HTTP DATA BEING SENT WITH THE INTERCEPTED MESSAGE</comment>
            </column>
        </property>
     
       <sql-insert >INSERT INTO ACTV_LOG ( PACL_ID_TS, PACL_TGT_PG_ID_TS, PACL_TYPE_CD, PACL_STATUS, PACL_USER_ID, PACL_SCNTRCT_ID, PACL_POL_ID, PACL_ACTV_REQ_TS, PACL_CONTENT)
               VALUES (CURRENT_TIMESTAMP, ?, ?, ?, ?, ?, ?, ?, ?)
            
      </sql-insert>
    </class>
</hibernate-mapping>




java object:

Code:
package com.recentactivity.data;

import java.sql.Timestamp;
import java.util.Calendar;
import com.data.BaseTransferObject;
import com.data.Name;

public class RecentActivityPersist extends BaseTransferObject {
   
   private static final long serialVersionUID = 6571940759119127415L;
   private Timestamp tsUnique;
   private Timestamp targetPages;
   private Integer recentActivityType;
   private String activityStatus;
   private String userId = null; // No longer mapped in Hibernate. Use userIdPrefix and subcontractorSuffix for persistence
   private String userIdPrefix = null;
   private Integer subcontractorSuffix = null;
   private String certificateNumber;
   private Timestamp activityForeignKey;
   private String activityDetailContent;
   private Name insuredsName;
   private String shortDisplayDate;
   
   
   
   public String getActivityDetailContent() {
      return activityDetailContent;
   }
   public void setActivityDetailContent(String activityDetailContent) {
      this.activityDetailContent = activityDetailContent;
   }
   
   public String getCertificateNumber() {
      return certificateNumber;
   }
   public void setCertificateNumber(String certificateNumber) {
      this.certificateNumber = certificateNumber;
   }
   
   public Name getInsuredsName() {
      return insuredsName;
   }
   public void setInsuredsName(Name insuredsName) {
      this.insuredsName = insuredsName;
   }
   
   public String getShortDisplayDate() {
      return shortDisplayDate;
   }
   public void setShortDisplayDate(String shortDisplayDate) {
      this.shortDisplayDate = shortDisplayDate;
   }
   public Integer getSubcontractorSuffix() {
      return subcontractorSuffix;
   }
   public void setSubcontractorSuffix(Integer subcontractorSuffix) {
      this.subcontractorSuffix = subcontractorSuffix;
   }
   
   public Integer getRecentActivityType() {
      return recentActivityType;
   }
   public void setRecentActivityType(Integer recentActivityType) {
      this.recentActivityType = recentActivityType;
   }
   
   public Timestamp getActivityForeignKey() {
      return activityForeignKey;
   }
   public void setActivityForeignKey(Timestamp activityForeignKey) {
      this.activityForeignKey = activityForeignKey;
   }
   public Timestamp getTargetPages() {
      return targetPages;
   }
   public void setTargetPages(Timestamp targetPages) {
      this.targetPages = targetPages;
   }
   public String getUserId() {
      return userId;
   }
   public void setUserId(String userId) {
      this.userId = userId;
   }
   public String getUserIdPrefix() {
      return userIdPrefix;
   }
   public void setUserIdPrefix(String userIdPrefix) {
      this.userIdPrefix = userIdPrefix;
   }
   public String getActivityStatus() {
      return activityStatus;
   }
   public void setActivityStatus(String activityStatus) {
      this.activityStatus = activityStatus;
   }
   public Timestamp getTsUnique() {
      return tsUnique;
   }
   public void setTsUnique(Timestamp tsUnique) {
      this.tsUnique = tsUnique;
   }
   
}


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.