Default value handling issues for entity queries

Entity query default value processing problem:

Since entity types have different default values, directly using the native entity query (except for the general mapper (removing any default value)) will take the default value as the query condition (using the String object type defaults to null No effect,
int default 0 has effect)

1, how many escape conditions are there
Example = new Example(TbPowerGroup.class);
example.createCriteria().andLike("flag", "%"+cusTradeKind+"%");
example.setOrderByClause("levelCode asc");
List<TbPowerGroup> list= tbPowerGroupMapper.selectByExample(example);


2, the general mapper automatically goes to the default null, all strings, no int, etc., so the default goes to
OpmUser opmUserNew = new OpmUser();
opmUserNew.setCode(code);
user = opmUserMapper.selectOne(opmUserNew);

==>  Preparing: SELECT ID,CODE,PASSWORD,NAME,TELEPHONE,EMAIL,ORGANID,VALID,MEMO,LEVEL1,LAST_LOGIN_DATE AS lastLoginDate,LAST_LOGIN_TIME AS lastLoginTime,ONLINE_MARK AS onlineMark,ONLINE_IP AS onlineIp,SESSIONID FROM OPM_USER WHERE CODE = ?
==> Parameters: system(String)==>  Preparing: SELECT ID,CODE,PASSWORD,NAME,TELEPHONE,EMAIL,ORGANID,VALID,MEMO,LEVEL1,LAST_LOGIN_DATE AS lastLoginDate,LAST_LOGIN_TIME AS lastLoginTime,ONLINE_MARK AS onlineMark,ONLINE_IP AS onlineIp,SESSIONID FROM OPM_USER WHERE CODE = ?
==> Parameters: system(String)



SESSIONID  改为int  默认的0就作为条件了(实体查询只会省略null的)

==>  Preparing: SELECT ID,CODE,PASSWORD,NAME,TELEPHONE,EMAIL,ORGANID,VALID,MEMO,LEVEL1,LAST_LOGIN_DATE AS lastLoginDate,LAST_LOGIN_TIME AS lastLoginTime,ONLINE_MARK AS onlineMark,ONLINE_IP AS onlineIp,SESSIONID FROM OPM_USER WHERE SESSIONID = ?
==> Parameters: 0(Integer)



3,直接用JdbcTemplate的sql查询

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326242791&siteId=291194637