- <hibernate-mapping>
- <class name="com.hbm.entity.User" table="tuser">
- <id name="userId">
- <column name="userId" />
- <generator class="sequence">
- <param name="sequence">seq</param>
- </generator>
- </id>
- <property name="username"/>
- <property name="password"/>
- <many-to-one name="role" column="roleId" class="com.hbm.entity.Role" unique="true" />
- </class>
- </hibernate-mapping>
- <hibernate-mapping package="com.hbm.entity" >
- <class name="Role" >
- <id name="roleId" column="roleId" >
- <generator class="assigned"/>
- </id>
- <property name="name" />
- </class>
- </hibernate-mapping>
一对一单向外键关联 用户->角色
hibernate.cfg.xml 都加了对应的映射文件的
导致错误的原因是
<many-to-one name="role" column="roleId" class="com.hbm.entity.Role" unique="true" />
class 开始写的不是类的全路径