当前位置:网站首页>Record the nth SQL exception
Record the nth SQL exception
2022-07-27 02:26:00 【Current affairs reader hjj】
List of articles
- Record No. N Time SQL abnormal
- Mapper How to write the interface
- Service Interface writing
- ServiceImpl Implementation class writing
- After modification Mapper How to write the interface
- After modification Service Interface writing
- After modification ServiceImpl Implementation class writing
- Integer The object type allows the return value to be null, Solve the problem successfully .
- In high performance MySQL It is recommended to set a default value for the field as far as possible , Try not to leave the field value blank , Avoid all kinds of things related to null It's abnormal , Unless there is a special need .
- Small about entity classes bug
- My learning forum
Record No. N Time SQL abnormal

The most important sentence :Mapper method 'com.handsome.dao.BlogMapper.countBlogViews attempted to return null from a method with a primitive return type (int).
The expected value is int type , The type of return is null, I'm sorry , direct GG. Why did you report this error ?
Mapper How to write the interface

Service Interface writing

ServiceImpl Implementation class writing

Expected return values are int Basic data type , But back null, Result in an error , therefore SQL Methods of should be changed to object type .
After modification Mapper How to write the interface

After modification Service Interface writing

After modification ServiceImpl Implementation class writing

Integer The object type allows the return value to be null, Solve the problem successfully .
In high performance MySQL It is recommended to set a default value for the field as far as possible , Try not to leave the field value blank , Avoid all kinds of things related to null It's abnormal , Unless there is a special need .
Small about entity classes bug
If the attribute of the entity class is defined by the basic data type , Updated in the database , Will not be null The value of is updated into the database . for example :int The defined value defaults to 0 , When the database is updated 0 Update into the database , Cause data statistics error .
Entity classes should use int The wrapper class Integer,Ingeter yes int The wrapper class ,int The initial value for the 0,Ingeter The initial value for the null, This field will not be updated when updating , Avoided bug Appearance .
My learning forum
HandsomeForum: use Java Prepared Learning Forum , Build our own circle !(http://huangjunjie.vip:66)
The article links :http://huangjunjie.vip:66/question/read/ket3qpjghv1yb6mpqc
边栏推荐
猜你喜欢
![Today, let's talk about escape characters [cute new version]](/img/8a/5d60d362c5de42fac0b9abd0754241.png)
Today, let's talk about escape characters [cute new version]

静态路由基本配置 实现全网可达

ESP8266Wi-Fi接入云平台

Find a specific number in an ordered array
![[C language] relevant distinction between strlen and sizeof](/img/c0/c026818692a01c1867771434e90da8.png)
[C language] relevant distinction between strlen and sizeof

Nb-iot networking communication

全连MGRE与星型拓扑MGRE

全网显示 IP 归属地,是怎么实现的?

【C语言】strlen与sizeof相关区分

Ogeek meetup phase I, together with cubefs, is hot
随机推荐
MySQL课程2.表的各种查询
MySQL course 1. simple command line -- simple record welcome to supplement and correct errors
Esp8266wi fi access cloud platform
Codeforces Round #810 (Div. 2), problem: (B) Party
First knowledge of C language (2)
Interesting C language
[C language] relevant distinction between strlen and sizeof
Experiment exercise of two-layer packaging technology (HDLC, ppp--pap\chap, GRE)
Hcip OSPF comprehensive experiment
Codeforces Round #796 (Div. 2), problem: (1688C) Manipulating History
CF 1333C Eugene and an array
记录HandsomeBlog的star用户
【C语言程序设计】分支结构
Today, let's talk about escape characters [cute new version]
(题意+详细思路+加注释代码) Codeforces Round #805 (Div. 3)F. Equate Multisets
C language -- nesting of relational and logical operators, if statements, switch statements, and branch structures
Use of golang - sync package (waitgroup, once, mutex, rwmutex, cond, pool, map)
动态路由配置
静态路由综合实验
HCIP-第二天