-->
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: Could not execute JDBC batch update
PostPosted: Mon Dec 12, 2005 10:49 pm 
Regular
Regular

Joined: Tue Nov 04, 2003 12:37 pm
Posts: 57
Hello,

When I use BLOB in Hibernate3.1, it just raised the following exception.


Hibernate3.1-rc2, Hibernate-Annotation-beta6
MySQL 5.




Code:
2005-12-13 10:24:22 org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 0, SQLState: 01004
2005-12-13 10:24:22 org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Data truncation: Data too long for column 'data' at row 1
2005-12-13 10:24:22 org.hibernate.event.def.AbstractFlushingEventListener performExecutions
SEVERE: Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:200)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:877)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:345)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
   at mo.eric.sinoalbum.servlet.SinoAlbumFilter.doFilter(SinoAlbumFilter.java:100)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.BatchUpdateException: Data truncation: Data too long for column 'data' at row 1
   at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
   at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:193)
   ... 22 more



Code:
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob;
import javax.persistence.LobType;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

import mo.eric.sinoalbum.util.DateTimeUtil;

import org.hibernate.validator.NotNull;

/**
* AbstractBasePhoto.java
*
* @author Chao Hoi Ka, Eric (HKC)
*
*/
@Entity
@Table (name = "PHOTO")
@NamedQueries ( {
      @NamedQuery (name = "photo.findAll", queryString = "select p from Photo p"),
      @NamedQuery (name = "photo.findByName", queryString = "select p from Photo p where p.name = :name"),
      @NamedQuery (name = "photo.findByCategory", queryString = "select p from Photo p where p.category = :category"),
      @NamedQuery (name = "photo.findByLocation", queryString = "select p from Photo p where p.location = :location"),
      @NamedQuery (name = "photo.findByDate", queryString = "select p from Photo p where p.photoDate between :date1 and :date2")
})
public class Photo extends AbstractBaseObject {

   public static final long serialVersionUID = 1L;

   protected Category category;

   protected String location;

   protected String events;

   protected Date photoDate;

   protected String description;

   protected byte[] data;

   protected User updater;

   protected User creator;

   /**
    *
    */
   public Photo() {
      super();
   }

   /**
    * @return Returns the category.
    */
   @ManyToOne (cascade = {
      CascadeType.ALL
   }, fetch = FetchType.LAZY)
   @JoinColumns ( {
      @JoinColumn (name = "CATEGORY_ID")
   })
   @NotNull
   public Category getCategory() {
      return this.category;
   }

   /**
    * @param category
    *           The category to set.
    */
   public void setCategory(Category category) {
      this.category = category;
   }

   /**
    * @return Returns the description.
    */
   @Column
   public String getDescription() {
      return this.description;
   }

   /**
    * @param description
    *           The description to set.
    */
   public void setDescription(String description) {
      this.description = description;
   }

   /**
    * @return Returns the events.
    */
   @Column
   public String getEvents() {
      return this.events;
   }

   /**
    * @param events
    *           The events to set.
    */
   public void setEvents(String events) {
      this.events = events;
   }

   /**
    * @return Returns the location.
    */
   @Column
   public String getLocation() {
      return this.location;
   }

   /**
    * @param location
    *           The location to set.
    */
   public void setLocation(String location) {
      this.location = location;
   }

   /**
    * @return Returns the photoDate.
    */
   @Column
   public Date getPhotoDate() {
      return this.photoDate;
   }

   /**
    * @param photoDate
    *           The photoDate to set.
    */
   public void setPhotoDate(Date photoDate) {
      this.photoDate = photoDate;
   }


   /**
    * @return Returns the data.
    */
   @Column
   @NotNull
   @Lob (type = LobType.BLOB)
   public byte[] getData() {
      return this.data;
   }

   /**
    * @param data
    *           The data to set.
    */
   public void setData(byte[] data) {
      this.data = data;
   }

   /**
    * @return Returns the updater.
    */
   @ManyToOne (cascade = {
      CascadeType.ALL
   }, fetch = FetchType.LAZY)
   @JoinColumns ( {
      @JoinColumn (name = "UPDATER_ID")
   })
   @NotNull   
   public User getUpdater() {
      return this.updater;
   }

   /**
    * @param updater
    *           The updater to set.
    */
   public void setUpdater(User updater) {
      this.updater = updater;
   }

   /**
    * @return Returns the creator.
    */
   @ManyToOne (cascade = {
      CascadeType.ALL
   }, fetch = FetchType.LAZY)
   @JoinColumns ( {
      @JoinColumn (name = "CREATOR_ID")
   })
   @NotNull
   public User getCreator() {
      return this.creator;
   }

   /**
    * @param creator
    *           The creator to set.
    */
   public void setCreator(User creator) {
      this.creator = creator;
   }
   
   @Transient
   public String getType() {      
        int idx = name.lastIndexOf(".");
        
        String type = "";
        
        if (idx > 0) {
           type = name.substring(idx+1);
        }
        
        return type;
   }


}


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.