Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Configuration
- @EnableTransactionManagement
- public class PersistenceContext {
- @Primary
- @Bean
- public DataSourceProperties dataSourceProperties() {
- return new DataSourceProperties();
- }
- @Bean
- public DataSource dataSource(DataSourceProperties properties) {
- return properties
- .initializeDataSourceBuilder()
- .type(HikariDataSource.class)
- .build();
- }
- @Bean
- public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
- final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
- em.setDataSource(dataSource(dataSourceProperties()));
- em.setPackagesToScan("model");
- em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
- return em;
- }
- @Bean
- public PlatformTransactionManager transactionManager(final EntityManagerFactory emf) {
- return new JpaTransactionManager(emf);
- }
- }
- 10:37:47.951 [main] DEBUG org.hibernate.SQL - insert into Book (id, author, bookType, bookstore, new_price, old_price, title, url) values (null, ?, ?, ?, ?, ?, ?, ?)
- 10:37:47.955 [main] DEBUG o.h.e.jdbc.spi.SqlExceptionHelper - could not prepare statement [insert into Book (id, author, bookType, bookstore, new_price, old_price, title, url) values (null, ?, ?, ?, ?, ?, ?, ?)]
- org.h2.jdbc.JdbcSQLException: Table "BOOK" not found; SQL statement:
- insert into Book (id, author, bookType, bookstore, new_price, old_price, title, url) values (null, ?, ?, ?, ?, ?, ?, ?) [42102-197]
- at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
- spring.datasource.url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
- spring.datasource.platform=h2
- spring.datasource.username=sa
- spring.datasource.password=
- spring.datasource.driver-class-name=org.h2.Driver
- spring.jpa.hibernate.ddl-auto=create-drop
- spring.jpa.generate-ddl=true
- spring.data.jpa.repositories.enabled=true
- spring.jpa.properties.hibernate.hbm2ddl.auto=create-drop
- spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
- spring.jpa.show-sql=true
- spring.h2.console.enabled=true
- spring.h2.console.path=/h2-console
Add Comment
Please, Sign In to add comment