Exemplo n.º 1
0
  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();
  }