-->
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.  [ 12 posts ] 
Author Message
 Post subject: invalid number exception ....??????
PostPosted: Fri Jun 15, 2007 3:35 pm 
Beginner
Beginner

Joined: Fri May 11, 2007 11:03 am
Posts: 32
Hibernate version:3.2
I have two objects A (parent) , B (child)

Mapping documents:
A:

<class name="A" table="A" lazy="true"
batch-size="6">
<id name="id" column="ID">
<generator class="increment"/>
</id>
<property name="name" column="NAME" not-null="true"/>
<set name="b" cascade="none" lazy="false" inverse="true">
<key column="a_id"/>
<one-to-many class="B" />
</set>
</class>

B:

<class name="B" table="B" lazy="true"
batch-size="6">
<id name="id" column="ID">
<generator class="increment"/>
</id>
<property name="name" column="NAME" not-null="true"/>
<many-to-one name="a" column="a_id"
class="A" cascade="none" lazy="false"/>
</class>
Code between sessionFactory.openSession() and session.close():
b.saveOrUpdate();
b.commit();


Full stack trace of any exception that occurs:
07/06/15 12:24:23 Hibernate: update B set NAME=?, A_ID=? where ID=?

07/06/15 12:24:23 [WARN] JDBCExceptionReporter - -SQL Error: 1722, SQLState: 42000

07/06/15 12:24:23 [ERROR] JDBCExceptionReporter - -ORA-01722: invalid number


07/06/15 12:24:23 [WARN] JDBCExceptionReporter - -SQL Error: 1722, SQLState: 42000

07/06/15 12:24:23 [ERROR] JDBCExceptionReporter - -ORA-01722: invalid number


07/06/15 12:24:23 [ERROR] AbstractFlushingEventListener - -Could not synchronize database state with session <org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update>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:140)

at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)

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 baseline.BAction.execute(BaselineAction.java:95)

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:1482)

at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)

at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)

at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:649)

at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)

at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)

at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)

at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)

at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)

at java.lang.Thread.run(Thread.java:534)

Caused by: java.sql.BatchUpdateException: ORA-01722: invalid number


at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:380)

at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:8757)

at com.evermind.sql.FilterStatement.executeBatch(FilterStatement.java:413)

at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)

at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)

... 23 more



07/06/15 12:24:23 [WARN] RequestProcessor - -Unhandled Exception thrown: class org.hibernate.exception.SQLGrammarException






I am not able to find why invalid number exception is being thrown

When I try to debug, at commit it tries to set every property of the object but in the joining column it comes up with a weird number of Long type and tries to set it and then throws the error.
Is there somebody who can help.........?????


Top
 Profile  
 
 Post subject: Re:
PostPosted: Fri Jun 15, 2007 5:25 pm 
Senior
Senior

Joined: Tue Jun 12, 2007 4:49 pm
Posts: 127
Location: India
It appears to me that A has not been saved before saving B.

Since the cascade is set to none on both sides, you will need to explicitly save A and B.

If this is the way you want it, then all u need to do is set many-to-one to allow null, then a_id will not cause this exception.

*Please do rate if you find this tip helpful*

Regards,
Jitendra


Top
 Profile  
 
 Post subject: Hi
PostPosted: Mon Jun 18, 2007 10:37 am 
Beginner
Beginner

Joined: Fri May 11, 2007 11:03 am
Posts: 32
I tried to run the program after setting not-null="false" in many-to-one , but didnt help . It throws the same error.


Top
 Profile  
 
 Post subject: Hi
PostPosted: Mon Jun 18, 2007 10:37 am 
Beginner
Beginner

Joined: Fri May 11, 2007 11:03 am
Posts: 32
Even if I remove the many-to-one relation from the mapping. I still get the same error. I also noticed whiled debugging that this invalid number is of long type(a big number) which I dont have in any of my tables. where is this number coming from??


Last edited by sriguru on Mon Jun 18, 2007 11:12 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Hi
PostPosted: Mon Jun 18, 2007 11:04 am 
Beginner
Beginner

Joined: Fri May 11, 2007 11:03 am
Posts: 32
I tried to run the program after setting not-null="false" in many-to-one , but didnt help . It throws the same error.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 2:59 pm 
Senior
Senior

Joined: Tue Jun 12, 2007 4:49 pm
Posts: 127
Location: India
In the code between session open and close, where are you getting 'b' from ???

How does it get loaded.. how does a get attached to it ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 3:41 pm 
Beginner
Beginner

Joined: Fri May 11, 2007 11:03 am
Posts: 32
I m displaying 'b' and its properties on a jsp page and when the user updates one or more of those properties , I retrieve them back and try to update the database. And it also has an option of being linked to another 'a' ie the relation can be changed from one parent to another. But it doesnt matter if the user tries to link the child to another parent or update just the child itself , it throws the same error.


Top
 Profile  
 
 Post subject: Re:
PostPosted: Mon Jun 18, 2007 3:53 pm 
Senior
Senior

Joined: Tue Jun 12, 2007 4:49 pm
Posts: 127
Location: India
How is the b loaded ? debug and see how it looks just before update is called.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 4:18 pm 
Beginner
Beginner

Joined: Fri May 11, 2007 11:03 am
Posts: 32
'b' is being loaded from the Struts Form which is being populated on the jsp page.
Before that 'b' is coming from the database so that it can be displayed on the page along with its properties.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 4:20 pm 
Senior
Senior

Joined: Tue Jun 12, 2007 4:49 pm
Posts: 127
Location: India
I have a feeling that your problem is not related to hibernate, see the properties being returned by the struts framework from the form submitted.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 4:44 pm 
Beginner
Beginner

Joined: Fri May 11, 2007 11:03 am
Posts: 32
Hi Jitendra,
I was also of the same thought before I went deep into debugging . but after that it seems like there is some problem in hibernate part.
This number which is being thrown as invalid number of long type has no place in database or any form.
This number seems to me some kinda object Id or hashset etc


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 26, 2007 12:30 pm 
Beginner
Beginner

Joined: Fri May 11, 2007 11:03 am
Posts: 32
Thanks j, i got it solved , i donno why but it was due to some unmatched value being entered for a checkbox
Thanks


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