[jboss-jira] [JBoss JIRA] Created: (EJBTHREE-784) When updating an entity that has multiple Blob fields, the blob objects are getting swaped.
Sandeep Ghosh (JIRA)
jira-events at jboss.com
Mon Nov 13 12:18:41 EST 2006
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