In MyBatis, if it is too unfriendly to write a full name for each configuration class, we can no longer need to specify the complete package name by configuring the alias in the master configuration file.
Basic usage of aliases:
<configuration>
<typeAliases>
<typealias type= "com.domain.Student" alias= "Student"/>
</typeAliases> ...
</configuration>
But if every entity class is a bit of a hassle, then we can specify the package name directly, MyBatis will automatically scan the JavaBean under the specified packet, and the default setting is an alias, the default name is: JavaBean An unqualified class name with the first letter lowercase as its alias (in fact, the alias is not case-insensitive). You can also customize aliases in JavaBean plus annotations @alias, for example: @Alias (Student)
<typeAliases>
<package name= "Com.domain"/>
</typeAliases>
Thus, in Mapper we don't have to write the full name of the class every time we configure it, but with one exception, that is namespace.
Namespace Property
In MyBatis, the namespace in mapper is used to bind the DAO interface, which is interface-oriented programming.
The advantage of this is that when the namespace is used, the interface implementation class can not be written, and the business logic will find the corresponding SQL statement for the corresponding data processing directly through this binding.
Student = (student) session.selectone ("Com.domain.Student.selectById", New Integer (10));
<mapper namespace= "Com.domain.Student" >
<select id= "Selectbyid" parametertype= "int" resulttype= " Student ">
select * from student where Id=#{id}
</select>
</mapper>