Mybatis calling SQL Function with SpringBoot
I have a sample demo Project of latest Mybatis and Spring Boot with testing of a calling SQL function. You can clone the demo project from demo github project . I am continuously getting below ERROR which i am unsure why i am getting.
2018-10-30 15:24:18.991 INFO 32549 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-10-30 15:24:21.162 INFO 32549 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-10-30 15:24:21.893 INFO 32549 --- [nio-8080-exec-1] o.s.b.f.xml.XmlBeanDefinitionReader : Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
2018-10-30 15:24:22.374 ERROR 32549 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path threw exception [Request processing failed; nested exception is org.springframework.jdbc.UncategorizedSQLException:
### Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist
### The error may exist in com/example/demo/Mapper.xml
### The error may involve com.example.demo.Mapper.getData-Inline
### The error occurred while setting parameters
### SQL: { call MV_METADATA.MV_GET_UI_REPORTS_BY_PAGEC(139440, 1000572, ?, ?, 0, 25, ?, ?, ?, ?, ?, ?, ?) }
### Cause: org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist
; uncategorized SQLException; SQL state [34000]; error code [0]; ERROR: cursor "<unnamed portal 1>" does not exist; nested exception is org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist] with root cause
org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgConnection.execSQLQuery(PgConnection.java:417) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgResultSet.internalGetObject(PgResultSet.java:250) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgResultSet.getObject(PgResultSet.java:2572) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgCallableStatement.executeWithFlags(PgCallableStatement.java:126) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:132) ~[postgresql-42.2.5.jar:42.2.5]
at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44) ~[HikariCP-2.7.9.jar:na]
at com.zaxxer.hikari.pool.HikariProxyCallableStatement.execute(HikariProxyCallableStatement.java) ~[HikariCP-2.7.9.jar:na]
at org.apache.ibatis.executor.statement.CallableStatementHandler.query(CallableStatementHandler.java:67) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77) ~[mybatis-3.4.6.jar:3.4.6]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ~[mybatis-spring-1.3.2.jar:1.3.2]
at com.sun.proxy.$Proxy65.selectOne(Unknown Source) ~[na:na]
at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166) ~[mybatis-spring-1.3.2.jar:1.3.2]
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:83) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) ~[mybatis-3.4.6.jar:3.4.6]
at com.sun.proxy.$Proxy67.getData(Unknown Source) ~[na:na]
at com.example.demo.DemoController.getData(DemoController.java:18) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) ~[spring-web-5.0.10.RELEASE.jar:5.0.10.RELEASE]
I have the below classes where i am calling the SQL function.
Mapper.java
package com.example.demo;
import org.apache.ibatis.annotations.Param;
@org.apache.ibatis.annotations.Mapper
public interface Mapper {
Object getData(LookUpParams lookUpParams);
}
Mapper.xml
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.demo.Mapper">
<resultMap id="reportsFolderMap" type="java.util.HashMap"/>
<select id="getData" parameterType="com.example.demo.LookUpParams" statementType="CALLABLE">
{
<if test="isContentManagerByLocale == 0">
call MV_METADATA.MV_GET_UI_REPORTS_BY_PAGEC(139440,
1000572,
#{productName,mode=IN,jdbcType=VARCHAR},
#{filterDefinition,mode=IN,jdbcType=VARCHAR},
0,
25,
#{sortProperty,mode=IN,jdbcType=VARCHAR},
#{sortDirection,mode=IN,jdbcType=VARCHAR},
#{dateStart,mode=IN,jdbcType=VARCHAR},
#{dateEnd,mode=IN,jdbcType=VARCHAR},
#{status,mode=IN,jdbcType=VARCHAR},
#{reportTypeId, mode=IN,jdbcType=VARCHAR},
#{mediaViewResultSet,jdbcType=CURSOR,javaType=java.sql.ResultSet, mode=OUT, resultMap=reportsFolderMap})
</if>
<if test="isContentManagerByLocale == 1">
call MV_METADATA.MV_GET_UI_REPORTS_BY_PAGEC_LOC(139440,
1000572,
#{productName,mode=IN,jdbcType=VARCHAR},
#{filterDefinition,mode=IN,jdbcType=VARCHAR},
0,
25,
#{sortProperty,mode=IN,jdbcType=VARCHAR},
#{sortDirection,mode=IN,jdbcType=VARCHAR},
#{dateStart,mode=IN,jdbcType=VARCHAR},
#{dateEnd,mode=IN,jdbcType=VARCHAR},
#{Status,mode=IN,jdbcType=VARCHAR},
#{locale,mode=IN,jdbcType=VARCHAR},
#{reportTypeId, mode=IN,jdbcType=VARCHAR},
#{mediaViewResultSet,jdbcType=CURSOR,javaType=java.sql.ResultSet, mode=OUT, resultMap=reportsFolderMap})
</if>
}
</select>
</mapper>
Controller class
package com.example.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@RestController
@RequestMapping("/")
public class DemoController {
@Autowired
Mapper mapper;
@PostMapping("/mb")
public Object getData(@Valid @RequestBody LookUpParams lookUpParams){
return mapper.getData(lookUpParams);
}
}
POJO class
package com.example.demo;
import javax.validation.constraints.NotNull;
import java.math.BigInteger;
import java.sql.ResultSet;
public class LookUpParams {
@NotNull
private String query;
@NotNull
private String queryNamespace;
private String page;
private String isContentManagerByLocale;
private String filterDefinition;
private String status;
private String reportTypeId;
private String dateStart;
private String dateEnd;
private BigInteger folderID;
private String productName;
private String locale;
private String permissionType;
private int startIndex;
private int limitIndex;
private Long associate_id;
private BigInteger currentBusinessEntity_id;
private String sortProperty;
private String sortDirection;
private int searchType;
private ResultSet mediaViewResultSet;
public ResultSet getMediaViewResultSet() {
return mediaViewResultSet;
}
public void setMediaViewResultSet(ResultSet mediaViewResultSet) {
this.mediaViewResultSet = mediaViewResultSet;
}
public int getSearchType() {
return searchType;
}
public void setSearchType(int searchType) {
this.searchType = 1;
}
public String getSortProperty() {
return sortProperty;
}
public void setSortProperty(String sortProperty) {
this.sortProperty = "";
}
public String getSortDirection() {
return sortDirection;
}
public void setSortDirection(String sortDirection) {
this.sortDirection = "DESC";
}
public Long getAssociate_id() {
return associate_id;
}
public void setAssociate_id(Long associate_id) {
this.associate_id = 8053000L;
}
public BigInteger getCurrentBusinessEntity_id() {
return currentBusinessEntity_id;
}
public void setCurrentBusinessEntity_id(BigInteger currentBusinessEntity_id) {
this.currentBusinessEntity_id = new BigInteger("1000572");
}
public String getQuery() {
return query;
}
public void setQuery(String query) {
this.query = query;
}
public String getQueryNamespace() {
return queryNamespace;
}
public void setQueryNamespace(String queryNamespace) {
this.queryNamespace = queryNamespace;
}
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
public String getIsContentManagerByLocale() {
return isContentManagerByLocale;
}
public void setIsContentManagerByLocale(String isContentManagerByLocale) {
this.isContentManagerByLocale = isContentManagerByLocale;
}
public String getFilterDefinition() {
return filterDefinition;
}
public void setFilterDefinition(String filterDefinition) {
this.filterDefinition = filterDefinition;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getReportTypeId() {
return reportTypeId;
}
public void setReportTypeId(String reportTypeId) {
this.reportTypeId = reportTypeId;
}
public String getDateStart() {
return dateStart;
}
public void setDateStart(String dateStart) {
this.dateStart = dateStart;
}
public String getDateEnd() {
return dateEnd;
}
public void setDateEnd(String dateEnd) {
this.dateEnd = dateEnd;
}
public BigInteger getFolderID() {
return folderID;
}
public void setFolderID(BigInteger folderID) {
this.folderID = folderID;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getLocale() {
return locale;
}
public void setLocale(String locale) {
this.locale = locale;
}
public String getPermissionType() {
return permissionType;
}
public void setPermissionType(String permissionType) {
this.permissionType = permissionType;
}
public int getStartIndex() {
return startIndex;
}
public void setStartIndex(int startIndex) {
this.startIndex = startIndex;
}
public int getLimitIndex() {
return limitIndex;
}
public void setLimitIndex(int limitIndex) {
this.limitIndex = limitIndex;
}
}
App calss
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String args) {
SpringApplication.run(DemoApplication.class, args);
}
}
I am not sure why i am getting the above error. Can anyone shed some light?
Thanks.
java spring spring-boot mybatis spring-mybatis
add a comment |
I have a sample demo Project of latest Mybatis and Spring Boot with testing of a calling SQL function. You can clone the demo project from demo github project . I am continuously getting below ERROR which i am unsure why i am getting.
2018-10-30 15:24:18.991 INFO 32549 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-10-30 15:24:21.162 INFO 32549 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-10-30 15:24:21.893 INFO 32549 --- [nio-8080-exec-1] o.s.b.f.xml.XmlBeanDefinitionReader : Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
2018-10-30 15:24:22.374 ERROR 32549 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path threw exception [Request processing failed; nested exception is org.springframework.jdbc.UncategorizedSQLException:
### Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist
### The error may exist in com/example/demo/Mapper.xml
### The error may involve com.example.demo.Mapper.getData-Inline
### The error occurred while setting parameters
### SQL: { call MV_METADATA.MV_GET_UI_REPORTS_BY_PAGEC(139440, 1000572, ?, ?, 0, 25, ?, ?, ?, ?, ?, ?, ?) }
### Cause: org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist
; uncategorized SQLException; SQL state [34000]; error code [0]; ERROR: cursor "<unnamed portal 1>" does not exist; nested exception is org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist] with root cause
org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgConnection.execSQLQuery(PgConnection.java:417) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgResultSet.internalGetObject(PgResultSet.java:250) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgResultSet.getObject(PgResultSet.java:2572) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgCallableStatement.executeWithFlags(PgCallableStatement.java:126) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:132) ~[postgresql-42.2.5.jar:42.2.5]
at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44) ~[HikariCP-2.7.9.jar:na]
at com.zaxxer.hikari.pool.HikariProxyCallableStatement.execute(HikariProxyCallableStatement.java) ~[HikariCP-2.7.9.jar:na]
at org.apache.ibatis.executor.statement.CallableStatementHandler.query(CallableStatementHandler.java:67) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77) ~[mybatis-3.4.6.jar:3.4.6]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ~[mybatis-spring-1.3.2.jar:1.3.2]
at com.sun.proxy.$Proxy65.selectOne(Unknown Source) ~[na:na]
at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166) ~[mybatis-spring-1.3.2.jar:1.3.2]
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:83) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) ~[mybatis-3.4.6.jar:3.4.6]
at com.sun.proxy.$Proxy67.getData(Unknown Source) ~[na:na]
at com.example.demo.DemoController.getData(DemoController.java:18) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) ~[spring-web-5.0.10.RELEASE.jar:5.0.10.RELEASE]
I have the below classes where i am calling the SQL function.
Mapper.java
package com.example.demo;
import org.apache.ibatis.annotations.Param;
@org.apache.ibatis.annotations.Mapper
public interface Mapper {
Object getData(LookUpParams lookUpParams);
}
Mapper.xml
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.demo.Mapper">
<resultMap id="reportsFolderMap" type="java.util.HashMap"/>
<select id="getData" parameterType="com.example.demo.LookUpParams" statementType="CALLABLE">
{
<if test="isContentManagerByLocale == 0">
call MV_METADATA.MV_GET_UI_REPORTS_BY_PAGEC(139440,
1000572,
#{productName,mode=IN,jdbcType=VARCHAR},
#{filterDefinition,mode=IN,jdbcType=VARCHAR},
0,
25,
#{sortProperty,mode=IN,jdbcType=VARCHAR},
#{sortDirection,mode=IN,jdbcType=VARCHAR},
#{dateStart,mode=IN,jdbcType=VARCHAR},
#{dateEnd,mode=IN,jdbcType=VARCHAR},
#{status,mode=IN,jdbcType=VARCHAR},
#{reportTypeId, mode=IN,jdbcType=VARCHAR},
#{mediaViewResultSet,jdbcType=CURSOR,javaType=java.sql.ResultSet, mode=OUT, resultMap=reportsFolderMap})
</if>
<if test="isContentManagerByLocale == 1">
call MV_METADATA.MV_GET_UI_REPORTS_BY_PAGEC_LOC(139440,
1000572,
#{productName,mode=IN,jdbcType=VARCHAR},
#{filterDefinition,mode=IN,jdbcType=VARCHAR},
0,
25,
#{sortProperty,mode=IN,jdbcType=VARCHAR},
#{sortDirection,mode=IN,jdbcType=VARCHAR},
#{dateStart,mode=IN,jdbcType=VARCHAR},
#{dateEnd,mode=IN,jdbcType=VARCHAR},
#{Status,mode=IN,jdbcType=VARCHAR},
#{locale,mode=IN,jdbcType=VARCHAR},
#{reportTypeId, mode=IN,jdbcType=VARCHAR},
#{mediaViewResultSet,jdbcType=CURSOR,javaType=java.sql.ResultSet, mode=OUT, resultMap=reportsFolderMap})
</if>
}
</select>
</mapper>
Controller class
package com.example.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@RestController
@RequestMapping("/")
public class DemoController {
@Autowired
Mapper mapper;
@PostMapping("/mb")
public Object getData(@Valid @RequestBody LookUpParams lookUpParams){
return mapper.getData(lookUpParams);
}
}
POJO class
package com.example.demo;
import javax.validation.constraints.NotNull;
import java.math.BigInteger;
import java.sql.ResultSet;
public class LookUpParams {
@NotNull
private String query;
@NotNull
private String queryNamespace;
private String page;
private String isContentManagerByLocale;
private String filterDefinition;
private String status;
private String reportTypeId;
private String dateStart;
private String dateEnd;
private BigInteger folderID;
private String productName;
private String locale;
private String permissionType;
private int startIndex;
private int limitIndex;
private Long associate_id;
private BigInteger currentBusinessEntity_id;
private String sortProperty;
private String sortDirection;
private int searchType;
private ResultSet mediaViewResultSet;
public ResultSet getMediaViewResultSet() {
return mediaViewResultSet;
}
public void setMediaViewResultSet(ResultSet mediaViewResultSet) {
this.mediaViewResultSet = mediaViewResultSet;
}
public int getSearchType() {
return searchType;
}
public void setSearchType(int searchType) {
this.searchType = 1;
}
public String getSortProperty() {
return sortProperty;
}
public void setSortProperty(String sortProperty) {
this.sortProperty = "";
}
public String getSortDirection() {
return sortDirection;
}
public void setSortDirection(String sortDirection) {
this.sortDirection = "DESC";
}
public Long getAssociate_id() {
return associate_id;
}
public void setAssociate_id(Long associate_id) {
this.associate_id = 8053000L;
}
public BigInteger getCurrentBusinessEntity_id() {
return currentBusinessEntity_id;
}
public void setCurrentBusinessEntity_id(BigInteger currentBusinessEntity_id) {
this.currentBusinessEntity_id = new BigInteger("1000572");
}
public String getQuery() {
return query;
}
public void setQuery(String query) {
this.query = query;
}
public String getQueryNamespace() {
return queryNamespace;
}
public void setQueryNamespace(String queryNamespace) {
this.queryNamespace = queryNamespace;
}
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
public String getIsContentManagerByLocale() {
return isContentManagerByLocale;
}
public void setIsContentManagerByLocale(String isContentManagerByLocale) {
this.isContentManagerByLocale = isContentManagerByLocale;
}
public String getFilterDefinition() {
return filterDefinition;
}
public void setFilterDefinition(String filterDefinition) {
this.filterDefinition = filterDefinition;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getReportTypeId() {
return reportTypeId;
}
public void setReportTypeId(String reportTypeId) {
this.reportTypeId = reportTypeId;
}
public String getDateStart() {
return dateStart;
}
public void setDateStart(String dateStart) {
this.dateStart = dateStart;
}
public String getDateEnd() {
return dateEnd;
}
public void setDateEnd(String dateEnd) {
this.dateEnd = dateEnd;
}
public BigInteger getFolderID() {
return folderID;
}
public void setFolderID(BigInteger folderID) {
this.folderID = folderID;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getLocale() {
return locale;
}
public void setLocale(String locale) {
this.locale = locale;
}
public String getPermissionType() {
return permissionType;
}
public void setPermissionType(String permissionType) {
this.permissionType = permissionType;
}
public int getStartIndex() {
return startIndex;
}
public void setStartIndex(int startIndex) {
this.startIndex = startIndex;
}
public int getLimitIndex() {
return limitIndex;
}
public void setLimitIndex(int limitIndex) {
this.limitIndex = limitIndex;
}
}
App calss
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String args) {
SpringApplication.run(DemoApplication.class, args);
}
}
I am not sure why i am getting the above error. Can anyone shed some light?
Thanks.
java spring spring-boot mybatis spring-mybatis
You should not create duplicate questions on the same matter. You already asked this here and got a hint that you should call the function directly.
– Roman Konoval
Oct 30 '18 at 16:44
Possible duplicate of Mybatis calling sql function return ERROR: cursor "<unnamed portal 1>" does not exist
– Roman Konoval
Oct 30 '18 at 16:45
I am calling the function directly. What do you mean directly then?
– rakeeee
Oct 31 '18 at 5:11
add a comment |
I have a sample demo Project of latest Mybatis and Spring Boot with testing of a calling SQL function. You can clone the demo project from demo github project . I am continuously getting below ERROR which i am unsure why i am getting.
2018-10-30 15:24:18.991 INFO 32549 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-10-30 15:24:21.162 INFO 32549 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-10-30 15:24:21.893 INFO 32549 --- [nio-8080-exec-1] o.s.b.f.xml.XmlBeanDefinitionReader : Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
2018-10-30 15:24:22.374 ERROR 32549 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path threw exception [Request processing failed; nested exception is org.springframework.jdbc.UncategorizedSQLException:
### Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist
### The error may exist in com/example/demo/Mapper.xml
### The error may involve com.example.demo.Mapper.getData-Inline
### The error occurred while setting parameters
### SQL: { call MV_METADATA.MV_GET_UI_REPORTS_BY_PAGEC(139440, 1000572, ?, ?, 0, 25, ?, ?, ?, ?, ?, ?, ?) }
### Cause: org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist
; uncategorized SQLException; SQL state [34000]; error code [0]; ERROR: cursor "<unnamed portal 1>" does not exist; nested exception is org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist] with root cause
org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgConnection.execSQLQuery(PgConnection.java:417) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgResultSet.internalGetObject(PgResultSet.java:250) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgResultSet.getObject(PgResultSet.java:2572) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgCallableStatement.executeWithFlags(PgCallableStatement.java:126) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:132) ~[postgresql-42.2.5.jar:42.2.5]
at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44) ~[HikariCP-2.7.9.jar:na]
at com.zaxxer.hikari.pool.HikariProxyCallableStatement.execute(HikariProxyCallableStatement.java) ~[HikariCP-2.7.9.jar:na]
at org.apache.ibatis.executor.statement.CallableStatementHandler.query(CallableStatementHandler.java:67) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77) ~[mybatis-3.4.6.jar:3.4.6]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ~[mybatis-spring-1.3.2.jar:1.3.2]
at com.sun.proxy.$Proxy65.selectOne(Unknown Source) ~[na:na]
at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166) ~[mybatis-spring-1.3.2.jar:1.3.2]
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:83) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) ~[mybatis-3.4.6.jar:3.4.6]
at com.sun.proxy.$Proxy67.getData(Unknown Source) ~[na:na]
at com.example.demo.DemoController.getData(DemoController.java:18) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) ~[spring-web-5.0.10.RELEASE.jar:5.0.10.RELEASE]
I have the below classes where i am calling the SQL function.
Mapper.java
package com.example.demo;
import org.apache.ibatis.annotations.Param;
@org.apache.ibatis.annotations.Mapper
public interface Mapper {
Object getData(LookUpParams lookUpParams);
}
Mapper.xml
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.demo.Mapper">
<resultMap id="reportsFolderMap" type="java.util.HashMap"/>
<select id="getData" parameterType="com.example.demo.LookUpParams" statementType="CALLABLE">
{
<if test="isContentManagerByLocale == 0">
call MV_METADATA.MV_GET_UI_REPORTS_BY_PAGEC(139440,
1000572,
#{productName,mode=IN,jdbcType=VARCHAR},
#{filterDefinition,mode=IN,jdbcType=VARCHAR},
0,
25,
#{sortProperty,mode=IN,jdbcType=VARCHAR},
#{sortDirection,mode=IN,jdbcType=VARCHAR},
#{dateStart,mode=IN,jdbcType=VARCHAR},
#{dateEnd,mode=IN,jdbcType=VARCHAR},
#{status,mode=IN,jdbcType=VARCHAR},
#{reportTypeId, mode=IN,jdbcType=VARCHAR},
#{mediaViewResultSet,jdbcType=CURSOR,javaType=java.sql.ResultSet, mode=OUT, resultMap=reportsFolderMap})
</if>
<if test="isContentManagerByLocale == 1">
call MV_METADATA.MV_GET_UI_REPORTS_BY_PAGEC_LOC(139440,
1000572,
#{productName,mode=IN,jdbcType=VARCHAR},
#{filterDefinition,mode=IN,jdbcType=VARCHAR},
0,
25,
#{sortProperty,mode=IN,jdbcType=VARCHAR},
#{sortDirection,mode=IN,jdbcType=VARCHAR},
#{dateStart,mode=IN,jdbcType=VARCHAR},
#{dateEnd,mode=IN,jdbcType=VARCHAR},
#{Status,mode=IN,jdbcType=VARCHAR},
#{locale,mode=IN,jdbcType=VARCHAR},
#{reportTypeId, mode=IN,jdbcType=VARCHAR},
#{mediaViewResultSet,jdbcType=CURSOR,javaType=java.sql.ResultSet, mode=OUT, resultMap=reportsFolderMap})
</if>
}
</select>
</mapper>
Controller class
package com.example.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@RestController
@RequestMapping("/")
public class DemoController {
@Autowired
Mapper mapper;
@PostMapping("/mb")
public Object getData(@Valid @RequestBody LookUpParams lookUpParams){
return mapper.getData(lookUpParams);
}
}
POJO class
package com.example.demo;
import javax.validation.constraints.NotNull;
import java.math.BigInteger;
import java.sql.ResultSet;
public class LookUpParams {
@NotNull
private String query;
@NotNull
private String queryNamespace;
private String page;
private String isContentManagerByLocale;
private String filterDefinition;
private String status;
private String reportTypeId;
private String dateStart;
private String dateEnd;
private BigInteger folderID;
private String productName;
private String locale;
private String permissionType;
private int startIndex;
private int limitIndex;
private Long associate_id;
private BigInteger currentBusinessEntity_id;
private String sortProperty;
private String sortDirection;
private int searchType;
private ResultSet mediaViewResultSet;
public ResultSet getMediaViewResultSet() {
return mediaViewResultSet;
}
public void setMediaViewResultSet(ResultSet mediaViewResultSet) {
this.mediaViewResultSet = mediaViewResultSet;
}
public int getSearchType() {
return searchType;
}
public void setSearchType(int searchType) {
this.searchType = 1;
}
public String getSortProperty() {
return sortProperty;
}
public void setSortProperty(String sortProperty) {
this.sortProperty = "";
}
public String getSortDirection() {
return sortDirection;
}
public void setSortDirection(String sortDirection) {
this.sortDirection = "DESC";
}
public Long getAssociate_id() {
return associate_id;
}
public void setAssociate_id(Long associate_id) {
this.associate_id = 8053000L;
}
public BigInteger getCurrentBusinessEntity_id() {
return currentBusinessEntity_id;
}
public void setCurrentBusinessEntity_id(BigInteger currentBusinessEntity_id) {
this.currentBusinessEntity_id = new BigInteger("1000572");
}
public String getQuery() {
return query;
}
public void setQuery(String query) {
this.query = query;
}
public String getQueryNamespace() {
return queryNamespace;
}
public void setQueryNamespace(String queryNamespace) {
this.queryNamespace = queryNamespace;
}
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
public String getIsContentManagerByLocale() {
return isContentManagerByLocale;
}
public void setIsContentManagerByLocale(String isContentManagerByLocale) {
this.isContentManagerByLocale = isContentManagerByLocale;
}
public String getFilterDefinition() {
return filterDefinition;
}
public void setFilterDefinition(String filterDefinition) {
this.filterDefinition = filterDefinition;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getReportTypeId() {
return reportTypeId;
}
public void setReportTypeId(String reportTypeId) {
this.reportTypeId = reportTypeId;
}
public String getDateStart() {
return dateStart;
}
public void setDateStart(String dateStart) {
this.dateStart = dateStart;
}
public String getDateEnd() {
return dateEnd;
}
public void setDateEnd(String dateEnd) {
this.dateEnd = dateEnd;
}
public BigInteger getFolderID() {
return folderID;
}
public void setFolderID(BigInteger folderID) {
this.folderID = folderID;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getLocale() {
return locale;
}
public void setLocale(String locale) {
this.locale = locale;
}
public String getPermissionType() {
return permissionType;
}
public void setPermissionType(String permissionType) {
this.permissionType = permissionType;
}
public int getStartIndex() {
return startIndex;
}
public void setStartIndex(int startIndex) {
this.startIndex = startIndex;
}
public int getLimitIndex() {
return limitIndex;
}
public void setLimitIndex(int limitIndex) {
this.limitIndex = limitIndex;
}
}
App calss
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String args) {
SpringApplication.run(DemoApplication.class, args);
}
}
I am not sure why i am getting the above error. Can anyone shed some light?
Thanks.
java spring spring-boot mybatis spring-mybatis
I have a sample demo Project of latest Mybatis and Spring Boot with testing of a calling SQL function. You can clone the demo project from demo github project . I am continuously getting below ERROR which i am unsure why i am getting.
2018-10-30 15:24:18.991 INFO 32549 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-10-30 15:24:21.162 INFO 32549 --- [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-10-30 15:24:21.893 INFO 32549 --- [nio-8080-exec-1] o.s.b.f.xml.XmlBeanDefinitionReader : Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
2018-10-30 15:24:22.374 ERROR 32549 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path threw exception [Request processing failed; nested exception is org.springframework.jdbc.UncategorizedSQLException:
### Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist
### The error may exist in com/example/demo/Mapper.xml
### The error may involve com.example.demo.Mapper.getData-Inline
### The error occurred while setting parameters
### SQL: { call MV_METADATA.MV_GET_UI_REPORTS_BY_PAGEC(139440, 1000572, ?, ?, 0, 25, ?, ?, ?, ?, ?, ?, ?) }
### Cause: org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist
; uncategorized SQLException; SQL state [34000]; error code [0]; ERROR: cursor "<unnamed portal 1>" does not exist; nested exception is org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist] with root cause
org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgConnection.execSQLQuery(PgConnection.java:417) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgResultSet.internalGetObject(PgResultSet.java:250) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgResultSet.getObject(PgResultSet.java:2572) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgCallableStatement.executeWithFlags(PgCallableStatement.java:126) ~[postgresql-42.2.5.jar:42.2.5]
at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:132) ~[postgresql-42.2.5.jar:42.2.5]
at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44) ~[HikariCP-2.7.9.jar:na]
at com.zaxxer.hikari.pool.HikariProxyCallableStatement.execute(HikariProxyCallableStatement.java) ~[HikariCP-2.7.9.jar:na]
at org.apache.ibatis.executor.statement.CallableStatementHandler.query(CallableStatementHandler.java:67) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77) ~[mybatis-3.4.6.jar:3.4.6]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ~[mybatis-spring-1.3.2.jar:1.3.2]
at com.sun.proxy.$Proxy65.selectOne(Unknown Source) ~[na:na]
at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166) ~[mybatis-spring-1.3.2.jar:1.3.2]
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:83) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) ~[mybatis-3.4.6.jar:3.4.6]
at com.sun.proxy.$Proxy67.getData(Unknown Source) ~[na:na]
at com.example.demo.DemoController.getData(DemoController.java:18) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) ~[spring-web-5.0.10.RELEASE.jar:5.0.10.RELEASE]
I have the below classes where i am calling the SQL function.
Mapper.java
package com.example.demo;
import org.apache.ibatis.annotations.Param;
@org.apache.ibatis.annotations.Mapper
public interface Mapper {
Object getData(LookUpParams lookUpParams);
}
Mapper.xml
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.demo.Mapper">
<resultMap id="reportsFolderMap" type="java.util.HashMap"/>
<select id="getData" parameterType="com.example.demo.LookUpParams" statementType="CALLABLE">
{
<if test="isContentManagerByLocale == 0">
call MV_METADATA.MV_GET_UI_REPORTS_BY_PAGEC(139440,
1000572,
#{productName,mode=IN,jdbcType=VARCHAR},
#{filterDefinition,mode=IN,jdbcType=VARCHAR},
0,
25,
#{sortProperty,mode=IN,jdbcType=VARCHAR},
#{sortDirection,mode=IN,jdbcType=VARCHAR},
#{dateStart,mode=IN,jdbcType=VARCHAR},
#{dateEnd,mode=IN,jdbcType=VARCHAR},
#{status,mode=IN,jdbcType=VARCHAR},
#{reportTypeId, mode=IN,jdbcType=VARCHAR},
#{mediaViewResultSet,jdbcType=CURSOR,javaType=java.sql.ResultSet, mode=OUT, resultMap=reportsFolderMap})
</if>
<if test="isContentManagerByLocale == 1">
call MV_METADATA.MV_GET_UI_REPORTS_BY_PAGEC_LOC(139440,
1000572,
#{productName,mode=IN,jdbcType=VARCHAR},
#{filterDefinition,mode=IN,jdbcType=VARCHAR},
0,
25,
#{sortProperty,mode=IN,jdbcType=VARCHAR},
#{sortDirection,mode=IN,jdbcType=VARCHAR},
#{dateStart,mode=IN,jdbcType=VARCHAR},
#{dateEnd,mode=IN,jdbcType=VARCHAR},
#{Status,mode=IN,jdbcType=VARCHAR},
#{locale,mode=IN,jdbcType=VARCHAR},
#{reportTypeId, mode=IN,jdbcType=VARCHAR},
#{mediaViewResultSet,jdbcType=CURSOR,javaType=java.sql.ResultSet, mode=OUT, resultMap=reportsFolderMap})
</if>
}
</select>
</mapper>
Controller class
package com.example.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@RestController
@RequestMapping("/")
public class DemoController {
@Autowired
Mapper mapper;
@PostMapping("/mb")
public Object getData(@Valid @RequestBody LookUpParams lookUpParams){
return mapper.getData(lookUpParams);
}
}
POJO class
package com.example.demo;
import javax.validation.constraints.NotNull;
import java.math.BigInteger;
import java.sql.ResultSet;
public class LookUpParams {
@NotNull
private String query;
@NotNull
private String queryNamespace;
private String page;
private String isContentManagerByLocale;
private String filterDefinition;
private String status;
private String reportTypeId;
private String dateStart;
private String dateEnd;
private BigInteger folderID;
private String productName;
private String locale;
private String permissionType;
private int startIndex;
private int limitIndex;
private Long associate_id;
private BigInteger currentBusinessEntity_id;
private String sortProperty;
private String sortDirection;
private int searchType;
private ResultSet mediaViewResultSet;
public ResultSet getMediaViewResultSet() {
return mediaViewResultSet;
}
public void setMediaViewResultSet(ResultSet mediaViewResultSet) {
this.mediaViewResultSet = mediaViewResultSet;
}
public int getSearchType() {
return searchType;
}
public void setSearchType(int searchType) {
this.searchType = 1;
}
public String getSortProperty() {
return sortProperty;
}
public void setSortProperty(String sortProperty) {
this.sortProperty = "";
}
public String getSortDirection() {
return sortDirection;
}
public void setSortDirection(String sortDirection) {
this.sortDirection = "DESC";
}
public Long getAssociate_id() {
return associate_id;
}
public void setAssociate_id(Long associate_id) {
this.associate_id = 8053000L;
}
public BigInteger getCurrentBusinessEntity_id() {
return currentBusinessEntity_id;
}
public void setCurrentBusinessEntity_id(BigInteger currentBusinessEntity_id) {
this.currentBusinessEntity_id = new BigInteger("1000572");
}
public String getQuery() {
return query;
}
public void setQuery(String query) {
this.query = query;
}
public String getQueryNamespace() {
return queryNamespace;
}
public void setQueryNamespace(String queryNamespace) {
this.queryNamespace = queryNamespace;
}
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
public String getIsContentManagerByLocale() {
return isContentManagerByLocale;
}
public void setIsContentManagerByLocale(String isContentManagerByLocale) {
this.isContentManagerByLocale = isContentManagerByLocale;
}
public String getFilterDefinition() {
return filterDefinition;
}
public void setFilterDefinition(String filterDefinition) {
this.filterDefinition = filterDefinition;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getReportTypeId() {
return reportTypeId;
}
public void setReportTypeId(String reportTypeId) {
this.reportTypeId = reportTypeId;
}
public String getDateStart() {
return dateStart;
}
public void setDateStart(String dateStart) {
this.dateStart = dateStart;
}
public String getDateEnd() {
return dateEnd;
}
public void setDateEnd(String dateEnd) {
this.dateEnd = dateEnd;
}
public BigInteger getFolderID() {
return folderID;
}
public void setFolderID(BigInteger folderID) {
this.folderID = folderID;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getLocale() {
return locale;
}
public void setLocale(String locale) {
this.locale = locale;
}
public String getPermissionType() {
return permissionType;
}
public void setPermissionType(String permissionType) {
this.permissionType = permissionType;
}
public int getStartIndex() {
return startIndex;
}
public void setStartIndex(int startIndex) {
this.startIndex = startIndex;
}
public int getLimitIndex() {
return limitIndex;
}
public void setLimitIndex(int limitIndex) {
this.limitIndex = limitIndex;
}
}
App calss
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String args) {
SpringApplication.run(DemoApplication.class, args);
}
}
I am not sure why i am getting the above error. Can anyone shed some light?
Thanks.
java spring spring-boot mybatis spring-mybatis
java spring spring-boot mybatis spring-mybatis
asked Oct 30 '18 at 10:21
rakeeeerakeeee
311324
311324
You should not create duplicate questions on the same matter. You already asked this here and got a hint that you should call the function directly.
– Roman Konoval
Oct 30 '18 at 16:44
Possible duplicate of Mybatis calling sql function return ERROR: cursor "<unnamed portal 1>" does not exist
– Roman Konoval
Oct 30 '18 at 16:45
I am calling the function directly. What do you mean directly then?
– rakeeee
Oct 31 '18 at 5:11
add a comment |
You should not create duplicate questions on the same matter. You already asked this here and got a hint that you should call the function directly.
– Roman Konoval
Oct 30 '18 at 16:44
Possible duplicate of Mybatis calling sql function return ERROR: cursor "<unnamed portal 1>" does not exist
– Roman Konoval
Oct 30 '18 at 16:45
I am calling the function directly. What do you mean directly then?
– rakeeee
Oct 31 '18 at 5:11
You should not create duplicate questions on the same matter. You already asked this here and got a hint that you should call the function directly.
– Roman Konoval
Oct 30 '18 at 16:44
You should not create duplicate questions on the same matter. You already asked this here and got a hint that you should call the function directly.
– Roman Konoval
Oct 30 '18 at 16:44
Possible duplicate of Mybatis calling sql function return ERROR: cursor "<unnamed portal 1>" does not exist
– Roman Konoval
Oct 30 '18 at 16:45
Possible duplicate of Mybatis calling sql function return ERROR: cursor "<unnamed portal 1>" does not exist
– Roman Konoval
Oct 30 '18 at 16:45
I am calling the function directly. What do you mean directly then?
– rakeeee
Oct 31 '18 at 5:11
I am calling the function directly. What do you mean directly then?
– rakeeee
Oct 31 '18 at 5:11
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53062096%2fmybatis-calling-sql-function-with-springboot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53062096%2fmybatis-calling-sql-function-with-springboot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You should not create duplicate questions on the same matter. You already asked this here and got a hint that you should call the function directly.
– Roman Konoval
Oct 30 '18 at 16:44
Possible duplicate of Mybatis calling sql function return ERROR: cursor "<unnamed portal 1>" does not exist
– Roman Konoval
Oct 30 '18 at 16:45
I am calling the function directly. What do you mean directly then?
– rakeeee
Oct 31 '18 at 5:11