-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Error in SQL syntax?
PostPosted: Fri Jun 25, 2004 4:36 pm 
Newbie

Joined: Fri Jun 25, 2004 4:25 pm
Posts: 4
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.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 25, 2004 4:37 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
probably a reserved word in there somewhere. try quoting column names


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 25, 2004 4:42 pm 
Newbie

Joined: Fri Jun 25, 2004 4:25 pm
Posts: 4
Awesome, thanks Gavin. Googled for MySQL keywords and GROUP was indeed a keyword. =)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.