Hi,
There’s a call to a Sql Server user defined function (dbo.TeFactProv) on the next JPQL query defined in the screen fragment controller:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<fragment xmlns="http://schemas.haulmont.com/cuba/screen/fragment.xsd">
<data readOnly="true">
<collection id="expEmbarcDc"
class="com.company.logistica.entity.ExpEmbarcament"
view="expEmbarcament-relacio">
<loader id="expEmbarcDl">
<query>
<![CDATA[select e from logis_ExpEmbarcament e where e.cteCd.conCod.conGenCom='S' and function('dbo.TeFactProv',e.cteID) = 0]]>
</query>
</loader>
</collection>
</data>
<layout width="725px" height="540px" maxHeight="540" maxWidth="650" minHeight="540" minWidth="650">
<table dataContainer="expEmbarcDc" width="800px" height="400">
<columns>
<column id="eemCd"/>
<column id="eemDt"/>
<column id="eemDtArrMA"/>
<column id="eemCnte"/>
<column id="cteCd.cteCd"/>
<column id="cteCd.cteDt"/>
<column id="cteID.cteLnRefP"/>
</columns>
</table>
</layout>
</fragment>
But the prepared statement doesn’t contain the parameter, as you can see:
Caused by: org.eclipse.persistence.exceptions.DatabaseException:
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: An insufficient number of arguments were supplied for the procedure or function dbo.TeFactProv.
Error Code: 313
Call: SELECT t1.ID, t1.EemCd, t1.EemCnte, t1.EemDt, t1.EemDtArrMA, t1.CteCd, t1.CteID, t0.ID, t0."CteCd", t0."CteDt", t0."ConCod", t2.ID, t2.ConGenCom, t3.ID, t3."CteLnRefP" FROM ContracteLin t3, CondicionsCte t2, ExpEmbarcament t1, Contracte t0 WHERE (((t2.ConGenCom = ?) AND (dbo.TeFactProv() = ?)) AND (((t0.ID = t1.CteCd) AND (t2.ID = t0."ConCod")) AND (t3.ID = t1.CteID)))
bind => [S, 0]
Query: ReadAllQuery(referenceClass=ExpEmbarcament sql="SELECT t1.ID, t1.EemCd, t1.EemCnte, t1.EemDt, t1.EemDtArrMA, t1.CteCd, t1.CteID, t0.ID, t0."CteCd", t0."CteDt", t0."ConCod", t2.ID, t2.ConGenCom, t3.ID, t3."CteLnRefP" FROM ContracteLin t3, CondicionsCte t2, ExpEmbarcament t1, Contracte t0 WHERE (((t2.ConGenCom = ?) AND (dbo.TeFactProv() = ?)) AND (((t0.ID = t1.CteCd) AND (t2.ID = t0."ConCod")) AND (t3.ID = t1.CteID)))")
FetchGroup(){eemCd, eemDt, eemDtArrMA, cteID => {class java.lang.Object=FetchGroup(cteID){cteLnRefP, id}}, eemCnte, id, cteCd => {class java.lang.Object=FetchGroup(cteCd){conCod => {class java.lang.Object=FetchGroup(conCod){conGenCom, id}}, id, cteCd, cteDt}}}
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:342) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:722) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:564) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2093) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:603) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:263) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:275) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.executeCall(ExpressionQueryMechanism.java:2897) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:261) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:332) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:728) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2785) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2738) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:565) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1221) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:914) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1180) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:466) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1268) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:3020) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1892) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1874) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1839) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:262) ~[org.eclipse.persistence.jpa-2.7.3-6-cuba.jar:na]
... 132 common frames omitted
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: An insufficient number of arguments were supplied for the procedure or function dbo.TeFactProv.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:258) ~[mssql-jdbc-6.2.1.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1535) ~[mssql-jdbc-6.2.1.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:467) ~[mssql-jdbc-6.2.1.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:409) ~[mssql-jdbc-6.2.1.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7151) ~[mssql-jdbc-6.2.1.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2478) ~[mssql-jdbc-6.2.1.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:219) ~[mssql-jdbc-6.2.1.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:199) ~[mssql-jdbc-6.2.1.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:331) ~[mssql-jdbc-6.2.1.jre8.jar:na]
at org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:107) ~[tomcat-dbcp.jar:8.5.33]
at org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:107) ~[tomcat-dbcp.jar:8.5.33]
at com.haulmont.cuba.core.sys.jdbc.ProxyPreparedStatement.lambda$executeQuery$0(ProxyPreparedStatement.java:34) ~[cuba-core-7.1.4.jar:7.1.4]
at com.haulmont.cuba.core.sys.jdbc.ProxyStatement.executeSqlStatement(ProxyStatement.java:257) ~[cuba-core-7.1.4.jar:7.1.4]
at com.haulmont.cuba.core.sys.jdbc.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:34) ~[cuba-core-7.1.4.jar:7.1.4]
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:1059) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:679) ~[org.eclipse.persistence.core-2.7.3-6-cuba.jar:na]
Is there any mistake on my part specifying the query or is there a problem when the framework prepare the JDBC statement ?
Regards