This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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
 
Similar Threads
How to use Hibernate JPA annotation when extending HibernateDaoSupport?
Can't persist data into Oracle 10g by the default persistence layer of EJB 3.0 (Hibernate)
Hibernate Question
eclipse+jboss+ejb3+mysql+dynamicWebProject
Problem in <many-to-one> relationship