Mybatis mapping file mapper (b)

EDITORIAL

The film is still Silicon Valley curriculum resources from education. The following courses are free connection, the teacher is very small, can be used as mybatis comprehensive learning materials
https://ke.qq.com/webcourse/index.html#cid=199779&term_id=100236742&taid=1162819445918819&vid=i1417aduxlz best from the first started watching

Deletions changed parameters and return values

  1. parameterType can be omitted
  2. Interface return value can be returned Integer, Long, Boolean, int, long, boolean, void, mybatis has been good for us encapsulates
    Here Insert Picture Description
<insert id="addRow">
	
</insert>

public Boolean addRow(Elemployee emp);

Get the value of increment primary key

Premise: a database primary key is auto-incremented

mysql

Here Insert Picture Description

oracle

Here Insert Picture Description
Here Insert Picture Description

mybatis parameters

A single parameter

Here Insert Picture Description
What single parameter may # {}

Multiple parameters

A plurality of parameters, mybatis encapsulated into a frame parameters will map, the value from the map. key to param1, param2 or @Param ( "emp") custom aliases. value is our parameter values
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

The difference between the $ and #

Here Insert Picture Description
Here Insert Picture Description

Here Insert Picture Description

resultTupe return value

Returns a collection of

Here Insert Picture Description
resultType write the elements of the collection type Employee
Here Insert Picture Description

The return value map

Returns a key-value

Here Insert Picture Description
resultType = map mybatis we already had a map package is an alias for
Here Insert Picture Description
the result:
Key column name, value is the value
Here Insert Picture Description

Back plurality of key-value

Id as the key to
Here Insert Picture Description
Here Insert Picture Description
the name of the whole class resultType = Employee of
Here Insert Picture Description
the results:
key value for the id
value for the value of the object Employe

Here Insert Picture Description

resultMap return value

the result is a custom set resultMap

resultMap is a very important concept, the next section will focus on it

Here Insert Picture Description
Here Insert Picture Description

Published 31 original articles · won praise 32 · views 8104

Guess you like

Origin blog.csdn.net/qq_40905403/article/details/101033670