`
knight_black_bob
  • 浏览: 853655 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

hibernate 报错 SQL Error: 1062, SQLState: 23000

阅读更多

 

 

hibernate 报错 SQL Error: 1062, SQLState: 23000

 

第一次插入成功,第二次失败

 

2018-04-12 10:50:35.163  INFO 10708 --- [pool-1-thread-1] s.spider.govZone.task.SchedulerTask      : ===================== scheduled ====================
2018-04-12 10:50:35.164  INFO 10708 --- [cTaskExecutor-5] s.s.govZone.linstener.EventListener      : ========================showandshare.spider.govZone.event.CityEvent[source=showandshare.spider.govZone.service.impl.ProcessServiceImpl@777d0398]
========================================
[{"cityCode":"620100000000","cityId":0,"cityKey":"6201","cityName":"兰州市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6201.html","countryList":[],"provinceKey":"62"},{"cityCode":"620200000000","cityId":0,"cityKey":"6202","cityName":"嘉峪关市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6202.html","countryList":[],"provinceKey":"62"},{"cityCode":"620300000000","cityId":0,"cityKey":"6203","cityName":"金昌市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6203.html","countryList":[],"provinceKey":"62"},{"cityCode":"620400000000","cityId":0,"cityKey":"6204","cityName":"白银市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6204.html","countryList":[],"provinceKey":"62"},{"cityCode":"620500000000","cityId":0,"cityKey":"6205","cityName":"天水市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6205.html","countryList":[],"provinceKey":"62"},{"cityCode":"620600000000","cityId":0,"cityKey":"6206","cityName":"武威市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6206.html","countryList":[],"provinceKey":"62"},{"cityCode":"620700000000","cityId":0,"cityKey":"6207","cityName":"张掖市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6207.html","countryList":[],"provinceKey":"62"},{"cityCode":"620800000000","cityId":0,"cityKey":"6208","cityName":"平凉市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6208.html","countryList":[],"provinceKey":"62"},{"cityCode":"620900000000","cityId":0,"cityKey":"6209","cityName":"酒泉市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6209.html","countryList":[],"provinceKey":"62"},{"cityCode":"621000000000","cityId":0,"cityKey":"6210","cityName":"庆阳市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6210.html","countryList":[],"provinceKey":"62"},{"cityCode":"621100000000","cityId":0,"cityKey":"6211","cityName":"定西市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6211.html","countryList":[],"provinceKey":"62"},{"cityCode":"621200000000","cityId":0,"cityKey":"6212","cityName":"陇南市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6212.html","countryList":[],"provinceKey":"62"},{"cityCode":"622900000000","cityId":0,"cityKey":"6229","cityName":"临夏回族自治州","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6229.html","countryList":[],"provinceKey":"62"},{"cityCode":"623000000000","cityId":0,"cityKey":"6230","cityName":"甘南藏族自治州","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6230.html","countryList":[],"provinceKey":"62"}]
========================================
=================1=======================
{"cityCode":"620100000000","cityId":0,"cityKey":"6201","cityName":"兰州市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6201.html","countryList":[],"provinceKey":"62"}
Hibernate: select province0_.province_id as province1_2_, province0_.province_code as province2_2_, province0_.province_key as province3_2_, province0_.province_name as province4_2_, province0_.province_url as province5_2_ from t_province province0_ where province0_.province_key=?
Hibernate: select citylist0_.province_id as province7_0_0_, citylist0_.city_id as city_id1_0_0_, citylist0_.city_id as city_id1_0_1_, citylist0_.city_code as city_cod2_0_1_, citylist0_.city_key as city_key3_0_1_, citylist0_.city_name as city_nam4_0_1_, citylist0_.city_url as city_url5_0_1_, citylist0_.province_id as province7_0_1_, citylist0_.province_key as province6_0_1_ from t_city citylist0_ where citylist0_.province_id=?
==================2======================
{"cityList":[],"provinceCode":"62","provinceId":28,"provinceKey":"62","provinceName":"甘肃省","provinceUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62.html"}
===================3=====================
{"cityCode":"620100000000","cityId":0,"cityKey":"6201","cityName":"兰州市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6201.html","countryList":[],"provinceKey":"62"}
Hibernate: insert into t_city (city_code, city_key, city_name, city_url, province_id, province_key) values (?, ?, ?, ?, ?, ?)
=================1=======================
{"cityCode":"620200000000","cityId":0,"cityKey":"6202","cityName":"嘉峪关市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6202.html","countryList":[],"provinceKey":"62"}
Hibernate: select province0_.province_id as province1_2_, province0_.province_code as province2_2_, province0_.province_key as province3_2_, province0_.province_name as province4_2_, province0_.province_url as province5_2_ from t_province province0_ where province0_.province_key=?
Hibernate: select citylist0_.province_id as province7_0_0_, citylist0_.city_id as city_id1_0_0_, citylist0_.city_id as city_id1_0_1_, citylist0_.city_code as city_cod2_0_1_, citylist0_.city_key as city_key3_0_1_, citylist0_.city_name as city_nam4_0_1_, citylist0_.city_url as city_url5_0_1_, citylist0_.province_id as province7_0_1_, citylist0_.province_key as province6_0_1_ from t_city citylist0_ where citylist0_.province_id=?
Hibernate: select countrylis0_.city_id as city_id7_1_0_, countrylis0_.country_id as country_1_1_0_, countrylis0_.country_id as country_1_1_1_, countrylis0_.city_key as city_key2_1_1_, countrylis0_.country_code as country_3_1_1_, countrylis0_.country_key as country_4_1_1_, countrylis0_.country_name as country_5_1_1_, countrylis0_.country_url as country_6_1_1_, countrylis0_.city_id as city_id7_1_1_ from t_country countrylis0_ where countrylis0_.city_id=?
==================2======================
{"cityList":[{"cityCode":"620100000000","cityId":18,"cityKey":"6201","cityName":"兰州市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6201.html","countryList":[],"provinceKey":"62"}],"provinceCode":"62","provinceId":28,"provinceKey":"62","provinceName":"甘肃省","provinceUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62.html"}
===================3=====================
{"cityCode":"620200000000","cityId":0,"cityKey":"6202","cityName":"嘉峪关市","cityUrl":"http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2016/62/6202.html","countryList":[],"provinceKey":"62"}
Hibernate: insert into t_city (city_code, city_key, city_name, city_url, province_id, province_key) values (?, ?, ?, ?, ?, ?)
2018-04-12 10:50:36.869  WARN 10708 --- [cTaskExecutor-5] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1062, SQLState: 23000
2018-04-12 10:50:36.869 ERROR 10708 --- [cTaskExecutor-5] o.h.engine.jdbc.spi.SqlExceptionHelper   : Duplicate entry '28' for key 'UK_itaid0sldsu35lk9mkp86b3q3'
2018-04-12 10:50:36.922 ERROR 10708 --- [cTaskExecutor-5] s.spider.govZone.event.CityEvent         : org.hibernate.exception.ConstraintViolationException: could not execute statement

 

 

错误原因:   unique = false ,我写了 true ,这里面的 false 是非唯一外键的意思 

@JsonIgnore
	@JSONField(serialize = false) 
	@ManyToOne(cascade = CascadeType. REFRESH, targetEntity = Province.class  , fetch = FetchType.EAGER)   
    @JoinColumn(name = "province_id",  unique = false, nullable = false, updatable = false ,insertable = true )  
    @NotFound(action=NotFoundAction.IGNORE)  
    @Cascade(value = { org.hibernate.annotations.CascadeType.SAVE_UPDATE })  
	private Province parentProvince;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

捐助开发者 

在兴趣的驱动下,写一个免费的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(支持支付宝和微信 以及扣扣群),没钱捧个人场,谢谢各位。

 

个人主页http://knight-black-bob.iteye.com/



 
 
 谢谢您的赞助,我会做的更好!

 

0
0
分享到:
评论

相关推荐

    MySQL导入sql脚本错误:2006 解决方法

    到如一些小脚本很少报错,但最近导入一个10+M的SQL脚本,却重复报错: Error occured at:2014-03-24 11:42:24 Line no.:85 Error Code: 2006 - MySQL server has gone away 最终找到原因,原来是MySQL导入大批量...

    SQLState错误码查表

    SQLSTATE 错误码是 SQL 语句执行过程中出现的错误代码,它们是标准化的错误代码,可以帮助开发者快速地定位和解决问题。本文档提供了 SQLSTATE 错误码的详细信息,包括错误代码、错误描述和解决方法。 SQLSTATE ...

    SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘a3b6420a-6’ for key ‘callId’

    "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'a3b6420a-6724-11ea-b2a3-d773d1d6999f' for key 'callId'\nThe SQL being executed was: INSERT INTO `ly_call` (`call_id`, `mobile`, ...

    DB2异常代码查询大全

    - **SQLCODE**:是DB2返回的一个整数值,用于表示SQL语句执行的状态。 - **SQLSTATE**:是DB2返回的一个五字符字符串,用于进一步细化SQLCODE的含义。 下面将列举一系列具体的异常代码及其含义: 1. **00000**:...

    sqlServer执行存储过程报错:42000,执行该sql即可

    sqlServer执行存储过程报错:42000 - [SQL Server]SQL Server 阻止了对组件“Ole Automation Procedures”的 过程“sys.sp_OACreate”的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以...

    SQL错误代码大全

    收集汇总了设计者在SQL 编程中所有出现的错误代码提示大全 希望对大家有所帮助

    解决SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded_runtimeerror怎么修复

    在MySQL数据库操作中,"SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded" 是一个常见的错误,它意味着在执行事务时,系统等待锁定资源的时间超过了预设的限制。这个错误通常发生在并发环境中,当...

    oracle数据库错误大全

    2. **错误解决方案**:除了错误解释,大全还会提供可能的解决策略,包括修改SQL语句、调整系统参数、检查硬件资源或更新数据库软件。 3. **案例分析**:可能会有实际的错误案例分析,帮助读者理解在特定环境下错误...

    oracle和Hibernated的结合

    8. **Criteria和HQL查询**:Hibernate提供了一种比SQL更高级的查询语言——Hibernate Query Language (HQL),以及Criteria API,它们允许开发者以面向对象的方式编写查询,避免了直接编写SQL的复杂性。 9. **性能...

    db2 错误码 大全

    - **SQLSTATE**: SQL警告状态 - **描述**: 表示SQL语句执行成功,但是存在一些警告信息。 ##### 3. 数据库表之间的关系不一致 - **SQLCODE**: +01201 - **SQLSTATE**: 545 - **描述**: 当数据库表之间的外键约束...

    DB2_SQLSTATE__消息异常

    SQLSTATE值是SQL标准中定义的一系列五字符代码,用于标识SQL语句执行的状态,包括成功或失败的具体原因。 #### SQLSTATE 值详解 在给出的部分内容中,列出了大量的SQLSTATE值及其简要含义。这里将对这些状态码进行...

    GBase 8s SQL 指南:教程

    **GBase 8s SQL 指南:教程** GBase 8s是南大通用数据系统有限公司开发的一款高性能、高可用性的国产化数据库管理系统,主要用于满足大规模数据处理和分析的需求。作为一款关系型数据库,它支持SQL(结构化查询语言...

    sql数据库死锁查询工具

    在SQL数据库管理中,死锁和阻塞是常见的问题,特别是在多用户环境下,它们可能导致系统性能下降甚至数据丢失。理解并有效地处理这些问题至关重要。本文将深入探讨“sql数据库死锁查询工具”及其在解决数据库死锁和...

    hyperf 3.0 查询sql server数据库 database扩展修改

    [ERROR] SQLSTATE[08001]: [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate] (SQL: ...

    php使用pdo连接报错Connection failed SQLSTATE的解决方法

    然而,有时在尝试连接MySQL数据库时,可能会遇到"Connection failed: SQLSTATE[HY000] [2002] No such file or directory"这样的错误提示。这个错误表明PHP无法找到与MySQL服务器通信的套接字文件,通常是由于`pdo_...

    MySQL Error Code文档手册

    在 MySQL 数据库中,错误代码可以分为五个级别:Error、Warning、Note、Info 和 Debug。其中,Error 是最严重的错误级别,表示 MySQL 数据库无法继续执行当前操作;Warning 表示 MySQL 数据库可以继续执行当前操作,...

    DB2不允许访问表空间

    DB2SQLError: SQLCODE=-290, SQLSTATE=55039, SQLERRMC=null, DRIVER=3.50.152 消息:不允许访问表空间。SQLCODE=-290, SQLSTATE=55039, DRIVER=3.50.152 ``` 此错误提示中的`SQLCODE=-290`和`SQLSTATE=55039`表明...

    DB2常用错误信息大全

    因为SQL语句引用一个远程对象,不能为该SQL语句执行EXPLAIN (+21801537) - **SQLCODE**: +21801537 - **SQLSTATE**: 01537 - **说明**: 当SQL语句涉及远程对象时,DB2无法生成该语句的EXPLAIN计划。这可能是因为...

    数据库MySQL表修复MyISAM

    数据库报错: SQLSTATE[HY000]: General error: 144 Table './db_jiangzi_video/cmf_jiangzi_items' is marked as crashed and last (automatic?) repair failed MySQL数据库表修复 MyISAM

    查询死锁数据库

    查询死锁数据库,当同一张表存在同时写,并且写的过程比较耗时,此时就会引起数据库死锁

Global site tag (gtag.js) - Google Analytics