package br.com.casadocodigo.loja.conf;
import java.util.Properties;
import org.springframework.orm.hibernate3.annotation.*;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
public class JPAConfiguration {
@Bean
public void entityManagerFactory(){
LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();//JpaVendorAdapter é uma classe abstrata vou somente dar um new em uma de suas classes concretas
factoryBean.setJpaVendorAdapter(vendorAdapter);
DriverManagerDataSource datasource = new DriverManagerDataSource();
datasource.setUsername("root");
datasource.setPassword("121212");
datasource.setUrl("jdbc:mysql://localhost:3306/casadocodigo");
datasource.setDriverClassName("com.mysql.jdbc.Driver");
factoryBean.setDataSource(datasource);
Properties props= new Properties();
props.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
props.setProperty("hibernate.show_sql", "true");
props.setProperty("hibernate.hbm2ddl", "update");//O update quer dizer que toda vez que mudarmos o modelo o hibernate mude tbm
factoryBean.setJpaProperties(props);
factoryBean.setP