We have the following constraint defined in sql server 2005:
| USE [boIcomsSecurityAudit]
| GO
| ALTER TABLE [dbo].[tblSecurityAuditNote] ADD CONSTRAINT
[DF_tblSecurityAuditNote_TimeStamp] DEFAULT (getdate()) FOR [TimeStamp]
I am persisting to the db table above via a Seam2.0.0.GA/JBoss 4.2.2.GA web
app. The constructor for the JPA entity is as follows:
| public TblSecurityAuditNote(Integer siteId,
| Integer employeeNumber, String noteType, String
noteText) {
|
| this.siteId = siteId;
| this.employeeNumber = employeeNumber;
| this.noteType = noteType;
| this.noteText = noteText;
| }
After em.persist() fires in the SFSB and the transaction commits, the insert
shows 'null' for the TimeStamp column (of type datatime) for that newly
inserted record. The problem is that when the value is 'null' the default
constraint does not fire the getdate() t-sql function. The default constraint
works when I issue the following command in SQL management studio:
| insert into tblsecurityauditnote(SITE_ID, EMPLOYEE_NUMBER, NoteType,
NoteText)
| values (333, 74055, 'mojo jojo', 'text of a note')
Is there a way around this (e.g. JPA annotation?) or should we remove the table
default constraint and use a getdate method in the Java code??? setTimeStamp()
is not being called on the JPA entity. So it must default to 'null' which
makes sense I guess...
thx.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4111722#4111722
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4111722
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user