Galera, estou usando o exemplo apresentado no curso, porém estou tentando usar o o Orcale, mas após vários erros corridigos e tentativas estou caindo nesse erro:
org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction
org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:524)
Alguem tem alguma ideia?
Produto DAO:
@Repository
@Transactional
public class ProdutoDAO {
@PersistenceContext
protected EntityManager manager;
public void gravarProduto(Produto produto){
manager.persist(produto);
}
}
JPAConfiguration:
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(){
LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
factoryBean.setJpaVendorAdapter(vendorAdapter);
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
dataSource.setUrl("jdbc:oracle:thin:@localhost:1521:XE");
dataSource.setUsername("system");
dataSource.setPassword("EYbr2017#");
factoryBean.setDataSource(dataSource);
Properties props = new Properties();
props.setProperty("hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect");
props.setProperty("hibernate.show_sql", "true");
props.setProperty("hibernate.format_sql", "true");
props.setProperty("hibernate.hbm2ddl.auto", "update");
props.setProperty("hibernate.default_schema", "system");
props.setProperty("connection.pool_size", "5");
factoryBean.setJpaProperties(props);
factoryBean.setPackagesToScan("org.testeSpringHibernate.models");
return factoryBean;
}
@Bean
JpaTransactionManager transactionManager(EntityManagerFactory emf){
return new JpaTransactionManager(emf);
}