怎么用ps做网站幻灯片,全国企业信息管理查询系统官网,网站登陆注册怎么做,石家庄哪里可以做网站代码下载
解决字段名与属性名不一致
①使用别名emp_name empName解决字段名和属性名不一致
select idgetAllEmpOld resultTypeEmp!--①使用别名emp_name empName解决字段名和属性名不一致--select eid,emp_name empName,age,sex,em…代码下载
解决字段名与属性名不一致
①使用别名emp_name empName解决字段名和属性名不一致
select idgetAllEmpOld resultTypeEmp!--①使用别名emp_name empName解决字段名和属性名不一致--select eid,emp_name empName,age,sex,email from t_emp;/select②在全局配置文件中添加全局配置
settings!-- 将_自动映射为驼峰emp_nameempName--setting namemapUnderscoreToCamelCase valuetrue//settings③使用resultMap
!--resultMap设置自定义映射关系id唯一标识type设置映射关系中的实体类类型id设置主键属性property设置映射关系中的属性名必须是type属性所设置的实体类类型中的属性名column设置映射关系中的字段名必须是SQL语句查询出的字段名--resultMap idempResultMap typeEmpid propertyeid columneid/id propertyempName columnemp_name/id propertyage columnage/id propertysex columnsex/id propertyemail columnemail//resultMap!--③使用resultMap解决字段名和属性名不一致--select idgetAllEmp resultMapempResultMapselect * from t_emp;/select多对一映射关系
①级联属性赋值 resultMap idempAndDeptResultMapOne typeEmpid propertyeid columneid/id propertyempName columnemp_name/id propertyage columnage/id propertysex columnsex/id propertyemail columnemail/id propertydept.did columndid/id propertydept.deptName columndept_name//resultMap!--Emp getEmpAndDept(Param(eid) Integer eid);--select idgetEmpAndDept resultMapempAndDeptResultMapOneselect * from t_emp left join t_dept on t_emp.did t_dept.did where t_emp.eid#{eid}/select②使用association
resultMap idempAndDeptResultMapTwo typeEmpid propertyeid columneid/id propertyempName columnemp_name/id propertyage columnage/id propertysex columnsex/id propertyemail columnemail/!-- association处理多对一的映射关系javaType该属性的类型--association propertydept javaTypeDeptid propertydid columndid/id propertydeptName columndept_name//association/resultMap!--Emp getEmpAndDept(Param(eid) Integer eid);--select idgetEmpAndDept resultMapempAndDeptResultMapTwoselect * from t_emp left join t_dept on t_emp.did t_dept.did where t_emp.eid#{eid}/select
mapper namespacecom.lotus.mybatis.mapper.DeptMapper!--Dept getEmpAndDeptByStepTwo(Param(did) Integer did);--select idgetEmpAndDeptByStepTwo resultTypeDeptselect * from t_dept where did#{did}/select
/mapper③分步查询
resultMap idempAndDeptByStepResultMap typeEmpid propertyeid columneid/id propertyempName columnemp_name/id propertyage columnage/id propertysex columnsex/id propertyemail columnemail/!--select设置分步查询的SQL唯一标识(namespace,SQLID或mapper接口的全类名.方法名)column设置分步查询的条件fetchType(eager|lazy)当开启全局延迟加载后通过此属性手动控制延迟加载的效果,eager表示立即加载--association propertydept selectcom.lotus.mybatis.mapper.DeptMapper.getEmpAndDeptByStepTwocolumndid fetchTypeeager/association/resultMap!-- Emp getEmpAndDeptByStepOne(); --select idgetEmpAndDeptByStepOne resultMapempAndDeptByStepResultMapselect * from t_emp where eid#{eid}/selectpublic interface EmpMapper {
/*** 通过分步查询查询员工以及员工所对应部门信息* 第一步查询员工信息*/Emp getEmpAndDeptByStepOne(Param(eid) Integer eid);}public interface DeptMapper {/*** 通过分步查询查询员工以及员工所对应部门信息* 第一步通过did查询员工对应的部门信息*/Dept getEmpAndDeptByStepTwo(Param(did) Integer did);
}一对多映射关系
①使用collection标签 resultMap iddeptAndEmpResultMap typeDeptid propertydid columndid/id propertydeptName columndept_name/collection propertyemps ofTypeEmpid propertyeid columneid/id propertyempName columnemp_name/id propertyage columnage/id propertysex columnsex/id propertyemail columnemail//collection/resultMap!--Dept getDeptAndEmp(Param(did) Integer did);--select idgetDeptAndEmp resultMapdeptAndEmpResultMapselect * from t_dept left join t_emp on t_dept.did t_emp.did where t_dept.did#{did}/select/*** 获取部门及部门中所有员工信息*/Dept getDeptAndEmp(Param(did) Integer did);
//测试代码Testpublic void testGetDeptAndEmp() {SqlSession sqlSession SqlSessionUtils.getSqlSession();DeptMapper mapper sqlSession.getMapper(DeptMapper.class);Dept dept mapper.getDeptAndEmp(1);System.out.println(dept);}②使用分步查询
!---DeptMapper.xml
resultMap iddeptAndEmpByStepResultMap typeDeptid propertydid columndid/result propertydeptName columndept_name/collection propertyempsselectcom.lotus.mybatis.mapper.EmpMapper.getDeptAndEmpByStepTwocolumndid/collection/resultMap!--Dept getDeptAndEmpByStepOne(Param(did) Integer did);--select idgetDeptAndEmpByStepOne resultMapdeptAndEmpByStepResultMapselect * from t_dept where did#{did}/select
!-- EmpMapper.xml --
!--ListEmp getDeptAndEmpByStepTwo(Param(did) Integer did);--select idgetDeptAndEmpByStepTwo resultTypeEmpselect * from t_emp where did#{did}/select//----DeptMapper
/*** 分步查询①查询部门信息*/Dept getDeptAndEmpByStepOne(Param(did) Integer did);
//----EmpMapper
/*** 分步查询②根据did查询员工信息*/
ListEmp getDeptAndEmpByStepTwo(Param(did) Integer did);//测试代码Testpublic void testGetDeptAndEmpStep() {SqlSession sqlSession SqlSessionUtils.getSqlSession();DeptMapper mapper sqlSession.getMapper(DeptMapper.class);Dept dept mapper.getDeptAndEmpByStepOne(1);System.out.println(dept);}