当我尝试在DAOimpl
类中使用此方法更新hibernate中的条目时:
public void setVoiceMailUnread(int id) {
Session session = sessionFactory.openSession();
Transaction transaction = null;
VoiceMail vm = (VoiceMail)session.load(VoiceMail.class, id);
try {
transaction = session.beginTransaction();
vm.setRead(false);
transaction.commit();
} catch (HibernateException e) {
if (transaction != null)
transaction.rollback();
e.printStackTrace();
} finally {
session.close();
}
}
我收到以下错误:
ERROR: ERROR: column "recording" is of type lo but expression is of type bigint
Hint: You will need to rewrite or cast the expression.
Position: 201
在我的实体类中,实例变量记录的类型为Blob:
@Entity
@Table(name = "VOICEMESSAGES")
public class VoiceMail implements Serializable {
private int uniqueId;
private int messageNumber;
private String directory;
private String context;
private String macroContext;
private String callerId;
private String origTime;
private String duration;
private String flag;
private String mailboxUser;
private String mailboxContext;
private Blob recording;
private String label;
private Boolean read;
private String messageId;
.....
@Column(name = "RECORDING", unique = true, nullable = false)
@Lob
@JsonIgnore
public Blob getRecording() {
return recording;
}
public void setRecording(Blob recording) {
this.recording = recording;
}
也许我遗漏了与大型对象的anotations相关的内容,因为db中的记录列是“lo”类型。 谢谢你的回答!