<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

    <!-- load hibernate configuration properties -->    
    <bean id="hibernateConfigProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="locations">
            <list>
                <value>classpath:alfresco/domain/hibernate-cfg.properties</value>
            </list>
        </property>
    </bean>
    <!-- load hibernate entity cache strategies -->    
    <bean id="hibernateConfigPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="ignoreUnresolvablePlaceholders">
            <value>true</value>
        </property>
        <property name="locations">
            <list>
                <value>classpath:alfresco/domain/hibernate-cfg.properties</value>
            </list>
        </property>
    </bean>

    <!-- Hibernate session factory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <property name="mappingResources">
            <list>
                <value>org/alfresco/repo/domain/hibernate/Node.hbm.xml</value>
                <value>org/alfresco/repo/domain/hibernate/Store.hbm.xml</value>
                <value>org/alfresco/repo/domain/hibernate/VersionCount.hbm.xml</value>
                <value>org/alfresco/repo/security/permissions/impl/hibernate/Permission.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties" ref="hibernateConfigProperties" />
        <property name="entityCacheStrategies" >
            <props>
                <prop key="org.alfresco.repo.domain.hibernate.NodeImpl">${cache.strategy}</prop>
                <prop key="org.alfresco.repo.domain.hibernate.NodeStatusImpl">${cache.strategy}</prop>
                <prop key="org.alfresco.repo.domain.hibernate.ChildAssocImpl">${cache.strategy}</prop>
                <prop key="org.alfresco.repo.domain.hibernate.NodeAssocImpl">${cache.strategy}</prop>
                <prop key="org.alfresco.repo.domain.hibernate.StoreImpl">${cache.strategy}</prop>
                <prop key="org.alfresco.repo.domain.hibernate.VersionCountImpl">${cache.strategy}</prop>
                
                <prop key="org.alfresco.repo.security.permissions.impl.hibernate.NodePermissionEntryImpl">${cache.strategy}</prop>
                <prop key="org.alfresco.repo.security.permissions.impl.hibernate.PermissionEntryImpl">${cache.strategy}</prop>
                <prop key="org.alfresco.repo.security.permissions.impl.hibernate.PermissionReferenceImpl">${cache.strategy}</prop>
                <prop key="org.alfresco.repo.security.permissions.impl.hibernate.RecipientImpl">${cache.strategy}</prop>
            </props>
        </property>
        <property name="collectionCacheStrategies" >
            <props>
                <prop key="org.alfresco.repo.domain.hibernate.NodeImpl.properties">${cache.strategy}</prop>
                <prop key="org.alfresco.repo.domain.hibernate.NodeImpl.aspects">${cache.strategy}</prop>
                <prop key="org.alfresco.repo.domain.hibernate.NodeImpl.parentAssocs">${cache.strategy}</prop>
                <prop key="org.alfresco.repo.domain.hibernate.NodeImpl.childAssocs">${cache.strategy}</prop>
                <prop key="org.alfresco.repo.domain.hibernate.NodeImpl.sourceNodeAssocs">${cache.strategy}</prop>
                <prop key="org.alfresco.repo.domain.hibernate.NodeImpl.targetNodeAssocs">${cache.strategy}</prop>

                <prop key="org.alfresco.repo.security.permissions.impl.hibernate.NodePermissionEntryImpl.permissionEntries">${cache.strategy}</prop>
                <prop key="org.alfresco.repo.security.permissions.impl.hibernate.RecipientImpl.externalKeys">${cache.strategy}</prop>
            </props>
        </property>
    </bean>
    
    <!-- create a transaction manager -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="transactionSynchronizationName">
            <value>SYNCHRONIZATION_ALWAYS</value>
        </property>
        <property name="sessionFactory">
            <ref bean="sessionFactory" />
        </property>
    </bean>

</beans>