Pessoal, tenho a segunte duvida:
Gostaria de integrar as tecnologias (Spring + Hibernate/JPA), e seguindo alguns materiais que encontrei fiz isto:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/projetobase</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="connection.pool_size">10</property>
<mapping class="br.com.projetobase.modelo.Usuario" />
<mapping class="br.com.projetobase.modelo.Endereco" />
<mapping class="br.com.projetobase.modelo.Login" />
</session-factory>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
<property name="configLocation" value="/WEB-INF/hibernate.cfg.xml" />
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="c3p0.min_size">20</prop>
<prop key="c3p0.max_size">75</prop>
<prop key="c3p0.timeout">180</prop>
<prop key="c3p0.c3p0.idle_test_period">100</prop>
</props>
</property>
</bean>
package br.com.projetobase.dao.session;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
public class HibernateUtility {
private static SessionFactory sessionFactory;
private static Session session;
static {
try {
sessionFactory = new AnnotationConfiguration().configure(
"/hibernate.cfg.xml").buildSessionFactory();
} catch (Exception e) {
e.printStackTrace();
sessionFactory = null;
}
}
public static Session getSession() {
return session = sessionFactory.openSession();
}
}
public class HibernateUtility {
private static SessionFactory sessionFactory;
private static Session session;
static {
try {
sessionFactory = new AnnotationConfiguration().configure(
"/hibernate.cfg.xml").buildSessionFactory();
} catch (Exception e) {
e.printStackTrace();
sessionFactory = null;
}
}
public static Session getSession() {
return session = sessionFactory.openSession();
}
}
Agora não sei mais para onde ir. Antes eu estava usando Hibernate sem o spring, mas acho que ficaria feio. Então quero fazer desta forma. O que acham?