openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Ruff ...@marcelruff.info>
Subject Re: How to apply creation timestamp with -> UNRESOLVED
Date Thu, 07 Aug 2008 09:23:52 GMT
Hi,

i was to quickly happy:

The timestamp is add nicely to the DB: OK
(check with normal sql)

But when i want to load it later into my bean
it remains null in java:
        CompanyProperty cp = em.find(CompanyProperty.class, key);
        log.info(cp.getCreationTs());
--> is null!

Why this?

Thanks
Marcel

Marcel Ruff wrote:
> 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


Mime
View raw message