<where>
<if test="userName != null and userName != ''">
and user_name like concat('%',#{userName},'%')
</if>
<if test="suerEmail != null and userEmail != ''">
and user_email=#{userEmail}
</if>
</where>
当if条件都不满足时,where元素中没有内容,所以在SQL中不会出现where。如果if满足条件where中的内容出现在,并会自动去除结尾

<set>
<if test="userName != null and userName != ''">
user_name=#{userName},
</if>
<if test="userEmail != null and userEmail != ''">
user_Email=#{userEmail},
</if>
id=#{id},
</set>
使用set时要注意,最好把必选项放在最后并加"," set会去除","的。

where id in
<foreach collection="list" open="(" close=")" separator="," item="id" index="i">
#{id}
</foreach>
collection的取值取决于传入的参数类型。
private Object warpCollection(final Object object){
if (onject instanceof Object) {
StrictMap<Object> map=new StrictMap<Object>();
map.put("collection",object);
if (object instanceof List){
map.put("list",object);
}
return map;
}
} else if(object!=null && object.getClass().isArray()){
StrictMap<Object> map=new StrictMap<Object>();
map.put("array",object);
return map;
}
return object;
}

final 修饰符的作用
the final keyword in java is used to restrict the user.the java final keyword can be used in many context.final can be:
variable
method
class
1 stop value change
2 stop method overridding
3 stop class inheritance

1) example of final variable
public class HelloWorld{

public static void main(String []args){
Bike9 obj=new Bike9();
obj.run();
}

}
class Bike9{
final int speedlimit=90;//final variable
void run(){
speedlimit=400;
}
}
oupput:error: cannot assign a value to final variable speedlimit speedlimit=400;

2) example of final method
if you make any mwthod as final,you can not override it.

public class HelloWorld{
public static void main(String []args){
Honda honda=new Honda();
honda.run();
}
}
class Bike9{
final void run(){System.out.println("running");}
}
class Honda extends Bike9{
void run(){System.out.println("running safely with 100kmph");}
}

output:run() in Honda cannot override run() in Bike9 void run(){System.out.println("running safely with 100kmph");}

3) java final class

if you make any class as final,you cannot extend it.

final class Bike9{
void run(){System.out.println("running");}
}
class Honda extends Bike9{
void run(){System.out.println("running safely with 100kmph");}
}

output: error: cannot inherit from final Bike9

Q) Is final method inherited?
Ans) Yes, final method is inherited but you cannot override it.

Q) What is blank or uninitialized final variable?
A final variable that is not initialized at the time of declaration is known as blank final variable.

If you want to create a variable that is initialized at the time of creating object and once initialized may not be changed, it is useful.

It can be initialized only in constructor.

Que) Can we initialize blank final variable?
Yes, but only in constructor.

static blank final variable
A static final variable that is not initialized at the time of declaration is known as static blank final variable. It can be initialized only in static block.

Q) What is final parameter?
If you declare any parameter as final, you cannot change the value of it.

Q) Can we declare a constructor final?
No, because constructor is never inherited.

instanceof
The java instanceof operator is used to test whether the object is an instance of the specified type(class or subclass or interface)

The instanceof in java is also known as type comparison operator because it compares the instance with type. it returns either true or flase. if we apply the instanceof operator with any vriable that has null value,it returns false.

Example

downcast 向下类型转化
interface Printable{}
class A implements Printable{
public void a(){
System.out.println("a method");
}

}
class B implements Printable{
public void b(){
System.out.println("b method");
}
}

class Call{
void invoke(Printable p){//upcasting
if(p instanceof A){
A a=(A)p;//Downcasting
a.a();
}
if(p instanceof B){
B b=(B)p;//Downcasting
b.b();
}

}
}//end of Call class

class Test4{
public static void main(String args[]){
Printable p=new B();
Call c=new Call();
c.invoke(p);
}
}

output:b method

Map
Java List Interface

List Interface is the subinterface of collection.It contains methods to insert and deleete elements in index basic.It is a factory of ListIterator interface.

List Interface declaration

public interface List<E> extends Collection<E>

Methods of Java List Interface

void add(int index,Object element)
boolean addAll(int index,Collection c)
Object get(int index)
Object set(int index,Object element)
Object remove(int index)
ListIterator listIterator()
ListIterator listIterator(int index)

Java ListIterator Interface

ListIterator Interface is used to traverse element in forword and backword direction.

ListIteartor Interface Declaration

public interface ListIterator<E> extends Iterator<E>

Methods of ListIterator Interface

boolean hasNext()
Object nect()
boolean hasPrevious()
Object previous()

Java Map Interface

A map contains values on the basic of key i.e key and value pair.Each key and value pair is known as an entry.Map contains only unioue keys.

Map is useful if you have to search,update or delete elements on the basic of key

Useful methods of Map interface

Object put(Object key,Object value)
void put(Map map)
Object remove(Object key)
boolean containsKey(Object key)
Set ketSet()
Set entrySet()

Map.Entry Interface

Entry is the sub interface of Map.So we will be accessed it by Map.Entry name.It provides methods to get key and value.

Methods of Map.Entry interface

Object getKey()
Object getValue()

Java Map Example

