Batch update returned unexpected row count from update [0];

Viewed 14106

I use this entity in order to record into database.

@Entity
@Table(name = "SYSTEM_USERS")
public class SystemUsersModel implements Serializable
{
    private static final long serialVersionUID = 8432414340180447723L;

    @Id
    @GeneratedValue
    private Integer id;

    @Column
    private String username;

    @Column
    private String email;

    @Column
    @Type(type = "date")
    @Temporal(TemporalType.DATE)
    private Date lastlogin;

    @Column
    private String password;

    @Column
    private String salt;

    @Column
    @Type(type = "date")
    @Temporal(TemporalType.DATE)
    private Date added;

Delete query:

SessionFactory factory = HibernateUtils.getSessionFactory();
        Session session = factory.getCurrentSession();

        try
        {
            session.getTransaction().begin();

            SystemUsersModel obj = new SystemUsersModel();
            obj.setId(userlist.getId());

            session.delete(obj);

            session.getTransaction().commit();

            blacklists.remove(selectedBlackListEntry);
            selectedBlackListEntry = null;
        }
        catch (Exception e)
        {
            e.printStackTrace();
            session.getTransaction().rollback();
        }

Then I run the code I get this error:

Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

I had inserted several rows using script before I start the application. How I can solve this issue?

2 Answers
Related