主题:不写Order by,会自动生成,导致md文件里的order by重复

andnnl 7天前 32

数据库SQL Server 2012

调用 代码

SmsMobiles sm=new SmsMobiles();
sm.setUcuid("xxxx");
sm.setMinSendTime(new SimpleDateFormat("yyyy-MM-dd").parse("2019-05-01"));
PageQuery pageQuery = new PageQuery();
pageQuery.setParas(sm);
pageQuery.setOrderBy(null);
sqlManager.pageQuery("smsMobiles.sample", SmsMobiles.class,pageQuery);
System.out.println(pageQuery.getTotalPage());
System.out.println(pageQuery.getTotalRow());
System.out.println(pageQuery.getPageNumber());
List<SmsMobiles> list2 = pageQuery.getList();
System.out.println(JsonLib.toJson(list2));


md文件

sample
===
* 注释


	select 
	@pageTag(){
	    #use("cols")# 
	@}
	from TBL_SMS_MOBILES  where  #use("condition")#
	@pageIgnoreTag(){
	    order by SENDTIME desc
	@}

cols
===
	ID,UCUID,MOBILE,SENDTIME


condition
===

	1 = 1  
	@if(!isEmpty(ucuid)){
	 and ucuid=#ucuid#
	@}
	@if(!isEmpty(mobile)){
	 and MOBILE=#mobile#
	@}
	
	@if(!isEmpty(sendtime)){
	 and SENDTIME=#sendtime#
	@}
	@if(!isEmpty(minSendTime)){
     and SENDTIME>=#minSendTime#
    @}
    @if(!isEmpty(maxSendTime)){
     and SENDTIME<#maxSendTime#
    @}
	
	
	
	


生成的SQL,多了order by current_timestamp,数据库都没这个字段

┏━━━━━ Debug [smsMobiles.sample] ━━━
┣ SQL:	  select count(1) from TBL_SMS_MOBILES where 1 = 1 and SENDTIME>=? and UCUID=? 
┣ 参数:	 [2019-05-01 00:00:00.000, xxxx]
┣ 位置:	 com.jiaying.GeneratorMain.testSmsSelect(GeneratorMain.java:77)
┣ 时间:	 239ms
┣ 结果:	 [1]
┗━━━━━ Debug [smsMobiles.sample] ━━━


┏━━━━━ Debug [smsMobiles.sample_page] ━━━
┣ SQL:	  select ID,UCUID,MOBILE,SENDTIME from TBL_SMS_MOBILES where 1 = 1 and SENDTIME>=? and UCUID=? order by SENDTIME desc order by current_timestamp offset ? rows fetch next ? rows only 
┣ 参数:	 [2019-05-01 00:00:00.000, xxxx, 0, 20]
┣ 位置:	 com.jiaying.GeneratorMain.testSmsSelect(GeneratorMain.java:77)
┗━━━━━ Debug [ ERROR:关键字 'order' 附近有语法错误。] ━━━

andnnl 7天前

Spring Boot工程

<dependency>
	<groupId>com.ibeetl</groupId>
	<artifactId>beetl-framework-starter</artifactId>
	<version>1.1.81.RELEASE</version>
</dependency>
andnnl 7天前

image.png

加了this.getOrderBy(),导致匹配不上