Dynamic sql processing of Mybatis

SQL statements of special symbols

Special symbols

<=

>=

&

replace

&lt;

&lt;=

&gt;

&gt;=

&amp;

&apos;

&quot;

 

Dynamic demand sql statement

Concept: mapping file sql statement is not fixed, according to the number of parameters passed, sql statement needs to be changed dynamically.

For example: the demand for multi-criteria query

 

 

According to sql statement users to fill in different conditions can lead to execution are not the same

select * from tuser ;

select * from tuser where id = ?

select * from tuser where name = ?   等等

From the above needs to see: sql statement can not be finalized, in this demand below, Mybatis create a new label, can be used to determine, circulation and other sql tag.

Commonly used dynamic tag of Mybatis

Using Mybatis generated entity class tools required, DAO interface mapping file

The multi-criteria query

or

 

Guess you like

Origin www.cnblogs.com/Tunan-Ki/p/11780044.html