How to Fix SQL Error: 1054, SQLState: 42S22 Unknown column ‘markcardex0_.art_service_time’ in ‘field list’

SQL Error: 1054, SQLState: 42S22 this is the Error caused by the missing field, first attach the Error log:

2020-03-04 10:30:00. 221 WARN [pool – 8 – thread – 1] [org. Hibernate. Engine. JDBC. Spi. SqlExceptionHelper. Java: 127] – SQL Error: 1054, SQLState: 42 s22
the 2020-03-04 10:30:00. 221 ERROR [pool – 8 – thread – 1] [org. Hibernate. Engine. JDBC. Spi. SqlExceptionHelper. Java: 129] – Unknown column ‘markcardex0_. Art_service_time’ in ‘field List ‘
the 2020-03-04 10:30:00. 225 ERROR [pool – 8 – thread – 1] [org. Springframework. Scheduling. Support. TaskUtils $LoggingErrorHandler. Java: 95] – Unexpected ERROR occurred in scheduled task.
org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; Nested exception is org. Hibernate. Exception….

under Caused by: org. Hibernate. Exception. SQLGrammarException: could not extract the ResultSet
… 24 common frames omitted
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column ‘markcardex0_. Art_service_time’ in ‘the field list’
the at sun, reflect the NativeConstructorAccessorImpl. NewInstance0 (Native Method)
the at Sun. Reflect. NativeConstructorAccessorImpl. NewInstance (NativeConstructorAccessorImpl. Java: 62)
the at Sun. Reflect. DelegatingConstructorAccessorImpl. NewInstance (DelegatingConstructorAccessorImpl. Java: 45)
the at Java lang. Reflect. Constructor. NewInstance (423) Constructor. Java:
the at Com. Mysql. JDBC. Util. HandleNewInstance Util. Java: (411)
at the mysql. JDBC. Util. GetInstance (Util. Java: 386)
at the mysql. JDBC. SQLError. CreateSQLException (SQLError. Java: 1053)
the at Com. Mysql. JDBC. MysqlIO. CheckErrorPacket MysqlIO. Java: (4074)
at the mysql. JDBC. MysqlIO. CheckErrorPacket (MysqlIO. Java: 4006)
at the mysql. JDBC. MysqlIO. SendCommand (MysqlIO. Java: 2468)
At com. Mysql. JDBC. MysqlIO. SqlQueryDirect (MysqlIO. Java: 2629)
at the mysql. JDBC. ConnectionImpl. ExecSQL (ConnectionImpl. Java: 2719)
the at . Com. Mysql. JDBC PreparedStatement. ExecuteInternal (PreparedStatement. Java: 2155)
at the mysql.. JDBC PreparedStatement. ExecuteQuery (2318) a PreparedStatement. Java:
the at Com. Alibaba. Druid. Filter. FilterChainImpl. PreparedStatement_executeQuery (FilterChainImpl. Java: 2714)
the at Com. Alibaba. Druid. Filter. FilterEventAdapter. PreparedStatement_executeQuery (FilterEventAdapter. Java: 465)
the at Com. Alibaba. Druid. Filter. FilterChainImpl. PreparedStatement_executeQuery (FilterChainImpl. Java: 2711)
the at Com. Alibaba. Druid. Proxy. JDBC. PreparedStatementProxyImpl. ExecuteQuery (PreparedStatementProxyImpl. Java: 145)
the at Com. Alibaba. Druid. Pool. DruidPooledPreparedStatement. ExecuteQuery (DruidPooledPreparedStatement. Java: 227)
the at Org. Hibernate. Engine. JDBC. Internal. ResultSetReturnImpl. Extract (ResultSetReturnImpl. Java: 70)
… 60 common frames omitted

error occurs mainly because the variables in the entity class do not match the classes in the database table, which is a headache, especially when the data is complex. I used to be stupid, one by one, but now I can sum up a simple method:

1. Look at the reason for this error: Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column ‘markcardex0_. Art_service_time ‘in ‘field List’ is Unknown column ‘markcardex0_. Art_service_time ‘in ‘field list’ is Unknown column’ mark_service_time ‘in ‘field list’ Find –> Find In Path) quickly search artServiceTime, Find the entity class that defines the variable artServiceTime, click In, as follows:

2. After entering the entity class corresponding to this variable, you can see the database Table corresponding to this entity through the annotation @table (name = “uk_markcard_xxxx”) :

opens the database and verifies the existence of this attribute in the table through the query, as follows:

as shown in the figure above, we found the same error as the console, at this time we add the corresponding entity variable property on the table, note:

(1) attribute type must be the same as the entity variable type

(2) MySQL makes no case difference, but if the variable in the entity class is named aaaBcc, the attribute name in the database should be aaa_bcc, not

Read More: