Home > Back-end >  Mybatis physical paging rowbounds temporary table alias problem
Mybatis physical paging rowbounds temporary table alias problem

Time:12-23

In the project using the RowBounds paging, but generated temporary table alias error report, but this is not my generates SQL:
Servlet service () for the Servlet [dispatcherServlet] in context with the path [/bos] threw the exception [Request processing failed; nested exception is org. Springframework. JDBC. BadSqlGrammarException:
# # # Error querying the database. Cause: the mysql. JDBC. Exceptions. Jdbc4. MySQLSyntaxErrorException: Every derived table must have its own alias
# # # The error may exist in The file [D: \ workspace \ spring \. Metadata \. Plugins \ org eclipse WST) server. The core \ tmp1 \ wtpwebapps \ bos \ WEB - INF \ classes \ mapper \ StaffMapper XML]
# # # The error may involve defaultParameterMap
# # # The error occurred while setting The parameters
# # # SQL: select * from (select tmp_page. *, rownum row_id from (select id, name, telephone, haspda deltag, station, standard the from bc_staff) tmp_page where rownum & lt;=? ) where row_id & gt; ?
# # # Cause: com. Mysql. JDBC. Exceptions. Jdbc4. MySQLSyntaxErrorException: Every derived table must have its own alias
; Bad SQL grammar []; Nested exception is com. Mysql. JDBC. Exceptions. Jdbc4. MySQLSyntaxErrorException: Every derived table must have its own alias] with root cause
Com. Mysql. JDBC. Exceptions. Jdbc4. MySQLSyntaxErrorException: Every derived table must have its own alias
At sun. Reflect. NativeConstructorAccessorImpl. NewInstance0 (Native Method)
At sun. Reflect. NativeConstructorAccessorImpl. NewInstance (Unknown Source)
At sun. Reflect. DelegatingConstructorAccessorImpl. NewInstance (Unknown Source)
The at Java. Lang. Reflect. Constructor. NewInstance (Unknown Source)
At com. Mysql. JDBC. Util. HandleNewInstance (Util. Java: 408)
At com. Mysql. JDBC. Util. GetInstance (Util. Java: 383)
The at cn. JGSDX. Gyx. Dao. BaseDAO. SelectPublicListPage (BaseDAO. Java: 54)
The at cn. JGSDX. Gyx. Service. Impl. StaffServiceImpl. SelectPublicListPage (25) StaffServiceImpl. Java:
The at cn. JGSDX. Gyx. Controller. StaffController. SelectPublicListPage (31) StaffController. Java:

In my dao paging code

The public & lt; T> PageList SelectPublicListPage (String countSqlID, String sqlID PageList Page, the Object obj) {
//the total number of queries
The Integer total=this. GetSqlSession (). SelectOne (countSqlID, obj);
If (total==null) {
Total=0;
}
//set the query article number range
RowBounds RowBounds=new RowBounds (page. GetFirstResult (), page, getPageSize ());
//query list information
List List=this. GetSqlSession (). The selectList (sqlID, obj, rowBounds);
Page. SetTotal (total!=null? Total: 0);
Page. SetRows (list);
Page. SetTotalPage ((total + page. GetPageSize () - 1)/page getPageSize ());
return page;
}

The realization of the service:

Public PageList SelectPublicListPage (Integer page, Integer rows) {

PageList PageList=new PageList<> (a);
PageList. SetCurrentPage (page);
PageList. SetPageSize (rows);
Map The map=new HashMap<> (a);
//parameter 1: query to send sqlid, of the total parameter 2: query sqlid
Return baseDAO. SelectPublicListPage (BosSqlIdDefine. StaffSqlId. QUERY_STAFF_BY_COUNT, BosSqlIdDefine. StaffSqlId. QUERY_STAFF_BY_All, pageList, map);
}

Mapper file:


Look at the error message is the table alias problem, but this is mybatis automatically generated temporary table, I how to control the process, or where there is a problem, someone could help me trouble, thank humbly

CodePudding user response:

CodePudding user response:



This is the result of the mapping set

CodePudding user response:

I also met this problem, the reason is that mybatis - config. XML configuration & lt; The property name="the dialect" value="https://bbs.csdn.net/topics/oracle"/& gt; Oracle, switch to mysql
  • Related