Uploaded image for project: 'Hibernate ORM'
  1. HHH-12370

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

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • backPortable:
      Backport?
    • Last commented by a user?:
      true
    • Sprint:

      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.

      @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);
        }
      }
      

        Attachments

          Issue links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: