首先看下报错日志:
### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "bas_alpcustomer_pkey"
详细:Key (id)=(77) already exists.
我的原因是系统再保存的时候始终保存不了,并且后台报这个错,究其原因是主键自增设置的问题,我的数据库是从mysql移植到postgresql的,所以sql也有好多问题。我的主键默认是
nextval('bas_alpcustomer_id_seq'::regclass)
解决办法:
1、首先看下自增值
SELECT nextval('"bas_alpcustomer_id_seq"'::regclass)
2、我的显示是 74 ,但是该表有三百多条数据,经从网上查询执行一下
SELECT setval('"bas_alpcustomer_id_seq"', (SELECT MAX(id) FROM "bas_alpcustomer")+1);
执行完后在执行1中的sql,查询结果和我的数据条数一致。再换到程序执行该sql,ok没问题!!!
最后贴一下解决问题的博主(http://www.cnblogs.com/catvan/p/9597701.html)