我遇到了休眠问题。
我有这个例外
Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
我正在尝试显示数据库中的日期,我的专栏之一是一个字符,在我的班级中有一个Enum
public enum Status {
CADASTRADA('C', "Cadastrada"),
APROVADA('A', "Aprovada"),
LIBERADA('L', "Liberada"),
BLOQUEADA('B', "Bloqueada");
public char index;
public String descricao;
private Status(char index, String descricao) {
this.index = index;
this.descricao = descricao;
}
public static Status valueOf(char index) {
for (Status status : Status.values()) {
if (status.equals(index)) {
return status;
}
}
return null;
}
public String getDescricao() {
return this.descricao;
}
public char getIndex() {
return this.index;
}
}
`
我创建一个TypeClass
来转换
`public class FilialStatusType extends TypeHibernate { public static final String TYPE = "filialStatusType";
@Override
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImpl, Object obj)
throws HibernateException, SQLException {
String index = rs.getString(names[0]);
return StringUtil.isStringNullOrEmpty(index) ? null : Filial.Status.valueOf(index.charAt(0));
}
@Override
public void nullSafeSet(PreparedStatement ps, Object value, int index, SessionImplementor session)
throws HibernateException, SQLException {
Filial.Status status = (Filial.Status) value;
if (NullUtil.isNull(status)) {
ps.setNull(index, CharacterType.INSTANCE.sqlType());
} else {
ps.setString(index, String.valueOf(status.index));
}
}
@Override
public Class<Filial.Status> returnedClass() {
return Filial.Status.class;
}
} `
那么有人可以帮助我吗?