Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Error saving objects in oracle

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to hibernate. To get familiar with hibernate, I tried tutorial at http://homepage.mac.com/edahand/projects/java/example1.html. Although this tutorial is for mysql, I changed the hinernate properties to use oracle.

hibernate.dialect net.sf.hibernate.dialect.OracleDialect
hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
#hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc racle:thin:@localhost:1521:***
hibernate.connection.username scott
hibernate.connection.password tiger


The table I created is :
CREATE TABLE item (
id number NOT NULL,
name varchar2(32) NOT NULL,
description varchar2(32),
PRIMARY KEY (id)
);


I changed generator class from 'identity' to 'native' as I read that oracle9i does not support 'identity'.

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

<hibernate-mapping>
<class name="com.edhand.example1.Item" table="item" >
<id name="id" column="id" type="java.lang.Long" unsaved-value="0">
<generator class="native"/>
</id>
<property name="name" column="name" type="java.lang.String" />
<property name="description" column="description" type="java.lang.String" />
</class>
</hibernate-mapping>

Everything works fine till I try to save the object. Hibernate is connecting to oracle 9i, but when I try to add new data it gives me exception:

javax.servlet.ServletException: net.sf.hibernate.JDBCException: Could not save object
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.RuntimeException: net.sf.hibernate.JDBCException: Could not save object
com.edhand.example1.ItemService.addItem(Unknown Source)
com.edhand.example1.AddItemAction.execute(Unknown Source)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


I would appreciate if somebody could help me what this exception means and how to get rid of it.

Thanks,
 
Why should I lose weight? They make bigger overalls. And they sure don't make overalls for tiny ads:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic