Forums Register Login

HibernateExcepton caught on error position

+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
Thanks!

Here is the error stack trace:

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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()
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1114 times.
Similar Threads
strings
How do i invoke a bean from a servlet?
Hibernate: Session and Transaction
Sorting a row in a two deminsional array
Servlets - JSP communication
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 30, 2024 01:25:29.