-->
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: A truncation error was encountered trying to shrink BLOB '(B
PostPosted: Sat Apr 16, 2011 11:19 am 
Beginner
Beginner

Joined: Sun Jan 30, 2011 8:14 am
Posts: 24
Dearl all,
I'm newbie of hibernate and I'm trying to use it with derby in my javafx application.
I 've an issue only with blob type.
Here is my entity (I use annotations)

Code:
@Entity
@Table(name = "allegato")
public class Allegato extends org.jfxtras.lang.XObject implements java.io.Serializable{
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "ID_ALLEGATO")
    private long idAllegato;
    @Column(name = "ID_DIAGNOSI")
    private long idDiagnosi;
    @Column(name="BLOB", length=Integer.MAX_VALUE - 1)
    @Basic(fetch=FetchType.LAZY)
    private Blob blob;

   
    public long getIdAllegato() {
        return idAllegato;
    }

    public void setIdAllegato(long idAllegato) {
        this.idAllegato = idAllegato;
    }


    public long getIdDiagnosi() {
        return idDiagnosi;
    }

    public void setIdDiagnosi(long idDiagnosi) {
        this.idDiagnosi = idDiagnosi;
    }

   
    public Blob getBlob() {
        return blob;
    }

    public void setBlob(Blob blob) {
        this.blob = blob;
    }}


I get file from path and put it into blob field in this way:

Code:
File source = new File(allegati[j]);
byte[] bFile = new byte[(int) source.length()];
                try {
                   
                    FileInputStream fileInputStream = new FileInputStream(source.getAbsolutePath());
                    //convert file into array of bytes
                    fileInputStream.read(bFile);
                    Blob cBlob = Hibernate.createBlob(fileInputStream, (int) source.length());
                     cAllegato.setBlob(cBlob);
                     fileInputStream.close();



I've got this exception

Code:
GRAVE: A truncation error was encountered trying to shrink BLOB '(Binary data value not displayed)' to length 255.
Exception occurred during event dispatching:
ortholab2.dao.DataAccessLayerException: org.hibernate.exception.DataException: could not insert: [ortholab2.entity.Allegato]



Please help me,
Thanks ,
Regards


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.