1: Give a @table annotation, give a default table name, do not write can also, but to hump turn underline match
@Table (name = "Conf_default")
2: Add non-table field parameters to accept dynamic Table name parameters
@Transient//declaring non-database fields
Private String TableName;
3: Implement interface Idynamictablename, implement the following method, the property in 2 is the return table name
Public String Getdynamictablename () { return tableName;}
This is said in the source code:
/**@author @since 2015-10-28 22:20 * * Public Interface idynamictablename {/**@return*/String Getdynamictablename ();}
4: Query the table dynamically using the following method
New Condition (Confdefault. Class); Condition.settablename ("conf"); // dynamic configuration indicates Condition.createcriteria (). Andcondition ("' key ' like '%1% '"). Andcondition ("' value ' like '%1% '"); Condition.setorderbyclause ("' Key ' desc"); List<ConfDefault> list = confdefaultmapper.selectbyexample (condition);
This is how the generated SQL is:
'%1% ' and ' value ' like '%1% ') Order by ' key ' desc
MyBatis Universal Mapper Dynamic query table name