我在插入数据库库时使用的时dao.insert方法
/**
* 新增楼盘信息
* @return
*/
public String addBuilding(String name, Date adddate) {
BuildingInfo build = new BuildingInfo();
build.setName(name);
build.setAddDate(adddate);
dao.insert(build);
return "数据插入成功";
}
结果报错了
2017-07-24 11:11:04 DEBUG [http-nio-0.0.0.0-8080-exec-27] INSERT INTO data.building(name,adddate,name,id,adddate) VALUES(?,?,?,?,?)
| 1 | 2 | 3 | 4 | 5 |
|-------|---------------------|-------|---|---------------------|
| 阿达阿萨德 | 2017-07-24 00:00:00 | 阿达阿萨德 | 0 | 2017-07-24 00:00:00 |
For example:> "INSERT INTO data.building(name,adddate,name,id,adddate) VALUES('阿达阿萨德','2017-07-24 00:00:00','阿达阿萨德',0,'2017-07-24 00:00:00') "
2017-07-24 11:11:04 DEBUG [http-nio-0.0.0.0-8080-exec-27] SQLException
org.postgresql.util.PSQLException: 错误: 字段 "name" 被指定多次
位置:40
为什么sql会多次插入字段
4 回复
@Table(value = "data.building" )
public class BuildingInfo {
private String name;
private Date adddate;
@Id
private int id;
/** default constructor */
public BuildingInfo() {
}
public BuildingInfo(String name,Date adddate,int id) {
this.name=name;
this.adddate=adddate;
this.id=id;
}
@Column(value = "name" )
public String getName() {
return this.name;
}
public void setName(String name) {
this.name=name;
}
@Column(value = "adddate" )
public Date getAddDate() {
return this.adddate;
}
public void setAddDate(Date date) {
this.adddate = date;
}
@Column(value = "id" )
public int getID() {
return this.id;
}
public void setID(int id) {
this.id=id;
}
}
添加回复
请先登陆