| The default behavior of the NEW_LOCATOR_LOB_MERGE_STRATEGY in https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java is always duplicating the blob. Whenever an entity with a Blob is passed to merge, also if no changes are done in the entity at all, the Blob is duplicated with lobCreator.createBlob. I'm using PostgreSQL as database and orphaned large object are not automatically removed. So, this behavior is filling up the database up quickly, when several periodically jobs are executed and are using merge to sync back changes to the database. My fix is to add a check if the two blobs are using the same reference, so are unchanged and return the original. {{ if ( original == null && target == null ) { return null; } if ( original == target) { return original; } }} I have set this behavior to critical because the data usage is increasing at a very high pace in my DB, meaning that I will reach TBs in the next weeks although the real size is just several 100 MB. |