• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HibernateExcepton caught on error position

 
donald zhang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my code snip:





I donot config transaction in hibernate.cfg.xml .
When I execute the code,an exception is caught in POS2.But,I expect it to be caught in POS1.Do I miss something?

Thanks!

[ May 26, 2005: Message edited by: donald zhang ]

[ May 26, 2005: Message edited by: donald zhang ]
[ May 29, 2005: Message edited by: donald zhang ]
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just a guess:

its not tx but trx (transaction var name)

one idea: why dont you use HibernateException instead and also catch it printing stackTrace?
 
donald zhang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I donot post the e.printStackTrace() because there is some Chinese character in it.It complaines that the value is too long to be saved. Any suggestion?

Thanks!
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i know zero about beans

once this said, i notice a coincidence: your bean name equals your error message; coud you post just the (english) relevant parts of your error message?
 
donald zhang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!

Here is the error stack trace:

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
once again i know nothing about Oracle database

but this error msg:
ORA-12899: column "JINJIANG"."TAXI_ORDER_LIST"."ROOM_NO" is too long (current length: 9, max length: 6)

makes me wonder if you properly defined that var in your mapping - looks like var is bigger than the space it gets in db

i have a home MySql + Hibernate + java app and i define , in java file:
String myVar; and then in MySql i get a field long enough to hold that var

sorry i cant help you further
 
donald zhang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!

The max length I assigned is a appropiate value.I cannot increase it.Besides,the user can always input a longer value.

I konw the following solution:
1),Modify the UI.If the user input longer data than I expect,prompt the user
2),Modify the DAO.When executing db execution,if the property is too long,throw an exception

I think the first one is better.

But I think there should be a better solution.Because all these solutions can only deal with expected error(user data too long).If something I donot expect happens,the user(even me) wonot know things went wrong.
 
donald zhang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Session.flush() works.

After calling the Session.save(MyBean),calling Session.flush() will synchronize the underlying persistent store with persistable state held in memory.

@see net.sf.hibernate.Session.flush()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic