Skip to main content

JPA - How can I use the table's default Date types? e.g. CURRENT_TIME

No replies
javious
Offline
Joined: 2006-11-29

I would like to know if/how one can use the default date/time/datetime types as declared for the target table when attempting to persist an entity having these fields set as null.

<br />
create table item<br />
(<br />
	item_id INTEGER NOT NULL PRIMARY KEY DEFAULT AUTOINCREMENT,<br />
	date_created DATETIME NOT NULL DEFAULT NOW(*),<br />
	date_updated DATETIME NOT NULL DEFAULT NOW(*)<br />
);<br />

Now how can I get the above table to work when attempting to em.persist(myItem) whereby dateCreated and dateUpdated are both null?