How do I update a timestamp in a DB using a CMP 2.0 Entity bean?

T

the Rat

All,

I have a CMP 2.0 Entity bean that represents a row in a table of my DB.
I've got numerous abstract setters and getters. However, one of the
columns in my DB is a timestamp and I want it to reflect the time -
ACCORDING TO THE DB - when that row was updated. Without using an CMP
2.0 entity bean I'd simply do something like this:
update customer set lastHeartBeat=sysdate where id=55;
The value of sysdate has special meaning to oracle - it's the current
system time. How does one deal with time issues using CMPs? It looks
like EJB-QL is really just for generating quieries in a DB-independent
way and doesn't deal with "date" or "timestamp" issues directly. Am I
wrong about this?

Any light you can shed would be appreciated.

-john
 
F

Frank Langelage

the said:
I have a CMP 2.0 Entity bean that represents a row in a table of my DB.
I've got numerous abstract setters and getters. However, one of the
columns in my DB is a timestamp and I want it to reflect the time -
ACCORDING TO THE DB - when that row was updated. Without using an CMP
2.0 entity bean I'd simply do something like this:
update customer set lastHeartBeat=sysdate where id=55;
Any light you can shed would be appreciated.

Three possible solution came into my mind:
1. create a database trigger for update and insert on this table and
fill the column with the sysdate value.
2. use the session facade pattern. All modifications for the entity bean
are done using a session bean. Every time a file is changed you change
the value for the lastHartBeat too.
3. use a application server specific feature. JBoss supports audit
fields for created-by, created-time, updated-by, updated-time. The
server fills in the name or timestamp before updating the database.
 
T

the Rat

I'm trying to do this in a DB and application server-independent way -
so I don't think #1 or #3 (above) will work. Can you elaborate more on
#2? Remember, I'm trying to update the time according to the DB - not
the application server.

Thanks!

-john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top