select * from tb_stu
and s_name like '%${name}%'
and s_email=#{email}
foreach
insert into tb_stu(s_name, s_age, s_birth, s_email, s_schid)
values
(#{s.name},#{s.age},#{s.birth},#{s.email},#{s.schid})
insert into tb_stu(s_name, s_age, s_birth, s_email, s_schid)
(select #{s.name},#{s.age},#{s.birth},#{s.email},#{s.schid} )
trim
select * from tb_stu
and s_name like '%${name}%'
and s_email=#{email}
chose…when.otherwise
select * from tb_stu
and s_name like '%${name}%'
and s_email=#{email}
13. 一对一和一对多的关联查询?
association
select
s_id, s_name, s_age, s_birth, s_email, s_schid,
sch.id, sch.name, sch.phone,sch.info
from tb_stu s left join school sch
on s.s_schid = sch.id where s.s_id=#{id}
collection:一对多
select sch.id, sch.name, sch.phone,sch.info,
s_id, s_name, s_age, s_birth, s_email, s_schid
from school sch left join tb_stu s on s.s_schid = sch.id
where sch.id=#{id}
public abstract class BaseBuilder{
protected final Configuration configuration;
protected final TypeAliasRegistry typeAliasRegistry;
protected final TypeHandlerRegistry typeHandlerRegistry;
public BaseBuilder(Configuration configuration) {
this.configuration = configuration;
this.typeAliasRegistry = this.configuration.getTypeAliasRegistry();
this.typeHandlerRegistry = this.configuration.getTypeHandlerRegistry();
}
Mapped Statements collection does not contain value for xxx
原因: SQL语句映射文件中没有DAO层调用的语句。
A query was run and no Result Maps were found for the Mapped Statement ‘com.et2203.queryById’. It’s likely that neither a Result Type nor a Result Map was specified.
原因:执行的是查询语句,没有resultType或者resultMap。
Caused by: org.apache.ibatis.binding.BindingException: Parameter ‘start’ not found. Available parameters are [arg1, arg0, param1, param2]