Erroneous update of the table from jsf pages



  • Hello. Trying to update:

        public void updateSubcategory(Subcategory subcategory) {
    
    if(subcategory == null) return;
    
    Query query = getSession().createQuery("update Subcategory set name = :name where id = :id");
    
    query.setParameter("name", subcategory.getName());
    query.setParameter("id", subcategory.getId());
    
    int result = query.executeUpdate();
    

    }

    On the line: Query query = getSession().createQuery("update Subcategory set name = :name where id = :id");

    java.lang.IllegalArgumentException: node to traverse cannot be null!

    I'm doing a similar thing to delete, delete everything works, and with some kind of trouble. ♪ ♪



  • Try this:

    String sql= String.format("UPDATE Subcategory set name =%s where id = %s", subcategory.getName(), subcategory.getId());
    Query query= session.createSQLQuery(sql);
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2