Olá, eu estou tentando fazer uma aplicação usando JSF + Hibernate + Spring e estou me enrolando nessa parte de integração do hibernate com o spring.
Eu fiz essa configuração do applicationContext.xml, mas parece que tem algo de errado.
No caso a minha aplicação chegar a rodar, porém ele não está criando o banco de dados.
Por isso vem o erro:
Table 'faclube' doesn't exist
Alguém pode me ajudar???
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="annotatedClasses">
<list>
<value>officeMusic.model.Faclube</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
<prop key="hibernate.connection.password">senha</prop>
<prop key="hibernate.connection.url">jdbc:mysql://localhost:3306/banco</prop>
<prop key="hibernate.connection.username">username</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<!-- Configuração do DB -->
<!-- Patch the HSQL error for batching -->
<prop key="hibernate.jdbc.batch_size" >0</prop>
<!-- Enable Hibernate's automatic session context management -->
<prop key="current_session_context_class">thread</prop>
<!-- Disable the second-level cache -->
<prop key="cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
<!-- Echo all executed SQL to stdout -->
<prop key="hibernate.show_sql" >true</prop>
<prop key="hibernate.format_sql" >true</prop>
<prop key="hibernate.use_sql_comments">true</prop>
<!-- Drop and re-create the database schema on startup -->
<!-- <property name="hbm2ddl.auto">update</property> -->
<prop key="hbm2ddl.auto">create-drop</prop>
</props>
</property>
</bean>
<!-- enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
<!-- Identifica os beans anotados com @Service, @Repository, @Controller -->
<context:component-scan base-package="officeMusic.action" />
<!-- Habilita a configuracao de beans via anotacoes
sem a necessidade de usar PersistenceAnnotationBeanPostProcessor,
AutowiredAnnotationBeanPostProcessor e etc
-->
<context:annotation-config />
<!-- Trabalha com a anotacao @Autowired
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
-->
<!-- Trabalha com a anotacao @Resource -->
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<!-- Declaracao de Beans no Spring -->
<bean id="anexoDao" class="officeMusic.dao.impl.AnexoDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="faclubeDao" class="officeMusic.dao.impl.FaclubeDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- Envia E-mail -->
<bean id="enviarEmail" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="HOST"/>
<property name="username" value="USUARIO@HOST"/>
<property name="password" value="SUA_SENHA"/>
</bean>
</beans>