db-ojb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexandre Borgoltz <alexandre.borgo...@smartjog.com>
Subject Re: How to use TimeStamp with OJB
Date Tue, 07 Jun 2005 14:27:42 GMT
If you map the field in the usual way, but don't specify an explicit 
value in the javabean you are storing, OJB will explicitely set it 
"null" in the DB:
insert into my table (......, my_timestamp_field) values(......., NULL);
(supposing you are at broker level).

If your timestamp is filled in automatically by the DB (say by a default 
value or by trigger), and if you don't want that value to change in the 
future, use something like
<field-descriptor *access="readonly"* name="myTimeStamp" 
column="my_timestamp_field"* ... />
*=> OJB won't include it in the insert/update SQLs.

HTH,

**
*Alexandre BORGOLTZ**
*Head of Technology

**SmartJog SA*
*Phone: +33 (0)1 4996 6324
Fax: +33 (0)1 4996 6405
Mobile: +33 (0)6 8882 1417
alexandre.borgoltz@smartjog.com <mailto:alexandre.borgoltz@smartjog.com>


A Leg wrote:

> Hi
>
> I use OJB with postgres.
> When using postgres without Ojb, I use TimeStamp, by creating some 
> table field, non nullable and TimeStamp.
> Like that every time we enter data, a timeStamp is created in this field.
>
> But with Ojb I get an error telling me that I am trying to create a 
> record with a null value in a non nullable field.
> Caused by: org.postgresql.util.PSQLException: ERROR : null value in 
> column "created" violates not-null constraint.
>
> How can I solve this issue ?
>
> Best regards
>
> Andre Legendre
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Mime
View raw message