2016-04-25 17 views
1

Ich habe eine gespeicherte Prozedur, und es ist von einer JpaRepository Implementierung als solcheSpring JPA Stored Procedure mit einem Nullwert?

@Repository 
public interface DataMartRepo extends JpaRepository<DataMartDAO, String> { 

    @Procedure(procedureName = "dbo.txn_ETL") 
    public void txnETL(
     @Param("txId") String txId, 
     @Param("inId") String inId, 
     @Param("proc") String proc, 
     @Param("qtys") String qtys); 

nun aufgerufen wird, das funktioniert gut, zu erwarten für, wenn „proc“ ist ein Nullwert, in diesem Fall ist es eine Ausnahme auslöst:

SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/Authenticator] 
threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: 
    Error calling CallableStatement.getMoreResults; nested exception is org.hibernate.exception.GenericJDBCException: 
    Error calling CallableStatement.getMoreResults] with root cause 
com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set for the parameter number 3. 
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190) 
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.buildParamTypeDefinitions(SQLServerPreparedStatement.java:260) 
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.buildPreparedStrings(SQLServerPreparedStatement.java:219) 
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doPrepExec(SQLServerPreparedStatement.java:612) 
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:400) 
[...] 

Wie gehe ich mit Nullwerten um? Das Setzen aller Strings auf "" bietet keine Null-Inserts.

+0

Hier ist eine mögliche Lösung für Ihr Problem: https://Stackoverflow.com/a/44378175/2200690 –

Antwort