如何在休眠中将@filter参数类型设置为枚举?
Hibernate版本5.3.x
@FilterDef(name = "my_filter", parameters = {
@ParamDef(name = "status", type = "what should be here? ")
})
@Filter(name = "my_filter", condition = "status = :status")
@Entity
public class MyEntity{
....
private MyStatus status;
....
}
enum
public enum MyStatus{
STATUS1,STATUS2
}
答案 0 :(得分:0)
尝试以下方法:
类上的过滤器定义:
@FilterDef(name = "my_filter", parameters = {
@ParamDef(name = "state", type = "string")
})
@Filter(name = "my_filter", condition = "status = :status")
@Entity
public class MyEntity{
....
private MyStatus status;
....
}
启用过滤器:
session.enableFilter("my_filter").setParameter("state", MySatus.STATUS1.toString());