Hibernate version: 2.1.3
This is the mapping file I'm using
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.alluvius.policy.Schedule" table="schedules_tbl">
<id name="id" type="long" column="id">
<generator class="native"/>
</id>
<property name="name" type="string">
<column name="NAME" length="100"/>
</property>
<property name="group" type="string">
<column name="GROUP" length="100"/>
</property>
<property name="startDate" type="date">
<column name="START_DATE"/>
</property>
<property name="endDate" type="date">
<column name="END_DATE"/>
</property>
<property name="hours" type="string">
<column name="HOURS" length="100"/>
</property>
<property name="dayOfMonth" type="string">
<column name="DAY_OF_MONTH" length="100"/>
</property>
<property name="months" type="string">
<column name="MONTHS" length="100"/>
</property>
<property name="dayOfWeek" type="string">
<column name="DAY_OF_WEEK" length="100"/>
</property>
</class>
</hibernate-mapping>
I get this when I try to save my Schedule object:
Code:
Hibernate: insert into schedules_tbl (NAME, GROUP, START_DATE, END_DATE, HOURS, DAY_OF_MONTH, MONTHS, DAY_OF_WEEK) values (?, ?, ?, ?, ?, ?, ?, ?)
13:27:29,265 WARN JDBCExceptionReporter:38 - SQL Error: 1064, SQLState: 42000
13:27:29,281 ERROR JDBCExceptionReporter:46 - Syntax error or access violation, message from server: "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 'GROUP, START_DATE, END_DATE, HOURS, DAY_OF_MONTH, MONTHS, DAY_O"
net.sf.hibernate.JDBCException: could not insert: [com.alluvius.policy.Schedule]
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:556)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:925)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:850)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:768)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:731)
at com.alluvius.vault.ScheduleVault.store(ScheduleVault.java:30)
at com.alluvius.vault.ScheduleVault.main(ScheduleVault.java:44)
Caused by: java.sql.SQLException: Syntax error or access violation, message from server: "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 'GROUP, START_DATE, END_DATE, HOURS, DAY_OF_MONTH, MONTHS, DAY_O"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1905)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1109)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1203)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2090)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1680)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1527)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:526)
... 8 more
I'm pretty new to Hibernate and don't quite understand the id generation. I am using MySQL and I've successfully saved some other objects so I'm not sure what's wrong with this one. Any help appreciated.