Pit stepping record – after Lombok is annotated with builder, mybatis cannot recognize the correct type of field
After adding Lombok to the entity class, sometimes we will use @ builder annotation, so we don’t need to write too many set methods to define the attribute content, which makes our code more elegant. Once the @ builder annotation is added to the entity class, it will cause problems in our mybatis mapping database fields
The questions are as follows
org.springframework.dao.DataIntegrityViolationException: Error attempting to get column 'username' from result set. Cause: java.sql.SQLDataException: Cannot determine value type from string 'zhangsa'
; Cannot determine value type from string 'zhangsa'; nested exception is java.sql.SQLDataException: Cannot determine value type from string 'zhangsa'
note: when using @ builder annotation, a full parameter structure will be generated, resulting in the disappearance of no parameter structure
terms of settlement
- we can directly remove @ builder annotation, and there will be no problem for mybatis to query the database. We can generate parametric and nonparametric constructs in entity classes (you can add them manually or add annotations
@ allargsconstructor
, @ noargsconstructor
) OL>
if it is still abnormal, you should check whether your entity class and database type mapping do not correspond
Hold fireworks to seek life, poetic to seek love