<?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="out"/>

	<bean id="jpaParameterSource" class="org.mockito.Mockito" factory-method="mock">
		<constructor-arg value="org.springframework.integration.jpa.support.parametersource.ParameterSource"
						 type="java.lang.Class"/>
	</bean>

	<int-jpa:inbound-channel-adapter id="jpaInboundChannelAdapter1"
									 entity-manager-factory="entityManagerFactory"
									 entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
									 expect-single-result="true"
									 parameter-source="jpaParameterSource"
									 auto-startup="false"
									 channel="out">
		<int:poller fixed-rate="5000"/>
	</int-jpa:inbound-channel-adapter>

	<int-jpa:inbound-channel-adapter id="jpaInboundChannelAdapter2"
									 entity-manager-factory="entityManagerFactory"
									 entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
									 max-results="13"
									 delete-after-poll="true"
									 flush-after-delete="true"
									 auto-startup="false"
									 channel="out">
		<int:poller fixed-rate="5000"/>
	</int-jpa:inbound-channel-adapter>

	<int-jpa:inbound-channel-adapter id="jpaInboundChannelAdapter3"
									 entity-manager-factory="entityManagerFactory"
									 entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
									 max-results-expression="@maxNumberOfResults"
									 auto-startup="false"
									 channel="out">
		<int:poller fixed-rate="5000"/>
	</int-jpa:inbound-channel-adapter>

	<bean name="maxNumberOfResults" class="java.lang.Integer">
		<constructor-arg value="2"/>
	</bean>

	<int-jpa:inbound-channel-adapter
			channel="nullChannel"
			auto-startup="false"
			entity-manager-factory="entityManagerFactory"
			jpa-query="select rm from Msg rm where rm.isApproved= '1'">
		<int:poller fixed-rate="30000"/>
	</int-jpa:inbound-channel-adapter>

	<int-jpa:inbound-channel-adapter
			channel="nullChannel"
			auto-startup="false"
			entity-manager-factory="entityManagerFactory"
			jpa-query="select slt from Email slt where  slt.mailStatus = 'NEW'">
		<int:poller fixed-rate="10000"/>
	</int-jpa:inbound-channel-adapter>

</beans>
