aspose file tools*
The moose likes Object Relational Mapping and the fly likes Batch Update Failure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Batch Update Failure" Watch "Batch Update Failure" New topic
Author

Batch Update Failure

subhashchandra medhiassam
Ranch Hand

Joined: Sep 10, 2008
Posts: 72
Hi all,
I have a table named Contact in MYSQL. This table looks like the following:

Column Type
------------- -------------
ID decimal
FIRSTNAME varchar
LASTNAME varchar
EMAIL varchar

There is only a single row of data in the table.

This row contains the following data:

ID = 6,FIRSTNAME=Subhash,LASTNAME=Medhi,EMAIL=medhi2006@gmail.com

Corresponding to this table i have a class Contact.java. It looks like the following:



My hbm.xml file looks like this:



I have a third class in which i am trying to update table Contact. This class named as UpdateExample.java looks like the following:



When i run this class, however, i am getting the following message:



The table is not getting updated.

Could anybody kindly tell me what exactly could the problem be?

Thanks,
Subhash
subhashchandra medhiassam
Ranch Hand

Joined: Sep 10, 2008
Posts: 72
Hi,
Could anybody kindly help me out. Please kindly help me out. It's urgent.

Thanks,
Subhash
[ September 29, 2008: Message edited by: subhashchandra medhiassam ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

There should be more information in the error message. What else does it tell you?

This may be nothing to do with the issue, but you have modelled your contact entity with an ID attribute with the type decimal, and mapped it with the type long. You possibly want to fix that.

And please, EaseUp.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
subhashchandra medhiassam
Ranch Hand

Joined: Sep 10, 2008
Posts: 72
There's nothing more in the message.

what should be the type of column id of Contact table? Kindly help.

Thanks,
Subhash
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Originally posted by subhashchandra medhiassam:
There's nothing more in the message.


This would be because you log the message the exception returns and not the stack trace. Print the stack trace and you will get more information. Hibernate always logs the underlying SQLException, which in turn always reports the database error message.


what should be the type of column id of Contact table

Decimal is usually used to store flaoting point numbers and floating point numbers are poor choices for surrogate keys. MySQL provides a variety of integer data types, I'd use one of them.
subhashchandra medhiassam
Ranch Hand

Joined: Sep 10, 2008
Posts: 72
i have used various types like mediumint and bigint for the column ID of table Contact. But nothing works.
subhashchandra medhiassam
Ranch Hand

Joined: Sep 10, 2008
Posts: 72
Hi,
when i changed the program to print the stacktrace it printed the following message:



I got it. thanks.
[ September 29, 2008: Message edited by: subhashchandra medhiassam ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Good. Worth remembering to check what is logged by Hibernate. SQLExceptions always tell you the issue - or at least as much information as the database is willing to give you.
peter tong
Ranch Hand

Joined: Mar 15, 2008
Posts: 240
the tutorial in roseIndia about hibernate has many bugs, their hibernate3.zip is old and would cause more error when you go to delete query example!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Batch Update Failure
 
Similar Threads
data insert error
Hibernate
cannot insert record in MS SQLServer 2000
it is giving fatal exception
Odd NullPointerException