<?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:gorm="http://grails.org/schema/gorm"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-2.5.xsd
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://grails.org/schema/gorm
       http://grails.org/schema/gorm/gorm.xsd
       http://www.springframework.org/schema/util
       http://www.springframework.org/schema/util/spring-util-2.5.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">


    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="url" value="jdbc:mysql://localhost/gormy"/>
        <property name="password" value=""/>
        <property name="username" value="root"/>
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>

    </bean>
    <!--
        - Message source for this context, loaded from localized "messages_xx" files.
    -->
    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename" value="messages" />
    </bean>

    <gorm:sessionFactory base-package="mprueba" data-source-ref="dataSource"
	                     message-source-ref="messageSource">
        <property name="hibernateProperties">
            <util:map>
                <entry key="hibernate.hbm2ddl.auto" value="update"/>
            </util:map>
        </property>
    </gorm:sessionFactory>

    <!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->
                Activates various annotations to be detected in bean classes:
		Spring's @Required and @Autowired, as well as JSR 250's @Resource.
	-->
    <context:annotation-config/>

    <!--
		Exporter that exposes the Hibernate statistics service via JMX. Autodetects the
		service MBean, using its bean name as JMX object name.
	-->
    <context:mbean-export/>


    <!--
		Instruct Spring to perform declarative transaction management
		automatically on annotated classes.
	-->
    <tx:annotation-driven/>



    <!-- Hibernate's JMX statistics service -->
    <bean name="mprueba:type=HibernateStatistics" class="org.hibernate.jmx.StatisticsService">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

</beans>
