Discussion on output parameters of mybatis

Fairy-KunKun 2022-05-14 14:38:00 阅读数:574

discussionoutputparametersmybatis

situation :

(1) Returns a simple value ( Single value )

resultType

Total number of query departments

(2) Return entity class

If the attribute name in the entity class is the same as the field in the table ( Ignore case ), Then use resultType

If the attribute name in the entity class is different from the field in the table ( Ignore case ), Then use resultMap

create table emp(

   t_empno int primary key,

 t_ename varchar(20),

 t_deptno int

) engine=Innodb;

Query employee data according to employee number

Definition Emp.xml

register Emp.xml

test

Why null?

You should use resultMap

The right way :

test

版权声明:本文为[Fairy-KunKun]所创,转载请带上原文链接,感谢。 https://javamana.com/2022/134/202205141429154153.html