Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Role model
- @Entity
- @Table(name = "role")
- class Role {
- @Id
- @Column(name = "id", unique = true)
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- open var id: Long? = null
- @Column(name = "name", nullable = false)
- lateinit var name: String
- }
- // Application
- interface RoleRepository: CrudRepository<Role, Long>
- @SpringBootApplication
- open class Application {
- @Autowired
- lateinit var roleRepository: RoleRepository
- @Bean
- open fun demo(): CommandLineRunner = CommandLineRunner {
- createRole(roleRepository)
- print("Roles count: " + roleRepository.count() + "\n")
- }
- }
- fun main(args: Array<String>) {
- SpringApplication.run(Application::class.java, *args)
- }
- fun createRole(roleRepository: RoleRepository) {
- val r = Role()
- r.name = "test"
- roleRepository.save(r)
- }
- // Bean Config
- @Configuration
- @EnableTransactionManagement
- open class BeanConfig {
- @Autowired
- lateinit open var entityManagerFactory: EntityManagerFactory
- @Bean
- open fun getSessionFactory() = entityManagerFactory.unwrap(SessionFactory::class.java)
- ?: throw NullPointerException("factory is not a hibernate factory")
- @Bean
- @Autowired
- open fun transactionManager(sessionFactory: SessionFactory) = HibernateTransactionManager(sessionFactory)
- }
- // Output
- :: Spring Boot :: (v1.5.6.RELEASE)
- 2017-08-15 16:32:58.834 INFO 96888 --- [ main] r.t.spring.jpa.versioning.ApplicationKt : Starting ApplicationKt on MBP-Ivan with PID 96888 (/Users/ivansmolin/Projects/spring-jpa-versioning/out/production/classes started by ivansmolin in /Users/ivansmolin/Projects/spring-jpa-versioning)
- 2017-08-15 16:32:58.839 INFO 96888 --- [ main] r.t.spring.jpa.versioning.ApplicationKt : No active profile set, falling back to default profiles: default
- 2017-08-15 16:32:58.927 INFO 96888 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@38364841: startup date [Tue Aug 15 16:32:58 MSK 2017]; root of context hierarchy
- Tue Aug 15 16:33:00 MSK 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
- Tue Aug 15 16:33:00 MSK 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
- Tue Aug 15 16:33:00 MSK 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
- Tue Aug 15 16:33:00 MSK 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
- Tue Aug 15 16:33:00 MSK 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
- Tue Aug 15 16:33:00 MSK 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
- Tue Aug 15 16:33:00 MSK 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
- Tue Aug 15 16:33:00 MSK 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
- Tue Aug 15 16:33:00 MSK 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
- Tue Aug 15 16:33:00 MSK 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
- 2017-08-15 16:33:00.530 INFO 96888 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
- 2017-08-15 16:33:00.547 INFO 96888 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
- name: default
- ...]
- 2017-08-15 16:33:00.608 INFO 96888 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
- 2017-08-15 16:33:00.609 INFO 96888 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
- 2017-08-15 16:33:00.610 INFO 96888 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
- 2017-08-15 16:33:00.664 INFO 96888 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
- 2017-08-15 16:33:00.786 INFO 96888 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL57InnoDBDialect
- 2017-08-15 16:33:01.190 INFO 96888 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
- 2017-08-15 16:33:01.198 DEBUG 96888 --- [ main] org.hibernate.SQL : drop table if exists role
- Hibernate: drop table if exists role
- 2017-08-15 16:33:01.205 DEBUG 96888 --- [ main] org.hibernate.SQL : create table role (id bigint not null auto_increment, name varchar(255) not null, primary key (id)) ENGINE=InnoDB
- Hibernate: create table role (id bigint not null auto_increment, name varchar(255) not null, primary key (id)) ENGINE=InnoDB
- 2017-08-15 16:33:01.230 INFO 96888 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
- 2017-08-15 16:33:01.265 INFO 96888 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
- 2017-08-15 16:33:01.504 INFO 96888 --- [ main] o.s.o.h.HibernateTransactionManager : Using DataSource [org.apache.tomcat.jdbc.pool.DataSource@517566b{ConnectionPool[defaultAutoCommit=null; defaultReadOnly=null; defaultTransactionIsolation=-1; defaultCatalog=null; driverClassName=com.mysql.cj.jdbc.Driver; maxActive=100; maxIdle=100; minIdle=10; initialSize=10; maxWait=30000; testOnBorrow=true; testOnReturn=false; timeBetweenEvictionRunsMillis=5000; numTestsPerEvictionRun=0; minEvictableIdleTimeMillis=60000; testWhileIdle=false; testOnConnect=false; password=********; url=jdbc:mysql://localhost:3306/test_calc?serverTimezone=UTC; username=root; validationQuery=SELECT 1; validationQueryTimeout=-1; validatorClassName=null; validationInterval=3000; accessToUnderlyingConnectionAllowed=true; removeAbandoned=false; removeAbandonedTimeout=60; logAbandoned=false; connectionProperties=null; initSQL=null; jdbcInterceptors=null; jmxEnabled=true; fairQueue=true; useEquals=true; abandonWhenPercentageFull=0; maxAge=0; useLock=false; dataSource=null; dataSourceJNDI=null; suspectTimeout=0; alternateUsernameAllowed=false; commitOnReturn=false; rollbackOnReturn=false; useDisposableConnectionFacade=true; logValidationErrors=false; propagateInterruptState=false; ignoreExceptionOnPreLoad=false; useStatementFacade=true; }] of Hibernate SessionFactory for HibernateTransactionManager
- 2017-08-15 16:33:01.699 INFO 96888 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
- 2017-08-15 16:33:01.768 INFO 96888 --- [ main] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
- 2017-08-15 16:33:01.977 DEBUG 96888 --- [ main] org.hibernate.SQL : select count(*) as col_0_0_ from role role0_
- Hibernate: select count(*) as col_0_0_ from role role0_
- Roles count: 0
- 2017-08-15 16:33:02.032 INFO 96888 --- [ main] r.t.spring.jpa.versioning.ApplicationKt : Started ApplicationKt in 3.573 seconds (JVM running for 3.999)
- 2017-08-15 16:33:02.033 INFO 96888 --- [ Thread-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@38364841: startup date [Tue Aug 15 16:32:58 MSK 2017]; root of context hierarchy
- 2017-08-15 16:33:02.035 INFO 96888 --- [ Thread-3] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
- 2017-08-15 16:33:02.037 INFO 96888 --- [ Thread-3] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
- 2017-08-15 16:33:02.038 WARN 96888 --- [ Thread-3] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method failed on bean with name 'entityManagerFactory': java.lang.IllegalStateException: EntityManagerFactory is closed
- Process finished with exit code 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement