[jboss-jira] [JBoss JIRA] Commented: (EJBTHREE-784) When updating an entity that has multiple Blob fields, the blob objects are getting swaped.

Emmanuel Bernard (JIRA) jira-events at lists.jboss.org
Tue Feb 13 20:25:32 EST 2007


    [ http://jira.jboss.com/jira/browse/EJBTHREE-784?page=comments#action_12353022 ] 
            
Emmanuel Bernard commented on EJBTHREE-784:
-------------------------------------------

Seems like your driver messes up. Note that blob/clobs can only be updated in the same transaction that loaded them as per the JDBC spec

> When updating an entity that has multiple Blob fields, the blob objects are getting swaped.
> -------------------------------------------------------------------------------------------
>
>                 Key: EJBTHREE-784
>                 URL: http://jira.jboss.com/jira/browse/EJBTHREE-784
>             Project: EJB 3.0
>          Issue Type: Bug
>          Components: EJB3 Extensions
>         Environment: App server: JBoss 4.0.4GA
> DB: Oracle 9i with the 10g driver.
>            Reporter: Sandeep Ghosh
>
> We are trying to store two BLOB fields (using extended persistence) and after setting the two fields with the right binary data, the data is somehow switched between the fields. i.e. if image1 is to be set in colum1 and file2 in column2 after the db transaction is completed using an extended persistence context, image1 is set in column2 and file2 is set in column1. 
> Here's the entity class 
> @Entity
> @Table(name = "GENE_CLONE_QC", uniqueConstraints = {})
> public class GeneCloneQc implements java.io.Serializable {
> 	@Lob @Basic(fetch=FetchType.EAGER)
> 	@Column(name = "DELETED_SEQ", unique = false, nullable = true, insertable = true, updatable = true)
> 	public String getDeletedSeq() {
> 		return this.deletedSeq;
> 	}
> 	public void setDeletedSeq(String deletedSeq) {
> 		this.deletedSeq = deletedSeq;
> 	}
>     @Lob @Basic(fetch = FetchType.EAGER)
> 	@Column(name = "QC_IMAGE", unique = false, nullable = true, insertable = true, updatable = true)
> 	public Blob getQcImage() {
> 		return this.qcImage;
> 	}
> 	public void setQcImage(Blob qcImage) {
> 		this.qcImage = qcImage;
> 	}
> }
> Here's the class with the save method that has the issue stated above
> @Stateful
> @Name("geneCloneQcBean")
> @Scope(ScopeType.SESSION)
> public class GeneCloneQcBean implements GeneCloneQcInf {
> 	@PersistenceContext(type = PersistenceContextType.EXTENDED)
> 	protected EntityManager entityManager;
> 	public void save(){
>         if(qcImageFile != null){
>             Blob image = null;
>             try {
>                 image = org.hibernate.Hibernate.createBlob(qcImageFile.getBytes());
>             } catch (IOException e) {
>                 e.printStackTrace();
>             }
>             geneCloneQc.setQcImage(image);
>         }
>         if(sequenceDataFile != null){
>             Blob sequenceDataFileBlob = null;
>             try {
>                 sequenceDataFileBlob = org.hibernate.Hibernate.createBlob(sequenceDataFile.getBytes());
>             } catch (IOException e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>             }
>             String fileName = sequenceDataFile.getName();
>             fileName = fileName.substring(fileName.lastIndexOf("\\")+1);
>             geneCloneQc.setSequenceDataFileName(fileName);
>             geneCloneQc.setSequenceDataFile(sequenceDataFileBlob);
>         }
>         
>         geneClone.setGeneCloneQc(geneCloneQc);
>         entityManager.persist(geneClone);
>     }  
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list