1

I recently added a new column "PASSWORD_RESET_REQUIRED" into my user and user_audit table.

Not when I am trying to delete a user I get an error saying :

cannot insert NULL into ("USER_AUD"."PASSWORD_RESET_REQUIRED")

@Entity
@Table(name = "sec_user", schema = "RZUL_DATA")
//Override the default Hibernate delete and set the termination date rather than     deleting the record from the db.
@SQLDelete(sql = "UPDATE RZUL_DATA.sec_user SET trmn_dt = sysdate  WHERE user_id = ?")

@Audited
public class User {

@NotEmpty
@Column(name = "password_reset_required", updatable = true, insertable = true)
private String isPasswordResetRequired;

 ... other properties
}

My UserDao delete method:

@Override
public boolean deleteUser(final User user) {
    sessionFactory.getCurrentSession().delete(user);
   NOTE: Till this point I can see the user.isPasswordResetRequired an a non null.
    return true;
}

What part could I be missing?

user620339
  • 851
  • 3
  • 20
  • 42

2 Answers2

2

Make sure your *_HISTORY table has no NOT NULL Data Colums.

Patrice
  • 1,404
  • 1
  • 14
  • 27
1

When you try to remove the items Hibernate try to set the foreign key column on the Child table to null and because its not null able the SQL technology you are using is giving error. Try

@Cascade(value=CascadeType.ALL)

See cannot insert null in one to many relatioship hibernate annotation

Community
  • 1
  • 1
Shehzad
  • 2,870
  • 17
  • 21