tags:

views:

48

answers:

1
public void uploadFile(ActionEvent evt)throws Exception{
InputFile inputFile=(InputFile)evt.getSource();
    byteArrayOutputStream=new ByteArrayOutputStream();
    ObjectOutputStream objectOutputStream=new ObjectOutputStream(byteArrayOutputStream);
    objectOutputStream.writeObject(inputFile.getFile());

    reportTemplate.setTemplatePath(inputFile.getFilename());
reportTemplate.setTemplateData(Hibernate.createBlob(byteArrayOutputStream.toByteArray()));
        this.reportTemplate=  reportFacadeLocal.createReportTemplate(reportTemplate);

} I am use EJB 3.0 and use persist method of EntityManager class to create entry in database. if I just explain code than reportTemplate is the entity bean instance , entity bean's templateData field is of type blob.Code describe above working fine and create entry in the database.

problem occurred while update the record all field except blob field are updated. I am use EntityManager merge method to update record.

+1  A: 

Try using entityManager.createNativequery(SomeQuery) or use entityManager.createNamedQuery(SomeQuery) rather then using entityManager.merge(Object) method directly to update.

Nayan Wadekar