<?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:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
	
	<context:property-placeholder location="${moa.id.configuration}"/> 
	<context:annotation-config/>
    	
    <bean id="sessionDataSource" class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true" destroy-method="close">
		<aop:scoped-proxy/>
		<property name="driverClassName" value="${moasession.hibernate.connection.driver_class}" />
		<property name="url" value="${moasession.hibernate.connection.url}"/>
		<property name="username" value="${moasession.hibernate.connection.username}" />
		<property name="password" value="${moasession.hibernate.connection.password}" />
				
		<property name="connectionProperties" value="${moasession.dbcp.connectionProperties}" />
		<property name="initialSize" value="${moasession.dbcp.initialSize}" />		
		<property name="maxTotal" value="${moasession.dbcp.maxActive}" />
		<property name="maxIdle" value="${moasession.dbcp.maxIdle}" />
		<property name="minIdle" value="${moasession.dbcp.minIdle}" />
		<!-- property name="maxWait" value="${moasession.dbcp.maxWaitMillis}" / -->
		<property name="testOnBorrow" value="${moasession.dbcp.testOnBorrow}" />
		<property name="testOnReturn" value="${moasession.dbcp.testOnReturn}" />
		<property name="testWhileIdle" value="${moasession.dbcp.testWhileIdle}" />
		<property name="validationQuery" value="${moasession.dbcp.validationQuery}" />
	</bean>
	
<!-- 	<bean id="sessionSessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
    	<property name="dataSource"  ref="sessionDataSource"/>
    	<property name="packagesToScan" value="at.gv.egovernment.moa.id.commons.db.dao.session" />
    	<property name="hibernateProperties">
        	<props>
            	<prop key="hibernate.dialect">${moasession.hibernate.dialect}</prop>
            	<prop key="hibernate.show_sql">${moasession.hibernate.show_sql}</prop>
            	<prop key="hibernate.hbm2ddl.auto">${moasession.hibernate.hbm2ddl.auto}</prop>
            	<prop key="current_session_context_class">${moasession.hibernate.current_session_context_class}</prop>
            	<prop key="hibernate.transaction.flush_before_completion">${moasession.hibernate.transaction.flush_before_completion}</prop>
                <prop key="hibernate.transaction.auto_close_session">${moasession.hibernate.transaction.auto_close_session}</prop>
        	</props>
    	</property>
	</bean> -->

	<!-- MYSQL Conector --> 
	<tx:annotation-driven transaction-manager="sessionTransactionManager"/>
	
	<bean id="sessionJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
		<property name="showSql" value="${moasession.hibernate.show_sql}" />
		<property name="generateDdl" value="${moasession.jpaVendorAdapter.generateDdl}" />
		<property name="databasePlatform" value="${moasession.hibernate.dialect}" />
	</bean>
	
	<bean name="session" id="session" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" depends-on="sessionDataSource">
		<property name="dataSource" ref="sessionDataSource" />
		<property name="jpaVendorAdapter" ref="sessionJpaVendorAdapter" />
		<property name="packagesToScan" value="at.gv.egovernment.moa.id.commons.db.dao.session" />
		<property name="persistenceUnitName" value="session" />
	</bean>
	
	 <bean name="sessionTransactionManager" id="sessionTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
		<property name="entityManagerFactory" ref="session" />
	</bean>  

    <!--  bean id="moaSessionDBUtils" class="at.gv.egovernment.moa.id.commons.db.MOASessionDBUtils"/-->
	
</beans>