Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
the Rat - 13 Mar 2006 21:11 GMT
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
Frank Langelage - 13 Mar 2006 21:39 GMT
> 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.
the Rat - 13 Mar 2006 21:52 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.