public void clearAttributeValue(Attribute attribute) { if (attribute == null || attribute.getPropertyIndex() == null || attribute.getProductCategory() == null) { return; } String jpql = "update Goods goods set goods." + Goods.ATTRIBUTE_VALUE_PROPERTY_NAME_PREFIX + attribute.getPropertyIndex() + " = null where goods.productCategory = :productCategory"; entityManager .createQuery(jpql) .setParameter("productCategory", attribute.getProductCategory()) .executeUpdate(); }