[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-4057) Error occurs when the not-null column has a default value in the DB but the field in object has no default value.

Adam Cameron (JIRA) noreply at atlassian.com
Thu Feb 25 15:07:47 EST 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=35696#action_35696 ] 

Adam Cameron commented on HHH-4057:
-----------------------------------

Agreed.  I've been caught out by the same thing.  It seems counter-intuitive to me.

-- 
Adam

> Error occurs when the not-null column has a default value in the DB but the field in object has no default value.
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-4057
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4057
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.3.2
>         Environment: Hibernate 3.3.2
>            Reporter: Rupesh Kumar
>
> I have a column in the database which is not null and has a default value.
> In the Java object, I don't have any default value set on the field mapped to this column. When this object is saved, Hibernate throws up an error because it tried to insert a null value in the not-null column. Since DB can generate the value for this column, hibernate should use that. 
> I can not use generated attribute in hibernate mapping file because this column value is not always generated. It is generated only when no value is specified for this column while inserting.
> Hibernate should inspect the database and find out which columns has default value set on it. If there is anything set on it, insert should ignore the mapped field if the value is not defined for it.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list