java - Insert Spring Data Field error -


i'm not understanding why generating wrong column name way when inserting table.

i'm using, flyway, spring boot, spring data, spring mvc + thymeleaf in project.

application.properties

spring.datasource.url = jdbc:mysql://localhost:3306/gffdb?usessl=false spring.datasource.username = root spring.datasource.password = root spring.jpa.show-sql = true spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.mysql5dialect   flyway.url=jdbc:mysql://localhost:3306/gffdb?usessl=false flyway.user=root flyway.password=root flyway.schemas=gffdb 

flyway create table

create table tdespesa (     codigodespesa bigint(20) primary key auto_increment,     datadespesa date not null,     valor decimal(5,2) not null,     tipodespesa varchar(50) not null,     formapagamento varchar(50) not null,     observacao varchar(255) null     ) engine=innodb default charset=utf8; 

table tdespesa in data base

tdespesa | create table `tdespesa` (   `codigodespesa` bigint(20) not null auto_increment,   `datadespesa` date not null,   `valor` decimal(5,2) not null,   `tipodespesa` varchar(50) not null,   `formapagamento` varchar(50) not null,   `observacao` varchar(255) default null,   primary key (`codigodespesa`) ) engine=innodb default charset=utf8 

model despesa

@entity @table(name = "tdespesa") public class despesa implements serializable {     private static final long serialversionuid = 1283338922878227530l;      @id     @generatedvalue(strategy = generationtype.identity)     private long codigodespesa;     private date datadespesa;     private bigdecimal valor;     @enumerated(enumtype.string)     private tipodespesa tipodespesa;     @enumerated(enumtype.string)     private formapagamento formapagamento;     private string observacao;      // set ...} 

repository

@repository public interface despesarepository extends jparepository<despesa, long> {  } 

controller

@controller public class despesacontroller {      @autowired private despesaservice despesaservice;      @getmapping("/cadastrodespesa")     public modelandview novo(despesa despesa) {         modelandview model = new modelandview("page/cadastro/despesa/caddespesa");         model.addobject("tiposdespesa", tipodespesa.values());         model.addobject("formaspagamento", formapagamento.values());         return model;     }      @postmapping("/cadastrodespesa")     public modelandview salvar(@modelattribute despesa despesa, bindingresult result, redirectattributes attributes) {         if (result.haserrors()) {             return novo(despesa);         }         despesa.setdatadespesa(new date());         despesaservice.salvardespesa(despesa);         attributes.addflashattribute("mensagem", "despesa salva com sucesso!");         return new modelandview("redirect:/cadastrodespesa");     } } 

log sql

insert tdespesa (data_despesa, forma_pagamento, observacao, tipo_despesa, valor) values (?, ?, ?, ?, ?) 

erro

com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: unknown column 'data_despesa' in 'field list'     @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) ~[na:1.8.0_121]     @ sun.reflect.nativeconstructoraccessorimpl.newinstance(unknown source) ~[na:1.8.0_121]     @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(unknown source) ~[na:1.8.0_121]     @ java.lang.reflect.constructor.newinstance(unknown source) ~[na:1.8.0_121]     @ com.mysql.jdbc.util.handlenewinstance(util.java:425) ~[mysql-connector-java-5.1.41.jar:5.1.41]     @ com.mysql.jdbc.util.getinstance(util.java:408) ~[mysql-connector-java-5.1.41.jar:5.1.41]     @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:943) ~[mysql-connector-java-5.1.41.jar:5.1.41]     @ com.mysql.jdbc.mysqlio.checkerrorpacket(mysqlio.java:3973) ~[mysql-connector-java-5.1.41.jar:5.1.41]     @ com.mysql.jdbc.mysqlio.checkerrorpacket(mysqlio.java:3909) ~[mysql-connector-java-5.1.41.jar:5.1.41]     @ com.mysql.jdbc.mysqlio.sendcommand(mysqlio.java:2527) ~[mysql-connector-java-5.1.41.jar:5.1.41]     @ com.mysql.jdbc.mysqlio.sqlquerydirect(mysqlio.java:2680) ~[mysql-connector-java-5.1.41.jar:5.1.41]     @ com.mysql.jdbc.connectionimpl.execsql(connectionimpl.java:2501) ~[mysql-connector-java-5.1.41.jar:5.1.41]     @ com.mysql.jdbc.preparedstatement.executeinternal(preparedstatement.java:1858) ~[mysql-connector-java-5.1.41.jar:5.1.41]     @ com.mysql.jdbc.preparedstatement.executeupdateinternal(preparedstatement.java:2079) ~[mysql-connector-java-5.1.41.jar:5.1.41]     @ com.mysql.jdbc.preparedstatement.executeupdateinternal(preparedstatement.java:2013) ~[mysql-connector-java-5.1.41.jar:5.1.41]     @ com.mysql.jdbc.preparedstatement.executelargeupdate(preparedstatement.java:5104) ~[mysql-connector-java-5.1.41.jar:5.1.41]     @ com.mysql.jdbc.preparedstatement.executeupdate(preparedstatement.java:1998) ~[mysql-connector-java-5.1.41.jar:5.1.41]     @ org.hibernate.engine.jdbc.internal.resultsetreturnimpl.executeupdate(resultsetreturnimpl.java:204) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.dialect.identity.getgeneratedkeysdelegate.executeandextract(getgeneratedkeysdelegate.java:57) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.id.insert.abstractreturningdelegate.performinsert(abstractreturningdelegate.java:42) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.persister.entity.abstractentitypersister.insert(abstractentitypersister.java:2855) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.persister.entity.abstractentitypersister.insert(abstractentitypersister.java:3426) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.action.internal.entityidentityinsertaction.execute(entityidentityinsertaction.java:81) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.engine.spi.actionqueue.execute(actionqueue.java:619) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.engine.spi.actionqueue.addresolvedentityinsertaction(actionqueue.java:273) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.engine.spi.actionqueue.addinsertaction(actionqueue.java:254) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.engine.spi.actionqueue.addaction(actionqueue.java:299) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.event.internal.abstractsaveeventlistener.addinsertaction(abstractsaveeventlistener.java:317) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.event.internal.abstractsaveeventlistener.performsaveorreplicate(abstractsaveeventlistener.java:272) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.event.internal.abstractsaveeventlistener.performsave(abstractsaveeventlistener.java:178) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.event.internal.abstractsaveeventlistener.savewithgeneratedid(abstractsaveeventlistener.java:109) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.jpa.event.internal.core.jpapersisteventlistener.savewithgeneratedid(jpapersisteventlistener.java:67) ~[hibernate-entitymanager-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.event.internal.defaultpersisteventlistener.entityistransient(defaultpersisteventlistener.java:189) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.event.internal.defaultpersisteventlistener.onpersist(defaultpersisteventlistener.java:132) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.event.internal.defaultpersisteventlistener.onpersist(defaultpersisteventlistener.java:58) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.internal.sessionimpl.firepersist(sessionimpl.java:775) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.internal.sessionimpl.persist(sessionimpl.java:748) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.internal.sessionimpl.persist(sessionimpl.java:753) ~[hibernate-core-5.0.12.final.jar:5.0.12.final]     @ org.hibernate.jpa.spi.abstractentitymanagerimpl.persist(abstractentitymanagerimpl.java:1146) ~[hibernate-entitymanager-5.0.12.final.jar:5.0.12.final]     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) ~[na:1.8.0_121]     @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) ~[na:1.8.0_121]     @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) ~[na:1.8.0_121]     @ java.lang.reflect.method.invoke(unknown source) ~[na:1.8.0_121]     @ org.springframework.orm.jpa.extendedentitymanagercreator$extendedentitymanagerinvocationhandler.invoke(extendedentitymanagercreator.java:347) ~[spring-orm-4.3.7.release.jar:4.3.7.release]     @ com.sun.proxy.$proxy78.persist(unknown source) ~[na:na]     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) ~[na:1.8.0_121]     @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) ~[na:1.8.0_121]     @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) ~[na:1.8.0_121]     @ java.lang.reflect.method.invoke(unknown source) ~[na:1.8.0_121]     @ org.springframework.orm.jpa.sharedentitymanagercreator$sharedentitymanagerinvocationhandler.invoke(sharedentitymanagercreator.java:298) ~[spring-orm-4.3.7.release.jar:4.3.7.release]     @ com.sun.proxy.$proxy78.persist(unknown source) ~[na:na]     @ org.springframework.data.jpa.repository.support.simplejparepository.save(simplejparepository.java:508) ~[spring-data-jpa-1.11.1.release.jar:na]     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) ~[na:1.8.0_121]     @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) ~[na:1.8.0_121]     @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) ~[na:1.8.0_121]     @ java.lang.reflect.method.invoke(unknown source) ~[na:1.8.0_121]     @ org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.executemethodon(repositoryfactorysupport.java:504) ~[spring-data-commons-1.13.1.release.jar:na]     @ org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.doinvoke(repositoryfactorysupport.java:489) ~[spring-data-commons-1.13.1.release.jar:na]     @ org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.invoke(repositoryfactorysupport.java:461) ~[spring-data-commons-1.13.1.release.jar:na]     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) ~[spring-aop-4.3.7.release.jar:4.3.7.release]     @ org.springframework.data.projection.defaultmethodinvokingmethodinterceptor.invoke(defaultmethodinvokingmethodinterceptor.java:61) ~[spring-data-commons-1.13.1.release.jar:na]     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) ~[spring-aop-4.3.7.release.jar:4.3.7.release]     @ org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation(transactioninterceptor.java:99) ~[spring-tx-4.3.7.release.jar:4.3.7.release]     @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:282) ~[spring-tx-4.3.7.release.jar:4.3.7.release]     @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:96) ~[spring-tx-4.3.7.release.jar:4.3.7.release]     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) ~[spring-aop-4.3.7.release.jar:4.3.7.release]     @ org.springframework.dao.support.persistenceexceptiontranslationinterceptor.invoke(persistenceexceptiontranslationinterceptor.java:136) ~[spring-tx-4.3.7.release.jar:4.3.7.release]     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) ~[spring-aop-4.3.7.release.jar:4.3.7.release]     @ org.springframework.data.jpa.repository.support.crudmethodmetadatapostprocessor$crudmethodmetadatapopulatingmethodinterceptor.invoke(crudmethodmetadatapostprocessor.java:133) ~[spring-data-jpa-1.11.1.release.jar:na]     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) ~[spring-aop-4.3.7.release.jar:4.3.7.release]     @ org.springframework.aop.interceptor.exposeinvocationinterceptor.invoke(exposeinvocationinterceptor.java:92) ~[spring-aop-4.3.7.release.jar:4.3.7.release]     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) ~[spring-aop-4.3.7.release.jar:4.3.7.release]     @ org.springframework.data.repository.core.support.surroundingtransactiondetectormethodinterceptor.invoke(surroundingtransactiondetectormethodinterceptor.java:57) ~[spring-data-commons-1.13.1.release.jar:na]     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) ~[spring-aop-4.3.7.release.jar:4.3.7.release]     @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:213) ~[spring-aop-4.3.7.release.jar:4.3.7.release]     @ com.sun.proxy.$proxy80.save(unknown source) ~[na:na]     @ gervasio.system.service.despesaservice.salvardespesa(despesaservice.java:22) ~[classes/:na]     @ gervasio.system.controller.despesacontroller.salvar(despesacontroller.java:45) ~[classes/:na]     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) ~[na:1.8.0_121]     @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) ~[na:1.8.0_121]     @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) ~[na:1.8.0_121]     @ java.lang.reflect.method.invoke(unknown source) ~[na:1.8.0_121]     @ org.springframework.web.method.support.invocablehandlermethod.doinvoke(invocablehandlermethod.java:205) ~[spring-web-4.3.7.release.jar:4.3.7.release]     @ org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:133) ~[spring-web-4.3.7.release.jar:4.3.7.release]     @ org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:116) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release]     @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlermethod(requestmappinghandleradapter.java:827) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release]     @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:738) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release]     @ org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:85) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release]     @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:963) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release]     @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:897) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release]     @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:970) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release]     @ org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:872) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release]     @ javax.servlet.http.httpservlet.service(httpservlet.java:648) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:846) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release]     @ javax.servlet.http.httpservlet.service(httpservlet.java:729) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:230) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) ~[tomcat-embed-websocket-8.5.11.jar:8.5.11]     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.springframework.web.filter.requestcontextfilter.dofilterinternal(requestcontextfilter.java:99) ~[spring-web-4.3.7.release.jar:4.3.7.release]     @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) ~[spring-web-4.3.7.release.jar:4.3.7.release]     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.springframework.web.filter.httpputformcontentfilter.dofilterinternal(httpputformcontentfilter.java:105) ~[spring-web-4.3.7.release.jar:4.3.7.release]     @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) ~[spring-web-4.3.7.release.jar:4.3.7.release]     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.springframework.web.filter.hiddenhttpmethodfilter.dofilterinternal(hiddenhttpmethodfilter.java:81) ~[spring-web-4.3.7.release.jar:4.3.7.release]     @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) ~[spring-web-4.3.7.release.jar:4.3.7.release]     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.springframework.web.filter.characterencodingfilter.dofilterinternal(characterencodingfilter.java:197) ~[spring-web-4.3.7.release.jar:4.3.7.release]     @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) ~[spring-web-4.3.7.release.jar:4.3.7.release]     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:198) ~[tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:96) [tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:474) [tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:140) [tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:79) [tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:87) [tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:349) [tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.coyote.http11.http11processor.service(http11processor.java:783) [tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.coyote.abstractprocessorlight.process(abstractprocessorlight.java:66) [tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.coyote.abstractprotocol$connectionhandler.process(abstractprotocol.java:798) [tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint.java:1434) [tomcat-embed-core-8.5.11.jar:8.5.11]     @ org.apache.tomcat.util.net.socketprocessorbase.run(socketprocessorbase.java:49) [tomcat-embed-core-8.5.11.jar:8.5.11]     @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) [na:1.8.0_121]     @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) [na:1.8.0_121]     @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) [tomcat-embed-core-8.5.11.jar:8.5.11]     @ java.lang.thread.run(unknown source) [na:1.8.0_121] 

even putting @column in entity fields error occurs.

suppose add spring.jpa.hibernate.ddl-auto=create in application.properties , see if working.

if it's working generate database , change property update


Comments