0
在我的MySQL數據庫我有一個表,命名爲: - file_upload 表結構; -春節冬眠MySQL不能獲取數據
我已經存儲在這個table..Now圖片我想取圖像.. 所以,我有: -
@Table(name = "file_upload")
public class ProfilePic {
private long id;
private String fileName;
private byte[] data;
--setters and getters with @Column annotation---
public ProfilePic(BigInteger userId) {
super();
this.userId = userId;
}
}
我DAO類是: -
public ProfilePic FetchImage(ProfilePic profilePic) {
String hql = "select data from ProfilePic where userId = :userId1 ";
logger.info(profilePic.getUserId());
Query query = (Query) sessionFactory.getCurrentSession().createQuery(hql)
.setParameter("userId1", profilePic.getUserId());
return (ProfilePic) query.uniqueResult();
}
但我GETT ing error:---
org.hibernate.NonUniqueResultException: query did not return a unique result: 4
爲什麼??問題出在哪裏?
Yaah ...我明白了..謝謝.. – Salini