<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	   xmlns:int="http://www.springframework.org/schema/integration"
	   xmlns:int-jpa="http://www.springframework.org/schema/integration/jpa"
	   xsi:schemaLocation="http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
		http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/integration/jpa https://www.springframework.org/schema/integration/jpa/spring-integration-jpa.xsd">

	<import resource="classpath:/hibernateJpa-context.xml" />

	<int:channel id="in"/>
	<int:channel id="out"/>

	<int-jpa:retrieving-outbound-gateway id="retrievingJpaOutboundGateway"
		entity-manager-factory="entityManagerFactory"
		auto-startup="true"
		entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
		order="1"
		max-results="55"
		delete-after-poll="true"
		flush-after-delete="true"
		request-channel="in"
		reply-channel="out"
		reply-timeout="100"
		expect-single-result="true"
		requires-reply="false"/>

	<int-jpa:retrieving-outbound-gateway id="retrievingJpaOutboundGatewayWithFirstResult"
		entity-manager-factory="entityManagerFactory"
		auto-startup="true"
		entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
		order="1"
		first-result="1"
		max-results="55"
		request-channel="in"
		reply-channel="out"
		reply-timeout="100"
		requires-reply="false"/>

	<int-jpa:retrieving-outbound-gateway id="retrievingJpaOutboundGatewayWithMaxResultExpression"
		entity-manager-factory="entityManagerFactory"
		auto-startup="true"
		entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
		order="1"
		first-result="1"
		max-results-expression="header['maxResults']"
		request-channel="in"
		reply-channel="out"
		reply-timeout="100"
		requires-reply="false"/>

	<int-jpa:retrieving-outbound-gateway id="retrievingJpaOutboundGatewayWithFirstResultExpression"
		entity-manager-factory="entityManagerFactory"
		auto-startup="true"
		entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
		order="1"
		first-result-expression="header['firstResult']"
		max-results="55"
		request-channel="in"
		reply-channel="out"
		reply-timeout="100"
		requires-reply="false"/>

	<int-jpa:updating-outbound-gateway id="updatingJpaOutboundGateway"
		entity-manager-factory="entityManagerFactory"
		auto-startup="false"
		entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
		persist-mode="PERSIST"
		use-payload-as-parameter-source="true"
		order="2"
		request-channel="in"
		reply-channel="out"
		reply-timeout="100"
		flush-size="100"
		clear-on-flush="true"
		requires-reply="false"/>

	<int-jpa:updating-outbound-gateway id="advised"
		entity-manager-factory="entityManagerFactory"
		auto-startup="false"
		entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
		persist-mode="PERSIST"
		use-payload-as-parameter-source="true"
		order="2"
		request-channel="in"
		reply-channel="out"
		reply-timeout="100">
		<int-jpa:transactional/>
		<int-jpa:request-handler-advice-chain>
			<ref bean="jpaFooAdvice"/>
		</int-jpa:request-handler-advice-chain>
	</int-jpa:updating-outbound-gateway>

	<bean  id="jpaFooAdvice" class="org.mockito.Mockito" factory-method="spy">
		<constructor-arg>
			<bean class="org.springframework.integration.jpa.config.xml.JpaOutboundGatewayParserTests$FooAdvice"/>
		</constructor-arg>
	</bean>
</beans>
