<?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-jpa="http://www.springframework.org/schema/integration/jpa"
	   xmlns:int="http://www.springframework.org/schema/integration"
	   xsi:schemaLocation=
			   "http://www.springframework.org/schema/beans          https://www.springframework.org/schema/beans/spring-beans.xsd
	http://www.springframework.org/schema/integration     https://www.springframework.org/schema/integration/spring-integration.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="retrievingGateway"
			entity-manager="entityManager"
			auto-startup="true"
			entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
			request-channel="in"
			reply-channel="out"
			first-result-expression="payload"
			max-results-expression="headers['maxResults']"
			delete-after-poll="true"
			flush-after-delete="true"
			reply-timeout="100">
		<int-jpa:transactional/>
	</int-jpa:retrieving-outbound-gateway>

	<int:channel id="findByEntityClass"/>

	<int-jpa:retrieving-outbound-gateway
			entity-manager="entityManager"
			entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
			request-channel="findByEntityClass"
			id-expression="payload"
			reply-channel="out"/>

	<int:channel id="findByPayloadType"/>

	<int-jpa:retrieving-outbound-gateway
			entity-manager="entityManager"
			request-channel="findByPayloadType"
			id-expression="payload.rollNumber"
			reply-channel="out"/>

	<int:channel id="findAndDelete"/>

	<int:channel id="findResultChannel">
		<int:queue/>
	</int:channel>

	<int-jpa:retrieving-outbound-gateway
			entity-manager="entityManager"
			request-channel="findAndDelete"
			entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
			id-expression="payload"
			delete-after-poll="true"
			requires-reply="true"
			reply-channel="findResultChannel">
		<int-jpa:transactional/>
	</int-jpa:retrieving-outbound-gateway>

</beans>
