【发布时间】:2013-12-05 20:57:39
【问题描述】:
我正在尝试做一个简单的消息系统,但映射出现严重的 hbernate 错误。这是类的示例
@Entity
public class SMS {
@Id
@GeneratedValue
@Column(name = "sms_id")
private int id;
private Korisnik sender;
private Korisnik receiver;
private String text;
这是 SMS 类中的 Korisnik 类
@Entity
public class Korisnik {
@Id
@Column(name = "user_num")
private int id;
private String name;
public int getNumber() {
return id;
}
如何设置类以便正确映射?
org.springframework.beans.factory.BeanCreationException: 错误 创建名为“korisnikDaoImpl”的bean:注入自动装配 依赖失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:不能 自动装配字段:私有 org.hibernate.SessionFactory com.sendsms.dao.impl.KorisnikDaoImpl.sessionFactory;嵌套异常 是 org.springframework.beans.factory.BeanCreationException: 错误 创建在类路径中定义的名称为“sessionFactory”的bean 资源 [com/sendsms/config/AppConfig.class]:init 的调用 方法失败;嵌套异常是 org.hibernate.MappingException: 无法确定类型:com.sendsms.model.Korisnik,在表中: SMS,用于列:[org.hibernate.mapping.Column(receiver)]
【问题讨论】:
-
请发布您的异常堆栈跟踪。
-
这是根本原因
-
您可以编辑您的问题。在那里添加它。
-
您是否在 SessionFactory
中添加了实体?在配置中?
标签: java hibernate web-applications