Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

273
Visualizações
Parameterizing JPA Inbound Channel Adapters

I am currently developing an application based on the Spring Boot framework that is employing a JPA inbound channel adapter to retrieve data from a relational database. I have a stored procedure named GetEmployee which needs to accept a value that varies based on the server instance on which the application is running.

I've looked at the Spring documentation on adapters, and it makes mention of a tag named int-jpa:parameter but that appears to only be utilized when the named-query attribute is utilized instead of the native-query attribute.

There is also a parameter-source attribute on the int-jpa:inbound-channel-adapter tag, but I haven't found any good documentation on how to utilize it.

Is there a way to pass a parameter from a Spring bean to the native query? Or is the better approach to use the named-query attribute?

Configuration XML:

    <int-jpa:inbound-channel-adapter
        id="employeeAdapter"
        channel="employeeChannel"
        entity-manager-factory="entityManagerFactory"   
        entity-class="com.example.entities.Employee"
        native-query="EXEC emp.dbo.GetEmployee"
        expect-single-result="false"    
        delete-after-poll="false">
        <int:poller fixed-rate="10000">
            <int:transactional propagation="REQUIRED" isolation="DEFAULT"
              transaction-manager="transactionManager" />
        </int:poller>
    </int-jpa:inbound-channel-adapter>
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Well, that really work only if your query declare some parameters:

/**
 * Given a JPQL query, this method gets all parameters defined in this query and
 * use the {@link ParameterSource} to find their values and set them.
 *
 */
private void setParametersIfRequired(String queryString, ParameterSource source, Query query) {
    Set<Parameter<?>> parameters = query.getParameters();

Since your EXEC doesn't have any parameters in the procedure call, there is nothing to extract and apply for the supplied int-jpa:parameters.

Consider to use CALL emp.dbo.GetEmployee(?) or BEGIN emp.dbo.GetEmployee(?); END;. Not sure which syntax will work for your RDBMS.

On the other hand, I'd take a look into Spring Integration Stored Procedure support instead.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda