• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rohit Bhal
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Hemant Thard
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 218
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rishi

Here is the complete stacktrace:


And here is the schema of the user table:


Thanks.
 
Rohit Bhal
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic