File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hibernate 3: java.sql.SQLException: Field 'passwordConfirmation' doesn't have a default value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate 3: java.sql.SQLException: Field Watch "Hibernate 3: java.sql.SQLException: Field New topic
Author

Hibernate 3: java.sql.SQLException: Field 'passwordConfirmation' doesn't have a default value

Rohit Bhal
Ranch Hand

Joined: Aug 28, 2007
Posts: 44
I've been scratching my head over this error for sometime now but can't work it out. I've been using Hibernate 3 to persist User entity. But I am getting java.sql.SQLException: Field 'passwordConfirmation' doesn't have a default value error when I try to do that.

Following is my User entity:
User.java

Could someone help me understand that why am I getting this error?


Skip Skipping
Hemant Thard
Ranch Hand

Joined: Dec 23, 2008
Posts: 122
hi Deshraj,

Its very difficult to predict what the error might be with just by looking at your bean class.
Please post your SQL script and configuration file too.

but 1 thing that i would like to point out is the use of @NotEmpty when you have declared your property to be of type @Transient.




Rohit Bhal
Ranch Hand

Joined: Aug 28, 2007
Posts: 44
Hi Hemant

The only entity that I have is User entity and the schema was generated using Hibernate itself. Although it should not be a problem but even after removing @NotEmpty from passwordConfirmation fields, it still gives me the same error. I am using spring mvc 3 with hibernate 3. I am using User entity to represent the form and after submitting the form I find the model populated with the respective fields properly.

Thanks.
Rishi Shehrawat
Ranch Hand

Joined: Aug 11, 2010
Posts: 218

Could you post the complete stack trace.
The exception is not caused by @NotEmpty, from what you have poseted it seems like a SQL exception thrown by database
Try removing @Transient from passwordConfirmation
Check the table creation script, this column has a default value set, try removing it.
Rohit Bhal
Ranch Hand

Joined: Aug 28, 2007
Posts: 44
Hi Rishi

Here is the complete stacktrace:


And here is the schema of the user table:


Thanks.
Rohit Bhal
Ranch Hand

Joined: Aug 28, 2007
Posts: 44
I was mistakenly using a different schema than the one I was generating using Hibernate. Both the schema had passwordConfirmation field in the User entity so got confused.

I've got it working now. Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate 3: java.sql.SQLException: Field 'passwordConfirmation' doesn't have a default value