@Override
public com.iranatelier.sistema.dominio.Probandoblob pruebaBajarImagen() throws Exception{
com.iranatelier.sistema.dominio.Probandoblob a = new com.iranatelier.sistema.dominio.Probandoblob();
Probandoblob b = new Probandoblob();
try {
Query query = en.createNamedQuery("Probandoblob.findAll");
List lista = query.getResultList();
if (lista.size() > 0) {
for(Object c : lista){
b = (Probandoblob) c;
a.setId(b.getId());
a.setImagen(b.getImagen());
}
}
} catch (Exception e) {
throw new Exception("Error en editarEntrega:", e);
}
return a;
}
我有一个sql oracle table whit blob数据类型,当我尝试从数据库中获取select的结果时,sendme会出现此错误。
Exception Description: Could not deserialize object from byte array.
Internal Exception: java.io.StreamCorruptedException: invalid stream header: FFD8FFE0
Mapping: org.eclipse.persistence.mappings.DirectToFieldMapping[imagen-->JAAN.PROBANDOBLOB.IMAGEN]
Descriptor: RelationalDescriptor(com.iranatelier.sistema.entities.Probandoblob --> [DatabaseTable(JAAN.PROBANDOBLOB)])>
实体是:
@Entity
@Table(name = "PROBANDOBLOB", catalog = "", schema = "JAAN")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Probandoblob.findAll", query = "SELECT p FROM Probandoblob p")
, @NamedQuery(name = "Probandoblob.findById", query = "SELECT p FROM Probandoblob p WHERE p.id = :id")})
public class Probandoblob implements Serializable {
private static final long serialVersionUID = 1L;
// @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
@Id
@Basic(optional = false)
@NotNull
@Column(name = "ID")
private BigDecimal id;
@Basic(optional = false)
@NotNull
@Lob
@Column(name = "IMAGEN")
private byte[] imagen;
我如何从数据库下载blob类型?