-->
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.  [ 2 posts ] 
Author Message
 Post subject: Strange error
PostPosted: Thu Feb 22, 2007 1:40 pm 
We have an entity class listed below:

Code:
package uniref.objects;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;



@Entity() @Table(name="UNIREF_NODES") @SequenceGenerator(name="UNIREF_SEQ", sequenceName="UNIREF_SEQ")
public class Node {

/** Creates a new instance of Node */
public Node() {
}

private Long id = null;
private Date date = null;
private String word = null;

@Id() @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="UNIREF_SEQ")
public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

@Column(name="DATE")
public Date getDate() {
return date;
}

public void setDate(Date date) {
this.date = date;
}

@Column(name="NUMBER")
public String getWord() {
return word;
}

public void setWord(String word) {
this.word = word;
}


}


and a servlet:




Code:
package uniref;

import java.io.*;
import java.util.Date;

import javax.servlet.*;
import javax.servlet.http.*;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import uniref.objects.Node;


public class NewServlet extends HttpServlet {
private static SessionFactory sessionFactory = null;
static {
try {
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
} catch (HibernateException ex) {
ex.printStackTrace();
}
}
/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String newWord = request.getParameter("word");
if (newWord != null) {
Node node = new Node();
node.setDate(new Date(System.currentTimeMillis()));
node.setWord(newWord);
Session session = sessionFactory.openSession();
session.beginTransaction();
try {
session.save(node);
} catch (HibernateException ex) {
ex.printStackTrace();
} finally {
try {
session.getTransaction().commit();
} catch (HibernateException ex) {
ex.printStackTrace();
}
}

}
}


protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}


protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}


public String getServletInfo() {
return "Short description";
}

}


The database contains the tables and a sequence.
But we get a error (the error is thrown when we are trying to commit the transaction):

Code:
Hibernate: select UNIREF_SEQ.nextval from dual
Hibernate: insert into UNIREF_NODES (DATE, NUMBER, id) values (?, ?, ?)
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
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 org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at uniref.NewServlet.processRequest(NewServlet.java:53)
at uniref.NewServlet.doGet(NewServlet.java:69)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.BatchUpdateException: ORA-00928: missing SELECT keyword

at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:367)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:8738)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
... 25 more



I have no idia why the error occurs. And I cant understand where the hibernate has found(or has not found) a "select". The project does not contains any other files except two listed above, hibernate.cfg.xml and tomcat configuration files ofcourse.


Top
  
 
 Post subject:
PostPosted: Fri Feb 23, 2007 9:44 am 
I have solved the problem. The Hibernate is not guilty. Oracle did not like the column named "NUMBER". I replaced it with "ANUMBER" and everything worked fine.


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.