Class RemoveEmptyMapValuesUtil


  • public class RemoveEmptyMapValuesUtil
    extends Object
    Author:
    Matthijs Laan
    • Constructor Detail

      • RemoveEmptyMapValuesUtil

        public RemoveEmptyMapValuesUtil()
    • Method Detail

      • removeEmptyMapValues

        public static void removeEmptyMapValues​(Map map)
        IMPORTANT TO CALL THIS BEFORE SAVING / UPDATING AN ENTITY WITH A DETAILS MAP. Hibernate fails to remove map entries with a null value when calling clear() on a map on Oracle. This leads to duplicate key violations when updating layer details.

        @PreUpdate/@PrePersist nor @EntityListeners do not work consistenly with cascaded objects in Hibernate, so call this manually!

        Parameters:
        map - the map to clean up