我正在尝试插入以下代码中的值:
public int create(Officer officer) {
String sql = "insert into officer values(" + officer.getOfficer_id() + ", " + officer.getCollege_id() + ", " + Officer.getUnit_id() + ", " + officer.getRole_id() + ")";
return template.update(sql);
}
答案 0 :(得分:1)
这应该是编译错误。 getUnit_id不是静态方法,因此您需要使用Officer实例调用它。
public int create(Officer officer) {
String sql = "insert into officer values(" + officer.getOfficer_id() + ", " + officer.getCollege_id() + ", " + officer.getUnit_id() + ", " + officer.getRole_id() + ")";
return template.update(sql);
}