Map<Integer,String> map=new HashMap<Integer,String>()
map.put(100,"Amit)
map.put(101,"Vijay")
map.put(102,"Rahui")
for(Map.Entry m:map.entrySet()){
System.out.println(m.getKey()+" "+m.getValue())
}

判断是否为数组类型的方法
1.instanceof
2.object.getClass().isArray()

mybatis和java一些知识记录的更多相关文章

  1. Java实用知识记录 —— 截止到Java8

    记录Java实用知识点,截止(包括)到Java8,只作概要的描述,不涉及到具体细节.变量:int.long的包装类支持无符号位操作,即其在内存中的位可以用来全部表示正数."_"可以 ...

  2. java面试知识记录

    1.数据库 (1)数据库优化      面试求职:数据库常见面试题(数据库优化思路) 数据库优化方案整理 (2)数据库的事务 MySQL——事务(Transaction)详解 MySQL 事务 2.设 ...

  3. Java基础知识(壹)

    写在前面的话 这篇博客,是很早之前自己的学习Java基础知识的,所记录的内容,仅仅是当时学习的一个总结随笔.现在分享出来,希望能帮助大家,如有不足的,希望大家支出. 后续会继续分享基础知识手记.希望能 ...

  4. Java并发知识总结,超详细!

    首先给大家分享一个github仓库,上面放了200多本经典的计算机书籍,包括C语言.C++.Java.Python.前端.数据库.操作系统.计算机网络.数据结构和算法.机器学习.编程人生等,可以sta ...

  5. DataBase MongoDB基础知识记录

    MongoDB基础知识记录 一.概念: 讲mongdb就必须提一下nosql,因为mongdb是nosql的代表作: NoSQL(Not Only SQL ),意即“不仅仅是SQL” ,指的是非关系型 ...

  6. 学习Spring必学的Java基础知识(2)----动态代理

    Spring AOP使用动态代理技术在运行期织入增强的代码,为了揭示Spring AOP底层的工作机理,有必要对涉及到的Java知识进行学习.Spring AOP使用了两种代理机制:一种是基于JDK的 ...

  7. Java基础知识回顾之七 ----- 总结篇

    前言 在之前Java基础知识回顾中,我们回顾了基础数据类型.修饰符和String.三大特性.集合.多线程和IO.本篇文章则对之前学过的知识进行总结.除了简单的复习之外,还会增加一些相应的理解. 基础数 ...

  8. Java基础知识总结(超级经典)

    Java基础知识总结(超级经典) 写代码: 1,明确需求.我要做什么? 2,分析思路.我要怎么做?1,2,3. 3,确定步骤.每一个思路部分用到哪些语句,方法,和对象. 4,代码实现.用具体的java ...

  9. Java开发知识之Java数组

    Java开发知识之Java数组 一丶数组简介 首先,不管是Java 还是 C++ 还是其它语言.都有数组. (有可能叫法不同) 数组简而言之就是存储一段连续相同数据类型的数据结构 在Java中数组可以 ...

随机推荐

  1. Redis本地集群搭建(5版本以上)

    Redis本地集群搭建(5版本以上) 2019年11月3日10:05:48 步骤 1.下载安装Redis的安装包 2.复制5份,一共6份Redis的解压安装版,修改每个Redis节点的端口并开启节点 ...

  2. Android开发 AAC的ADTS头解析[转载]

    原文地址:https://www.jianshu.com/p/b5ca697535bd 1. ADTS(Audio Data Transport Stream)头之于AAC AAC音频文件的每一帧都由 ...

  3. [转]Redis实现缓存,你应该懂的哪些思路!

    场景一:类似于微博,实现关注和被关注功能. 思路: 对每个用户使用两个集合类型键,用来存储关注别人的用户和被该用户关注的用户.当用户A关注用户B的时候,执行两步操作: sadd user:A B sa ...

  4. 关于FR4板一些重复的数据

    介电常数:4.2-4.7 信号传输速度:表层 140~170 ps/inch, 内层 180 ps/inch

  5. [JZOJ6271] 2019.8.4【NOIP提高组A】锻造

    题目 题目大意 武器的每个级别有固定的两种属性\(b_i\)和\(c_i\) 可以用\(a\)的代价得到一把\(0\)级的武器. 可以将\(x\)级武器和\(y=\max(x-1,0)\)级武器融合锻 ...

  6. 【JZOJ6293】迷宫

    description analysis 有没有想起[\(NOIP2018\)]保卫王国? 设\(tr[t][x][y]\)表示线段树上的\(t\)节点代表的区间,从最左边列的\(x\)行到最右边列\ ...

  7. xkl的各种沙雕低错

    13,特判判掉20分算不算? 12,linux用c++11编译: g++ -std=c++11 -o a a.cpp g++ a.cpp -std=c++11 -o a //g++ a.cpp -st ...

  8. duilib教程之duilib入门简明教程11.部分bug

    一.WindowImplBase的bug    在第8个教程[2013 duilib入门简明教程 -- 完整的自绘标题栏(8)]中,可以发现窗口最大化之后有两个问题,    1.最大化按钮的样式还是没 ...

  9. 使用treeNMS管理及监控Redis

    Redis做为现在web应用开发的黄金搭担组合,大量的被应用,广泛用于存储session信息,权限信息,交易作业等热数据.做为一名有10年以上JAVA开发经验的程序员,工作中项目也是广泛使用了Redi ...

  10. Ubunto 无法连接ssh客服端

    解决办法: (1)查看ip地址是否冲突 我在单位的虚拟机ip地址是192.168.14.85,与其它机器冲突了.改成了192.168.14.83   (2)关闭Ubuntu14.04的防火墙 root ...