chabeee
chabeee

Reputation: 305

Want to delete with HibernateUtils, but it throws exception

I just want to delete vPref from my db, but it throws caused by: java.lang.IllegalArgumentException: Removing a detached instance models.Preference

   public void valueChange(Property.ValueChangeEvent event) {
        switch ((SelectedDropdownItem) event.getProperty().getValue()) {
                    default:
                    if(vPref != null) {
                        HibernateUtils.delete(vPref);
                        vPref = null;
                    }
                    break;

the vPref cant be null, so I dont even know what the problem.

Upvotes: 0

Views: 58

Answers (1)

Sajan Chandran
Sajan Chandran

Reputation: 11487

You cannot remove an instance which is detached from hibernate. You need to first load the instance and then do any update operation on that instance. See link

Upvotes: 2

Related Questions