Pinaki Poddar wrote:
Hi,
   With MySQL this is what happens:


1. Definition of a column with default timestamp value

   @Column(name="ts", columnDefinition="TIMESTAMP DEFAULT
CURRENT_TIMESTAMP")
   private Timestamp ts;

2. OpenJPA issues SQL to create the table:

    CREATE TABLE AutoInc (id BIGINT NOT NULL, ts TIMESTAMP DEFAULT
CURRENT_TIMESTAMP, PRIMARY KEY (id))

3. OpenJPA issues SQL for insert when application does not set the value of
ts field:
INSERT INTO AutoInc (id, ts) VALUES (?, ?) [params=(long) 100, (null)
null]


4. This is what database looks like:

mysql> select * from autoinc;
+-----+---------------------+
| id  | ts                  |
+-----+---------------------+
| 100 | 2008-08-06 12:47:29 |
+-----+---------------------+
Hi all,

thanks for all support & solution.

For postgres 8.3.x this works well:

   @Column(name = "creationts", insertable=false, updatable=false,
columnDefinition="timestamp not null default current_timestamp")


regards
Marcel


--
Marcel Ruff
http://www.xmlBlaster.org
http://watchee.net
Phone: +49 7551 309371

Reply via email to