Senhores estou usando o banco de dados oracle ao invés do mysql, já fiz toda configuração no JpaConfigurator.java
DriverManagerDataSource dataSource = new
DriverManagerDataSource();
dataSource.setDriverClassName("oracle.jdbc.OracleDriver");
dataSource.setUrl("jdbc:oracle:thin:@localhost:1521/xe");
dataSource.setUsername("SYSTEM");
dataSource.setPassword("123");
return dataSource;
LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
entityManagerFactory.setPackagesToScan("br.com.caelum");
entityManagerFactory.setDataSource(dataSource);
entityManagerFactory
.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
Properties props = new Properties();
props.setProperty("hibernate.dialect", "org.hibernate.dialect.OracleDialect");
props.setProperty("hibernate.show_sql", "true");
props.setProperty("hibernate.hbm2ddl.auto", "create-drop");
entityManagerFactory.setJpaProperties(props);
return entityManagerFactory;
Troquei para sequence na criação das tabelas, exemplo abaixo
@Id
@SequenceGenerator(name = "seq_id_produto", sequenceName = "seq_id_produto", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_id_produto")
private Integer id;
Mas estou tendo o seguinte error ao iniciar o tomcat (erro resumido)
set 18, 2019 9:04:23 PM org.apache.catalina.core.StandardContext listenerStart
GRAVE: Exceção ao enviar evento de contexto iniciado para instância listener da classe [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'criadorDeProdutos': Invocation of init method failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement
Caused by: org.hibernate.exception.SQLGrammarException: could not execute statement
Caused by: java.sql.SQLSyntaxErrorException: ORA-00942: a tabela ou view não existe
Caused by: Error : 942, Position : 12, Sql = insert into Produto (descricao, linkDaFoto, loja_id, nome, preco, id) values (:1 , :2 , :3 , :4 , :5 , :6 ), OriginalSql = insert into Produto (descricao, linkDaFoto, loja_id, nome, preco, id) values (?, ?, ?, ?, ?, ?), Error Msg = ORA-00942: a tabela ou view não existe
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:498)
... 84 more
Poderiam me ajudar, com isso?