Я не могу вставить запись.я использую hibernate и mysql.
файлы выглядят следующим образом ...
Route.hbm.xml
<id name="routeId" type="java.lang.Integer" unsaved-value="null">
<column name="ROUTE_ID" not-null="true" />
<generator class="increment" />
</id>
<property name="routeName" type="java.lang.String" column="ROUTE_NAME" />
<property name="from" type="java.lang.String" column="FROM" />
<property name="to" type="java.lang.String" column="TO" />
<property name="distance" type="java.lang.Integer" column="DISTANCE" />
<property name="time" type="java.lang.Integer" column="TIME" />
RouteDTO.java
private static final long serialVersionUID = 1L;
private Integer routeId;
private String routeName;
private String from;
private String to;
private Integer distance;
private Integer time;
public Integer getRouteId() {
return routeId;
}
public void setRouteId(Integer routeId) {
this.routeId = routeId;
}
.
.
.
.
Структура таблицы -
CREATE TABLE `route` (
`ROUTE_ID` int(5) NOT NULL AUTO_INCREMENT,
`ROUTE_NAME` varchar(20) NOT NULL,
`FROM` varchar(20) NOT NULL,
`TO` varchar(20) NOT NULL,
`DISTANCE` int(11) DEFAULT NULL,
`TIME` int(11) DEFAULT NULL,
PRIMARY KEY (`ROUTE_ID`)
)
, когда я пытаюсь сохранить эту запись с помощью RoutDAO.java
, код -
getHibernateTemplate().save(routeDto);
, это выдает мне ошибку следующим образом ....
Hibernate: select routedto0_.ROUTE_ID as ROUTE1_, routedto0_.ROUTE_NAME as ROUTE2_0_, routedto0_.FROM as FROM0_, routedto0_.TO as TO0_, routedto0_.DISTANCE as DISTANCE0_, routedto0_.TIME as TIME0_ from ROUTE routedto0_
Hibernate: insert into ROUTE (ROUTE_NAME, FROM, TO, DISTANCE, TIME, ROUTE_ID) values (?, ?, ?, ?, ?, ?)
Apr 15, 2011 9:04:03 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 1064, SQLState: 42000
Apr 15, 2011 9:04:03 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: 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 'FROM, TO, DISTANCE, TIME, ROUTE_ID) values ('A099', 'Hadapser', 'Pune Station', ' at line 1
Apr 15, 2011 9:04:03 PM org.hibernate.event.def.AbstractFlushingEventListener performExecutions
SEVERE: Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:179)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:726)
......
Caused by: java.sql.BatchUpdateException:
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 'FROM, TO, DISTANCE, TIME, ROUTE_ID) values
('A099', 'Hadapser', 'Pune Station', ' at line 1
at
com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2024)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1449)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:172)
... 58 more
Пожалуйста, помогите мне ...