-->
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.  [ 1 post ] 
Author Message
 Post subject: org.hibernate.exception.SQLGrammarException in hibernate
PostPosted: Wed Dec 29, 2010 6:21 am 
Newbie

Joined: Wed Dec 29, 2010 6:11 am
Posts: 1
Hi
I am not able to insert data in to database table . I followed some previous posts in the same forum but none of them are helpful.
Please help.

Thanks for your help in Advance.

The following are the details ;

My bean

Code:
public class BasicInfo {
   private String firstName;
   private String lastName;
   private String emailId;
   private long id = -1l;
   
   public String getFirstName() {
      return firstName;
   }
   public void setFirstName(String firstName) {
      this.firstName = firstName;
   }
   public String getLastName() {
      return lastName;
   }
   public void setLastName(String lastName) {
      this.lastName = lastName;
   }
   public String getEmailId() {
      return emailId;
   }
   public void setEmailId(String emailId) {
      this.emailId = emailId;
   }
   public long getId() {
      return id;
   }
   public void setId(long id) {
      this.id = id;
   }
   
}


My Hibernate config file

Code:
<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
   <session-factory>
      <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
      <property name="hibernate.connection.url">jdbc:oracle:thin:hellodb/hellodb@122.222.10.1:1521:orathin</property>
      <property name="hibernate.connection.username">hellodb</property>
         <property name="hibernate.connection.password">hellodb</property>
         <property name="hibernate.connection.pool_size">5</property>
         <property name="show_sql">true</property>
         <property name="dialect">org.hibernate.dialect.OracleDialect</property>
         <property name="hibernate.hbm2ddl.auto">update</property>
         <property name="hibernate.jdbc.batch_size">0</property>
        <!-- Mapping files -->
         <mapping resource="basicinfo.hbm.xml"/>
   </session-factory>
</hibernate-configuration>


My Hbm file

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
  <class name="my.hibernate.basic.cls.BasicInfo" table="MY_TEST_TABLE">
   <id name="id" type="long" column="'ID'" >
   <generator class="assigned"/>
  </id>

  <property name="firstName">
     <column name="'FIRST_NAME'" />
  </property>
  <property name="lastName">
    <column name="'LAST_NAME'"/>
  </property>
  <property name="emailId">
    <column name="'E-MAIL'"/>
  </property>
</class>
</hibernate-mapping>


My main method :

Code:
public class Mymain {
   public static void main(String[] args) {
      Session hibernateSession = null;
      try{
         SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
         hibernateSession = sessionFactory.openSession();
         
         BasicInfo bInfo = new BasicInfo();
         bInfo.setFirstName("Sachin2");
         bInfo.setLastName("Tendulkar2");
         bInfo.setEmailId("sTendulkar@gmail2.com");
         hibernateSession.save(bInfo);
      }catch(Exception e){
         e.printStackTrace();
      }finally{
         hibernateSession.flush();
         hibernateSession.close();
      }
   }

}


Stack trace of errors

Dec 29, 2010 3:13:56 PM org.hibernate.event.def.AbstractFlushingEventListener performExecutions
SEVERE: Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: could not insert: [my.hibernate.basic.cls.BasicInfo]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2267)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at Mymain.main(Mymain.java:46)
Caused by: java.sql.SQLException: ORA-00928: missing SELECT keyword

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:219)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:970)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1190)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3370)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3454)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2247)
... 9 more
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert: [my.hibernate.basic.cls.BasicInfo]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2267)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at Mymain.main(Mymain.java:46)
Caused by: java.sql.SQLException: ORA-00928: missing SELECT keyword

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:219)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:970)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1190)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3370)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3454)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2247)
... 9 more


Please let me know if you need any more info.

Thanks



I am getting these exception while flushing the content.
Can anyone please help me out here.

Thanks for your help in advance.


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

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.