0

I'm using Mybatis query database

mysql table structure

enter image description here

parent_id default is ''

insert value is

enter image description here

Mybatis get value seem error? , parent_id should be "" instead null value?

enter image description here

0

1 Answer 1

1

if your value in DB is empty string and in your Java object is int/Integer, MyBatis cannot cast the column. To solve this, you can either:

  • Modify your database to make parent_id default null
  • Modify your select query and change column parent_id to IF(parent_id = '', null, parent_id) as parent_id
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.