MySQL CURRENT_TIMESTAMP usage with timestamp version tags,
with generated="insert" generated="always" and source="db" source="vm" attributes.
Hibernate version: 3
MySQL 5
Code between Inserts and Updates
---Currently Working--- (But Have a look at what I would like)
MySQL DDL:
`createDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedDate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
Mapping documents:
<timestamp name="updatedDate" column="updatedDate" source="db" generated="never" />
<property name="createDate" type="java.util.Date" generated="insert" update="false">
<column name="createDate" length="0" not-null="true" />
</property>
---What I would Like To Work---
MySQL DDL:
`createDate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`updatedDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
Mapping documents: NON Current DTD Compliant
<timestamp name="updatedDate" column="updatedDate" source="db" generated="always" />
<property name="createDate" type="java.util.Date" generated="insert" source="db" update="false">
<column name="createDate" length="0" not-null="true" />
</property>
---Other Options---
a) ???
<timestamp name="createDate" column="createDate" source="db" generated="insert" />
<version name="updatedDate" type="timestamp" unsaved-value="null" generated="always" source="db" />
b) problems on updates
<timestamp name="createDate" column="createDate" source="db" generated="never" /> <!-- Y -->
<property name="updatedDate" type="java.util.Date" generated="always">
<column name="updatedDate" length="0" not-null="true" />
</property>
|