]
Ritesh patel commented on ANN-626:
----------------------------------
I'm in the similar boat where I need to dynamically insert the timestamp value through
hibernate, but only null is inserted in the database. Rob, what was your workaround? I
can't use obj.setDate() since all my hibernate session code is abstract where the
incoming object might be of different types. Is there any other way to generate DateTime
stamp in hibernate without using <timestamp>?
@Generated annotation not inserting during insert
-------------------------------------------------
Key: ANN-626
URL:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-626
Project: Hibernate Annotations
Issue Type: Bug
Components: binder
Affects Versions: 3.2.0.ga, 3.3.0.ga
Environment: MSSQL 9.00.3042.00
Hibernate annotations version 3.2.0 GA and also tested 3.30 GA
Reporter: Rob
Priority: Critical
Fix For: 3.3.1
The @Generated annotation is not working similiar to the hbm generated tag.
Annotation Mapping:
@Generated(GenerationTime.INSERT)
@Column (name="CreatedOn", length=23, nullable=false, insertable=false,
updatable=false)
private Date mCreatedOn;
Mapping Document:
<property name="createdOn" generated="insert"
type="TimestampType">
<column name="CreatedOn" length="23"/>
</property>
The generated SQL (show_sql=true):
Hibernate: insert into Zone (CreatedByUserID, ZoneDescription, ZoneFile,
ModifiedByUserID, ModifiedOn, ZoneName, RowStatus, SOAExpire, SOAMinimum, SOARefresh,
SOARetry, SOAWho, ZoneTTL, ZoneType, ZoneClass) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?)
Debug level Hibernate log excerpt:
18:37:42 WARN org.hibernate.util.JDBCExceptionReporter 77 SQL Error: 515, SQLState:
23000
18:37:42 ERROR org.hibernate.util.JDBCExceptionReporter 78 Cannot insert the value NULL
into column 'CreatedOn', table 'DB.dbo.Zone'; column does not allow nulls.
INSERT fails.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: