We're updating the issue view to help you get more done. 

Lazily-initialized byte[] LOB gets turned into a String, resulting in poor performance

Description

I am having some performance issues with caching lazily-initialized LOBs. A large amount of time (>25% of total time according to JMC) is spent trying turn the byte[] into a String. Some of our byte[]s can be several MBs large, and this is hurting performance more than caching them improves performance in the first place.

I thought this could be related to https://hibernate.atlassian.net/browse/HHH-11097 but we are using 5.2.13. I have attached the stack trace in the images below. My entity class, which is lazily loaded, is below.

I see in https://github.com/hibernate/hibernate-orm/commit/c7c9e421454fd6c5c4ac426f39dffe9440a8ba37 that Clob and BlobTypeDescriptors should print BLOB(...). instead of trying to create a String. However, despite my @Lob annotation, it is still a PrimitiveByteArrayTypeDescriptor.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 @Entity public class Payload { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Lob @Column(length = Integer.MAX_VALUE) private byte[] payload; public Payload() {} public Payload(byte[] payload){ super(); this.payload = Arrays.copyOf(payload, payload.length); } public byte[] getPayload() { return payload; } public void setPayload(byte[] payload) { this.payload = Arrays.copyOf(payload, payload.length); } }

Environment

None

Status

Assignee

Sanne Grinovero

Reporter

Phil Godzin

Fix versions

backPortable

Backport?

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

5.2.13

Priority

Major