ClassCastException when updating lazy loaded bytecode enhanced byte[]
Description
Attachments
- 25 May 2018, 11:37 AM
relates to
Activity
Ka Wu March 25, 2021 at 2:58 PM
At the time of this writing 5.2.18.Final was not published on the release page for 5.2. Sorry for the inconvenience.
Ka Wu March 25, 2021 at 8:23 AM
This bugfix is tagged as 5.2.18, but the release is pending.
I’ve just posted this in the forums: https://discourse.hibernate.org/t/backporting-hhh-12555-to-5-2/5213
Will there be a 5.2.18 release anytime soon?
We REALLY REALLY need this bugfix. :-(
Mario Martinho Dias May 25, 2018 at 4:39 PM
The side effects were on other unrelated parts of my codebase but I'll look into it, cheers!
Guillaume Smet May 25, 2018 at 4:32 PM
Might be interesting for us to know about the side effects, maybe we have other things to fix!
Anyway, I created a PR with a proposed fix. Needs some review on this though as I'm not very familiar with this area of the code.
Mario Martinho Dias May 25, 2018 at 3:49 PM
It does, but for a current project enabling it had some unintended side effects. My workaround was to create a user type wrapper around the byte array.
When updating an entities byte[] field configured as lazy loaded causes the exception:
Caused by: java.lang.ClassCastException: org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer$1 cannot be cast to [B
at org.hibernate.type.descriptor.java.PrimitiveByteArrayTypeDescriptor.areEqual(PrimitiveByteArrayTypeDescriptor.java:26) <...>
Test passes if I disable "enableLazyInitialization" or cause the field to load (via getter) before I update it.