Autumn Recruitment Interview Questions Series - - -Java Engineer (4)

Foreword: At the end of July and the beginning of August, the autumn recruitment officially started, and the company will release a large number of full-time and internship positions. In order to help the autumn recruits, the seniors have compiled a series of interview questions for the autumn recruits here, so the friends don't need to be too anxious, I believe you will be able to perform well and receive offers from your favorite company~~

The content covers: Java, MyBatis, ZooKeeper, Dubbo, Elasticsearch, Memcached, Redis, MySQL, Spring, Spring Boot, Spring Cloud, RabbitMQ, Kafka, Linux and other technology stacks

Recommended autumn recruitment column:

                            Alibaba interview questions

                                Autumn recruitment interview questions

 Table of contents

MyBatis Interview Questions

16. In addition to the common select|insert|updae|delete tags, what other tags are there in the Xml mapping file?

17. In the Xml mapping file of Mybatis, can the IDs of different Xml mapping files be repeated?

18. Why is Mybatis a semi-automatic ORM mapping tool? How is it different from fully automatic?

19. One-to-one, one-to-many association query?


MyBatis Interview Questions

16. In addition to the common select|insert|updae|delete tags, what other tags are there in the Xml mapping file?

Answer: <resultMap>, <parameterMap>, <sql>, <include>, <selectKey>, plus 9 tags of dynamic sql, among which is the sql fragment tag, the sql fragment is introduced through the <include> tag, and <selectKey> is Auto-incrementing primary key generation strategy tags are not supported.

17. In the Xml mapping file of Mybatis, can the IDs of different Xml mapping files be repeated?

For different Xml mapping files, if the namespace is configured, the id can be repeated; if the namespace is not configured, the id cannot be repeated;

The reason is that namespace+id is used as the key of Map. If there is no namespace, there will be id left, then duplicate id will cause data to overwrite each other. With the namespace, the natural id can be repeated. If the namespace is different, the namespace+id will naturally be different.

18. Why is Mybatis a semi-automatic ORM mapping tool? How is it different from fully automatic?

Hibernate is a fully automatic ORM mapping tool. When using Hibernate to query related objects or related collection objects, it can be obtained directly according to the object relationship model, so it is fully automatic. Mybatis needs to manually write sql when querying associated objects or associated collection objects, so it is called a semi-automatic ORM mapping tool.

19. One-to-one, one-to-many association query?

namespace="com.lcb.mapping.userMapper">

id="getClass"parameterType="int"

resultMap="ClassesResultMap">

select * from class c,teacher t where c.teacher_id=t.t_id andc.c_id=#{id}

type="com.lcb.user.Classes"id="ClassesResultMap">

property="id"column="c_id"/>

property="name"column="c_name"/>

property="teacher"

javaType="com.lcb.user.Teacher">

property="id"column="t_id"/>

property="name"column="t_name"/>

id="getClass2"parameterType="int"

resultMap="ClassesResultMap2">

select * from class c,teacher t,student s where c.teacher_id=t.t_idand c.c_id=s.class_id and c.c_id=#{id}

type="com.lcb.user.Classes"id="ClassesResultMap2">

property="id"column="c_id"/>

property="name"column="c_name"/>

property="teacher"

javaType="com.lcb.user.Teacher">

property="id"column="t_id"/>
<resultproperty="name"column="t_name"/></association>
<collectionproperty="student"
ofType="com.lcb.user.Student">
<idproperty="id"column="s_id"/>
<resultproperty="name"column="s_name"/></collection>
</resultMap></mapper>

Follow the bloggers and don't get lost. Senior Ye Qiu will take you to the Qiuzhao Expressway~~

Supongo que te gusta

Origin blog.csdn.net/m0_63722685/article/details/126359766
Recomendado
Clasificación