<?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:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd">

	<!-- Database setup -->
	<import resource="infrastructure.xml" />

	<!-- Configure a DAO for User class -->
	<bean id="userDao" class="org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean">
		<constructor-arg value="org.springframework.data.jpa.repository.sample.UserRepository" />
		<property name="customImplementation">
			<bean class="org.springframework.data.jpa.repository.sample.UserRepositoryImpl">
				<constructor-arg>
					<bean class="org.springframework.data.jpa.repository.support.DefaultJpaContext" autowire="constructor" />
				</constructor-arg>
			</bean>
		</property>
		<property name="namedQueries">
			<bean class="org.springframework.data.repository.core.support.PropertiesBasedNamedQueries">
				<constructor-arg>
					<util:properties location="META-INF/jpa-named-queries.properties" />
				</constructor-arg>
			</bean>
		</property>
		<property name="evaluationContextProvider" ref="expressionEvaluationContextProvider"/>
	</bean>
	
	<bean id="roleDao" class="org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean">
		<constructor-arg value="org.springframework.data.jpa.repository.sample.RoleRepository" />
		<property name="evaluationContextProvider" ref="expressionEvaluationContextProvider"/>
	</bean>

	<!-- Necessary to get the entity manager injected into the factory bean -->
	<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

	<!-- Adds transparent exception translation to the DAOs -->
	<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />

	<bean id="expressionEvaluationContextProvider" class="org.springframework.data.repository.query.ExtensionAwareQueryMethodEvaluationContextProvider" autowire="constructor" />
	
	<bean class="org.springframework.data.jpa.repository.support.EntityManagerBeanDefinitionRegistrarPostProcessor" />

	<bean class="org.springframework.data.jpa.repository.GreetingsFrom" name="greetingsFrom" />

</beans>
