Hi, I have an entity mapped with an byte[] attribute (SQL Server - Column definition: Photo IMAGE).
{noformat}@Entity @Table(name = "MYTABLE") public class MyEntity {
...
@Lob @Column(name = "Photo") private byte[] photo = null;
...
}
public byte[] getPhoto(String id) { CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); CriteriaQuery<byte[]> cq = cb.createQuery(byte[].class);
Root<MyEntity> root = cq.from(MyEntity.class);
cq.select(root.get(MyEntity_.photo)) .where(cb.equal(root.get(MyEntity_.id), id));
TypedQuery<byte[]> q = getEntityManager().createQuery(cq);
return q.getSingleResult();
}{noformat}
Executing the query i’m getting:
{{Caused by: java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [B ([Ljava.lang.Object; and [B are in module java.base of loader 'bootstrap')}}
I created a unit test [https://github.com/DanielNovo/hibernate-test-case-templates/commit/dd2f5df4013130543d98387c4fa2a26262f76e5a|https://github.com/DanielNovo/hibernate-test-case-templates/commit/dd2f5df4013130543d98387c4fa2a26262f76e5a|smart-link] |
|