Help! spring 下 hibernate的一个异常。

gen_fossil 2006-11-30 02:05:16
我对表employee和address进行了map,employee中的address_Id是外键,
address的xml配置:
<set name="employees" inverse="true">
<key>
<column name="address_Id" />
</key>
<one-to-many class="addressmap.Employee" />
</set>
employee的xml配置:
<many-to-one name="address" class="employeemap.Address" fetch="select">
<column name="address_Id" />
</many-to-one>
applicationContext.xml 中的bean的配置:
<bean id="AddressDAO" class="addressmap.AddressDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="EmployeeDAO" class="employeemap.EmployeeDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

在执行到:ApplicationContext ctx = new FileSystemXmlApplicationContext(
"src/applicationContext.xml");时抛出异常:

Error creating bean with name 'sessionFactory' defined in file

[C:\Documents and Settings\chenzhou.chen\Desktop\workspace\crmdemo3\src\applicationContext.xml]:

Initialization of bean failed;

nested exception is org.hibernate.MappingException: Association references unmapped class: addressmap.Employee

org.hibernate.MappingException: Association references unmapped class: addressmap.Employee

......
请问是怎么回事?
...全文
98 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
elvihuang 2006-12-01
  • 打赏
  • 举报
回复
field not found: address
这个是你的bean里没有address这个属性
gen_fossil 2006-11-30
  • 打赏
  • 举报
回复
有人帮我看看吗?我弄了很长时间了,不知道怎么回事。
我也试过先map没有外键关系的两张表,然后再在各自的hbm.xml文件 中配置many-to-one
<many-to-one
name = "address"
column ="addressId"
unique = "true"
not-null ="true"
/> 结果有这样的异常Initialization of bean failed; nested exception is org.hibernate.PropertyNotFoundException: field not found: address
org.hibernate.PropertyNotFoundException: field not found: address

有谁告诉我正确的使用外键的方法是怎样的?

58,454

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