Daniel Novo (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5ae986b...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYmZkYTgzMTJl...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16606?atlOrigin=eyJpIjoiYmZkYT...
) HHH-16606 (
https://hibernate.atlassian.net/browse/HHH-16606?atlOrigin=eyJpIjoiYmZkYT...
) ClassCastException retrieving byte[] from database (
https://hibernate.atlassian.net/browse/HHH-16606?atlOrigin=eyJpIjoiYmZkYT...
)
Issue Type: Bug Affects Versions: 6.2.2 Assignee: Unassigned Components: hibernate-core
Created: 15/May/2023 07:15 AM Priority: Blocker Reporter: Daniel Novo (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5ae986b...
)
Hi, I have an entity mapped with an byte[] attribute (SQL Server - Column definition:
Photo IMAGE).
@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();
}
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://hibernate.atlassian.net/browse/HHH-16606#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16606#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:a5851ae )