-->
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.  [ 5 posts ] 
Author Message
 Post subject: Mapping configuration for oracle database.
PostPosted: Wed Feb 01, 2006 12:00 pm 
Beginner
Beginner

Joined: Mon Oct 24, 2005 2:45 am
Posts: 23
hi,

Could any one help me for Data insertion into Oracle daabase.

I have Table item in scott/tiger database.
With below coe i could retrive data.
But when i save NEW data ,I could not save to my oracle database table.


I am in doubt with generator class.

Experts please help me!!


-------------------------------

Oracle Database table
---------------------

DROP TABLE ITEM CASCADE CONSTRAINTS ;

CREATE TABLE ITEM (
ID NUMBER (11) NOT NULL,
NAME VARCHAR2 (32) NOT NULL,
DESCRIPTION VARCHAR2 (32) NOT NULL,
CONSTRAINT PKID
PRIMARY KEY ( ID )
USING INDEX
TABLESPACE USERS PCTFREE 10
STORAGE ( INITIAL 128K NEXT 128K PCTINCREASE 0 ))
TABLESPACE USERS NOLOGGING
PCTFREE 10
PCTUSED 40
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 131072
NEXT 131072
MINEXTENTS 1
MAXEXTENTS 4096
FREELISTS 1 FREELIST GROUPS 1 )
NOCACHE;


------------
Item.hbm.xml
----------------
<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>


--------------------------------
ERROR

java.lang.RuntimeException: net.sf.hibernate.JDBCException: Could not save object at com.edhand.example1.ItemService.addItem(Unknown Source) at com.edhand.example1.AddItemAction.execute(Unknown Source) at


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 4:13 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
Parts of your stack trace are missing.
Just a guess:
Do you use the correct id generator? Just try another one (assigned) and use some random values.
I am sure that you can find infos about oracles id generator somewhere in the reference or in the wiki.

Sebastian

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 2:29 am 
Beginner
Beginner

Joined: Mon Oct 24, 2005 2:45 am
Posts: 23
hi Sebastian

Ok i will check with docs in hibernate.meanwhile if you could identify problem please let me know

please find stack trace
---------------------------------
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cac
he is not recommended)
Feb 2, 2006 11:37:27 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
Feb 2, 2006 11:37:27 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use JDBC3 getGeneratedKeys(): false
Feb 2, 2006 11:37:27 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: false
Feb 2, 2006 11:37:27 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: echoing all SQL to stdout
Feb 2, 2006 11:37:27 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {no='N', true=1, yes='Y', false=0}
Feb 2, 2006 11:37:27 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.ehcache.hibernate.Provider
Feb 2, 2006 11:37:27 AM net.sf.hibernate.cfg.Configuration configureCaches
INFO: instantiating and configuring caches
Feb 2, 2006 11:37:27 AM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Feb 2, 2006 11:37:28 AM net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: no JNDI name configured
06/02/02 11:37:28 addItem() -------------- session=net.sf.hibernate.impl.SessionImpl@739f3f
06/02/02 11:37:28 exiasts
06/02/02 11:37:28 OC4J ItemService addItem() --item ={Item: id=234 name=234description=234 }
06/02/02 11:37:28 OC4J ItemService addItem() --session=net.sf.hibernate.impl.SessionImpl@739f3f
Feb 2, 2006 11:37:29 AM net.sf.hibernate.id.TableGenerator generate
SEVERE: could not read a hi value
java.sql.SQLException: ORA-00942: table or view does not exist

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:137)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:304)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:271)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:625)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:499
)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:1003)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:5
31)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1109)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:29
32)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2973)

at net.sf.hibernate.id.TableGenerator.generate(TableGenerator.java:93)
at net.sf.hibernate.id.TableHiLoGenerator.generate(TableHiLoGenerator.java:59)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:747)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:720)
at com.edhand.example1.ItemService.addItem(Unknown Source)
at com.edhand.example1.AddItemAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824
)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher
.java:330)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledEx
ecutor.java:186)
at java.lang.Thread.run(Thread.java:534)
Feb 2, 2006 11:37:29 AM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 942, SQLState: 42000
Feb 2, 2006 11:37:29 AM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: ORA-00942: table or view does not exist

Feb 2, 2006 11:37:29 AM net.sf.hibernate.JDBCException <init>
SEVERE: Could not save object
java.sql.SQLException: ORA-00942: table or view does not exist

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:137)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:304)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:271)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:625)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:499
)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:1003)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:5
31)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1109)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:29
32)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2973)

at net.sf.hibernate.id.TableGenerator.generate(TableGenerator.java:93)
at net.sf.hibernate.id.TableHiLoGenerator.generate(TableHiLoGenerator.java:59)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:747)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:720)
at com.edhand.example1.ItemService.addItem(Unknown Source)
at com.edhand.example1.AddItemAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824
)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher
.java:330)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledEx
ecutor.java:186)
at java.lang.Thread.run(Thread.java:534)
06/02/02 11:37:29 Hibernate ExceptionCould not save object
Feb 2, 2006 11:37:29 AM org.apache.struts.action.RequestProcessor processException
WARNING: Unhandled Exception thrown: class java.lang.RuntimeException


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 5:08 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
You should read your stack trace properly! You have some misconfiguration with your id generator.
If this helps, please do not forget to rate.

Sebastian

java.sql.SQLException: ORA-00942: table or view does not exist

Feb 2, 2006 11:37:29 AM net.sf.hibernate.id.TableGenerator generate
SEVERE: could not read a hi value

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 9:03 am 
Beginner
Beginner

Joined: Mon Oct 24, 2005 2:45 am
Posts: 23
thanks sebastain for suggestion

I have added hsqldb.jar in lib and used transaction to commit my Data.

Data is saving into database after this change.


----------------------
LaLiLuna wrote:
You should read your stack trace properly! You have some misconfiguration with your id generator.
If this helps, please do not forget to rate.

Sebastian

java.sql.SQLException: ORA-00942: table or view does not exist

Feb 2, 2006 11:37:29 AM net.sf.hibernate.id.TableGenerator generate
SEVERE: could not read a hi value


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