Reputation: 86
I have created a spring application with MySql db connected and I want the hibernate to create tables using Innodb engine but it always creates the table using MyISAM engine.
the application.properties
file:
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/spring?autoReconnect=true&useSSL=false
spring.datasource.username=root
spring.datasource.password=
The hibernate.properties
file:
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.dialect.storage_engine=innodb
The console output:
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.3.RELEASE)
2017-12-18 13:54:19.460 INFO 9144 --- [ main] hello.Application : Starting Application on webc13 with PID 9144 (C:\spring\gs-rest-service\complete\build\classes\main started by Arielb in C:\spring\gs-rest-service\complete)
2017-12-18 13:54:19.465 INFO 9144 --- [ main] hello.Application : No active profile set, falling back to default profiles: default
2017-12-18 13:54:19.506 INFO 9144 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@44a3ec6b: startup date [Mon Dec 18 13:54:19 IST 2017]; root of context hierarchy
2017-12-18 13:54:20.802 WARN 9144 --- [ main] o.h.v.m.ParameterMessageInterpolator : HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported
2017-12-18 13:54:21.102 WARN 9144 --- [ main] o.h.v.m.ParameterMessageInterpolator : HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported
2017-12-18 13:54:21.371 INFO 9144 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-12-18 13:54:21.380 INFO 9144 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-12-18 13:54:21.381 INFO 9144 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.14
2017-12-18 13:54:21.517 INFO 9144 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-12-18 13:54:21.518 INFO 9144 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2014 ms
2017-12-18 13:54:21.634 INFO 9144 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-12-18 13:54:21.638 INFO 9144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-12-18 13:54:21.639 INFO 9144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-12-18 13:54:21.639 INFO 9144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-12-18 13:54:21.639 INFO 9144 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-12-18 13:54:22.051 INFO 9144 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-12-18 13:54:22.060 INFO 9144 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2017-12-18 13:54:22.114 INFO 9144 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2017-12-18 13:54:22.116 INFO 9144 --- [ main] org.hibernate.cfg.Environment : HHH000205: Loaded properties from resource hibernate.properties: {hibernate.dialect=org.hibernate.dialect.MySQLMyISAMDialect, spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLMyISAMDialect, hibernate.bytecode.use_reflection_optimizer=false, hibernate.dialect.storage_engine=myisam}
2017-12-18 13:54:22.117 INFO 9144 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2017-12-18 13:54:22.151 INFO 9144 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-12-18 13:54:22.236 INFO 9144 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2017-12-18 13:54:22.527 INFO 9144 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update
2017-12-18 13:54:22.555 INFO 9144 --- [ main] rmationExtractorJdbcDatabaseMetaDataImpl : HHH000262: Table not found: logs
2017-12-18 13:54:22.555 INFO 9144 --- [ main] rmationExtractorJdbcDatabaseMetaDataImpl : HHH000262: Table not found: logs
2017-12-18 13:54:22.741 INFO 9144 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-12-18 13:54:23.178 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@44a3ec6b: startup date [Mon Dec 18 13:54:19 IST 2017]; root of context hierarchy
2017-12-18 13:54:23.231 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/dd/one/{id}],methods=[GET]}" onto public hello.Files hello.controller.InspectorController.getFile(java.lang.Integer)
2017-12-18 13:54:23.232 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/dd/all],methods=[GET]}" onto public java.lang.Iterable<hello.Files> hello.controller.InspectorController.getAllUsers()
2017-12-18 13:54:23.232 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/dd/insert],methods=[POST]}" onto public hello.Files hello.controller.InspectorController.saveFiles(java.lang.String,java.util.Date,java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest) throws javassist.tools.web.BadHttpRequest
2017-12-18 13:54:23.232 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/greeting]}" onto public hello.Greeting hello.GreetingController.greeting(java.lang.String)
2017-12-18 13:54:23.234 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-12-18 13:54:23.234 INFO 9144 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-12-18 13:54:23.259 INFO 9144 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-12-18 13:54:23.259 INFO 9144 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-12-18 13:54:23.287 INFO 9144 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-12-18 13:54:23.459 INFO 9144 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-12-18 13:54:23.504 INFO 9144 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-12-18 13:54:23.508 INFO 9144 --- [ main] hello.Application : Started Application in 4.291 seconds (JVM running for 4.77)
Any idea?
finally, the only way I managed to reach the desired engine was to set the my.conf
file:
default-storage-engine=InnoDB
Upvotes: 1
Views: 4789
Reputation: 375
spring.jpa.database-platform: org.hibernate.dialect.MySQL57InnoDBDialect
work for me, but MySQL57InnoDBDialect was marked as deprecated.
It suggested that using hibernate.dialect.storage_engine=innodb
but it is not working for me.
So I keep MySQL57InnoDBDialect
.
Upvotes: 0
Reputation: 527
change your hibernate.properties
file to
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.dialect.storage_engine=innodb
and then try it. MySQL5InnoDBDialect
is deprecated .
Upvotes: 1
Reputation: 8280
According to this post, the MySQL5InnoDBDialect
has been deprecated, the class to use is MySQL5Dialect
.
So you need to change the dialect :
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.dialect.storage_engine=innodb
If it doesn't work, try using the spring jpa properties :
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
Upvotes: 2