Guest User

Untitled

a guest
Sep 3rd, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. @Configuration
  2. @EnableTransactionManagement
  3. public class PersistenceContext {
  4.  
  5. @Primary
  6. @Bean
  7. public DataSourceProperties dataSourceProperties() {
  8. return new DataSourceProperties();
  9. }
  10.  
  11. @Bean
  12. public DataSource dataSource(DataSourceProperties properties) {
  13. return properties
  14. .initializeDataSourceBuilder()
  15. .type(HikariDataSource.class)
  16. .build();
  17. }
  18.  
  19. @Bean
  20. public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
  21. final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
  22. em.setDataSource(dataSource(dataSourceProperties()));
  23. em.setPackagesToScan("model");
  24. em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
  25. return em;
  26. }
  27.  
  28. @Bean
  29. public PlatformTransactionManager transactionManager(final EntityManagerFactory emf) {
  30. return new JpaTransactionManager(emf);
  31. }
  32.  
  33. }
  34.  
  35. 10:37:47.951 [main] DEBUG org.hibernate.SQL - insert into Book (id, author, bookType, bookstore, new_price, old_price, title, url) values (null, ?, ?, ?, ?, ?, ?, ?)
  36. 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, ?, ?, ?, ?, ?, ?, ?)]
  37. org.h2.jdbc.JdbcSQLException: Table "BOOK" not found; SQL statement:
  38. insert into Book (id, author, bookType, bookstore, new_price, old_price, title, url) values (null, ?, ?, ?, ?, ?, ?, ?) [42102-197]
  39. at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
  40.  
  41. spring.datasource.url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
  42. spring.datasource.platform=h2
  43. spring.datasource.username=sa
  44. spring.datasource.password=
  45. spring.datasource.driver-class-name=org.h2.Driver
  46.  
  47. spring.jpa.hibernate.ddl-auto=create-drop
  48. spring.jpa.generate-ddl=true
  49. spring.data.jpa.repositories.enabled=true
  50. spring.jpa.properties.hibernate.hbm2ddl.auto=create-drop
  51. spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
  52. spring.jpa.show-sql=true
  53.  
  54. spring.h2.console.enabled=true
  55. spring.h2.console.path=/h2-console
Add Comment
Please, Sign In to add comment