I have one table called AdminRole
ADMIN_ROLE_ID | DESCRIPTION | NAME | ARCHIVED
I need to delete a record from AdminRole
as admin role is very important. I need to perform soft deletion instead of hard deletion. For this I am trying to use @SqlDelete
hibernate annotation. My entity class is this:
@Entity
@table(name="ADMINROLE")
@SqlDelte(sql="UPDATE ADMINROLE SET ARCHIVED = 'Y' WHERE ADMIN_ROLE_ID=?")
public class AdminRole{
@column(name="ADMIN_ROLE_ID" )
protected Lond id;
@column(name="DESCRIPTION" )
protected String description;
@column(name="NAME" )
protected String name;
...
...
}
I have to show the record on front end when ARCHIVED
in N
if it is Y
record is not visible in front end, when I create admin role ARCHIVED
is setting to N
succesfully and showing on front end. But the problem is when I try to delete the admin role
from front end the ARCHIVED
is not setting to Y
due to this record is showing on front end.
In DAO
public AdminDAO {
protected EntityManager manager;
public void remove(Serializable entity){
manager.remove(entity)
}
}
why is @SqlDelete
is not working for me can anyone help me? No exception raised on log file. When this @SqlDelete
will be executed?
答案 0 :(得分:1)
我自己解决了这个问题,问题是从我这边只是我不小心更新了不同的表现在我改为我的adminrole
表
在
@SqlDelte(sql="UPDATE ROLE SET ARCHIVED = 'Y' WHERE ROLE_ID=?")
之后
@SqlDelte(sql="UPDATE ADMINROLE SET ARCHIVED = 'Y' WHERE ADMIN_ROLE_ID=?")
答案 1 :(得分:0)
我也在解决“ SQLDelete无法正常工作”的问题,这是我得到的第一个Google搜索结果,因此也许会对其他人有所帮助:
使用超类映射时,不仅要在超类本身上进行扩展,还要为扩展超类的每个实体指定SQLDelete,尽管它们都存储在一个数据库表中。