One : Omnipotent Map
hypothesis , Our entity classes , Or a table in a database , Too many fields or parameters , We should consider using Map!
Why does it show up Map?
When we change the password , Just one id And the password , At this time, it's a little too big for us to pass on an entity ( In the case of entities, we need to assign values to all the attributes of the entities ) So let's pass on a map If we gather, we only need to pass one id And the password . as follows :(Map If we do, we'll be at the bottom userid You can do it again map I'll call you any name I want ( It refers to us key value ), When we're in user Entity class is not allowed. It must have the same attribute name as our entity )
test :
Map Pass parameters , Directly in sql Remove from key that will do ! 【parameterType="map"}】
Object passing parameters , Directly in sql Just take the attribute of the object from ! 【parameterType="Object】
With only one basic type parameter , Can be directly in sql Remove from !( such as int)
Multiple parameters with Map, Or annotation !
Two : Fuzzy query
How to write fuzzy query ?
1.java When the code executes , Pass wildcard % %
2. stay sql Using wildcards in stitching !
( prevent sql The way of Injection , Is to put our ? It's written here to prevent 1or1=1 Such code injection )