You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Alexandre Borgoltz <al...@smartjog.com> on 2005/06/07 16:27:42 UTC

Re: How to use TimeStamp with OJB

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 <ma...@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


Re: Solved : How to use TimeStamp with OJB

Posted by Hale India <ha...@yahoo.com>.
Hi Alexandre

Thank's for your help. It works good and it is simple.

For you, or others interested. We have made a eclipse
plugin for Ojb for our project, but it can be use for
any ojb project.
http://compiere-mfgscm.sourceforge.net/

Code generation and xml file generation is done using
code from ojb project.

Any feedback welcome.

We have also realised a Jini service for Ojb but we
are waiting for license change in Sun rio/jini
project.

Ojb is a nice tool to work with. Thank's to all the
team and it's supporters.

Andre
--- Alexandre Borgoltz
<al...@smartjog.com> wrote:

> 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
> <ma...@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
> 
> 


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