我在使用 struts 并将记录插入数据库时遇到了一些问题
数据库是这样的
以下是地图:
<mapper namespace="Employees">
<resultMap id="employeeMap" type="employee">
<id column="employeeID" property="employeeID" />
<result column="employeeNum" property="employeeNum" />
<result column="username" property="userName" />
<result column="firstName" property="firstName" />
<result column="lastName" property="lastName" />
<association property="address" column="addressID" resultMap="addressMap" />
</resultMap>
<resultMap id="addressMap" type="address">
<id column="addressID" property="id" />
<result column="addressLine1" property="addressLine1" />
<result column="addressLine2" property="addressLine2" />
<result column="city" property="city" />
<result column="postcode" property="postcode" />
<result column="country" property="country" />
</resultMap>
这是 Employee 对象:
public class Employee{
private static final long serialVersionUID = 1L;
private int employeeID;
private String employeeNum;
private String firstName;
private String lastName;
关于存储上述关系,我的表应该如何?
此时,Employees 表看起来像:employeeID employeeNum firstName lastName addressID
而且我不断收到错误消息,例如“addressID 没有默认值”是所有内容都按照应有的方式布置还是我遗漏了什么?