前提・実現したいこと
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as task5_1_, vehicles0_.task_type as task_typ6_1_, vehicles0_.tvehicle_code as vehicle_co' at line
が原因のエラーを解決したい
発生している問題・エラーメッセージ
HTTPステータス 500 - org.hibernate.exception.SQLGrammarException: could not extract ResultSet type 例外レポート メッセージ org.hibernate.exception.SQLGrammarException: could not extract ResultSet 説明 The server encountered an internal error that prevented it from fulfilling this request. 例外 javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet 原因 org.hibernate.exception.SQLGrammarException: could not extract ResultSet 原因 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as task5_1_, trucks0_.task_type as task_typ6_1_, trucks0_.truck_code as truck_co' at line 1 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
該当のソースコード
package models; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; @Table(name = "trucks") @NamedQueries({ @NamedQuery( name = "getAllTrucks", query = "SELECT t FROM Trucks AS t ORDER BY t.id DESC" ), @NamedQuery( name = "getTrucksCount", query = "SELECT COUNT(t) FROM Trucks AS t" ), }) @Entity public class Vehicles{ @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; @Column(name = "task_date", nullable = false) private java.sql.Date task_date; @Column(name = "task time", nullable = false) private java.sql.Time task_time; @Column(name = "task_type", nullable = false) private String task_type; @Column(name = "office_name", nullable = false) private String office_name; @Column(name = "vehicle_code", nullable = false) private String vehicle_code; @Column(name = "stack_area", nullable = false) private String stack_area; @Column(name = "wholesale_area", nullable = false) private String wholesale_area; @Column(name = "vehicle_type", nullable = false) private String vehicle_type; Trucksテーブル *************************** 1. row *************************** Table: trucks Create Table: CREATE TABLE `trucks` ( `id` int(11) NOT NULL AUTO_INCREMENT, `office_name` varchar(10) DEFAULT NULL, `truck_code` varchar(15) DEFAULT NULL, `truck_type` varchar(10) DEFAULT NULL, `task_date` date DEFAULT NULL, `stack_area` varchar(10) DEFAULT NULL, `wholesale_area` varchar(10) DEFAULT NULL, `task_time` time DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8
新たなエラー
HTTPステータス 500 - org.hibernate.exception.SQLGrammarException: could not extract ResultSet type 例外レポート メッセージ org.hibernate.exception.SQLGrammarException: could not extract ResultSet 説明 The server encountered an internal error that prevented it from fulfilling this request. 例外 javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:149) org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157) org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1423) org.hibernate.query.Query.getResultList(Query.java:146) controllers.dispatch.DispatchIndexServlet.doGet(DispatchIndexServlet.java:45) javax.servlet.http.HttpServlet.service(HttpServlet.java:622) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) filters.LoginFilter.doFilter(LoginFilter.java:72) filters.EncodingFilter.doFilter(EncodingFilter.java:38) 原因 org.hibernate.exception.SQLGrammarException: could not extract ResultSet org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:63) org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111) org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97) org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:69) org.hibernate.loader.Loader.getResultSet(Loader.java:2168) org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1931) org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1893) org.hibernate.loader.Loader.doQuery(Loader.java:938) org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341) org.hibernate.loader.Loader.doList(Loader.java:2692) org.hibernate.loader.Loader.doList(Loader.java:2675) org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2507) org.hibernate.loader.Loader.list(Loader.java:2502) org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502) org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:392) org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216) org.hibernate.internal.SessionImpl.list(SessionImpl.java:1490) org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1445) org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414) org.hibernate.query.Query.getResultList(Query.java:146) controllers.dispatch.DispatchIndexServlet.doGet(DispatchIndexServlet.java:45) javax.servlet.http.HttpServlet.service(HttpServlet.java:622) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) filters.LoginFilter.doFilter(LoginFilter.java:72) filters.EncodingFilter.doFilter(EncodingFilter.java:38) 原因 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'trucks0_.task_type' in 'field list' sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) java.lang.reflect.Constructor.newInstance(Constructor.java:423) com.mysql.jdbc.Util.handleNewInstance(Util.java:425) com.mysql.jdbc.Util.getInstance(Util.java:408) com.mysql.jdbc.SQLError.createSQLException(SQLError.java:944) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909) com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527) com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680) com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2484) com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858) com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1966) org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:60) org.hibernate.loader.Loader.getResultSet(Loader.java:2168) org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1931) org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1893) org.hibernate.loader.Loader.doQuery(Loader.java:938) org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341) org.hibernate.loader.Loader.doList(Loader.java:2692) org.hibernate.loader.Loader.doList(Loader.java:2675) org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2507) org.hibernate.loader.Loader.list(Loader.java:2502) org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502) org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:392) org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216) org.hibernate.internal.SessionImpl.list(SessionImpl.java:1490) org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1445) org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414) org.hibernate.query.Query.getResultList(Query.java:146) controllers.dispatch.DispatchIndexServlet.doGet(DispatchIndexServlet.java:45) javax.servlet.http.HttpServlet.service(HttpServlet.java:622) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) filters.LoginFilter.doFilter(LoginFilter.java:72) filters.EncodingFilter.doFilter(EncodingFilter.java:38)
補足情報(FW/ツールのバージョンなど)
使用しているのはEclipse4.6Neonです。
回答1件
あなたの回答
tips
プレビュー