Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isAutoId为true时,保存对象到db会报NullPointException异常 #724

Open
Bi6ocp opened this issue Mar 19, 2021 · 0 comments
Open

isAutoId为true时,保存对象到db会报NullPointException异常 #724

Bi6ocp opened this issue Mar 19, 2021 · 0 comments

Comments

@Bi6ocp
Copy link

Bi6ocp commented Mar 19, 2021

version:3.9.0

异常定位:
class: org.xutils.db.table.ColumnEntity
method: public Object getColumnValue(Object entity)
line:87

描述:
public Object getColumnValue(Object entity) {
Object fieldValue = getFieldValue(entity);
if (this.isAutoId && (fieldValue.equals(0L) || fieldValue.equals(0))) {
return null;
}
return columnConverter.fieldValue2DbValue(fieldValue);
}
当保存对象isAutoId为True时,对应字段为null时,导致fieldValue.equals(0L)报空指针异常
我对象中id的类型为Integer,所以有可能为空,这里使用equals(0)我猜想是不是自增类型只能用int呀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant