ClassCastException when updating lazy loaded bytecode enhanced byte[]


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 <...>

Test passes if I disable "enableLazyInitialization" or cause the field to load (via getter) before I update it.


java 1.8.0_172, windows 10


Ka Wu
March 25, 2021, 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, 8:23 AM

This bugfix is tagged as 5.2.18, but the release is pending.

I’ve just posted this in the forums:

Will there be a 5.2.18 release anytime soon?

We REALLY REALLY need this bugfix. :-(

Mario Martinho Dias
May 25, 2018, 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, 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, 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.



Guillaume Smet


Mario Martinho Dias

Fix versions