Hi all,

I have a problem with storing sql.Timestamp fields. Every time after an ejbStore() the 
nanoseconds are thrown away for ever. Im using jboss 3.2.3 and a mysql 4 db. There are 
no additional mappings made - only using jboss default mappings.

Can someone explain me this behavior ?
Thanks in advance.

Greets,
Marcel


  |   /**
  |    * @see javax.ejb.EntityBean#ejbLoad()
  |    */
  |   public void ejbLoad() throws EJBException, RemoteException {
  |     log.debug("ejbLoad(): converting values.");
  |     Timestamp adate = getSQLActivationDate();
  |     Timestamp edate = getSQLExpirationDate();
  |     if (adate != null && edate != null) {
  |       log.debug("adate = " + adate.getTime() + "nanos: " + adate.getNanos());
  |       log.debug("edate = " + edate.getTime() + "nanos: " + adate.getNanos());
  |     }
  |     activationDate = convertSQLTimeStampToCalendar(adate);
  |     expirationDate = convertSQLTimeStampToCalendar(edate);
  | 
  |     if (activationDate != null && expirationDate != null) {
  |       log.debug("activationDate = " + activationDate.getTimeInMillis());
  |       log.debug("expirationDate = " + expirationDate.getTimeInMillis());
  |     }
  |   }
  | 
  |   /**
  |    * @see javax.ejb.EntityBean#ejbStore()
  |    */
  |   public void ejbStore() throws EJBException, RemoteException {
  |     log.debug("ejbStore(): converting values.");
  |     if (activationDate != null && expirationDate != null) {
  |       log.debug("activationDate = " + activationDate.getTimeInMillis());
  |       log.debug("expirationDate = " + expirationDate.getTimeInMillis());
  |     }
  |     Timestamp adate = convertCalendarToSQLTimeStamp(activationDate);
  |     Timestamp edate = convertCalendarToSQLTimeStamp(expirationDate);
  |     setSQLActivationDate(adate);
  |     setSQLExpirationDate(edate);
  |     if (adate != null && edate != null) {
  |       log.debug("adate = " + adate.getTime());
  |       log.debug("edate = " + edate.getTime());
  |     }
  |   }
  | ...
  | 
  |   private Calendar convertSQLTimeStampToCalendar(Timestamp t) {
  |     Calendar date = null;
  |     if (t != null) {
  |       date = Calendar.getInstance();
  |       date.setTimeInMillis(t.getTime() + t.getNanos() / 1000000);
  |     }
  |     return date;
  |   }
  | 
  |   private Timestamp convertCalendarToSQLTimeStamp(Calendar c) {
  |     Timestamp t = null;
  |     if (c != null) {
  |       t = new Timestamp(c.getTimeInMillis());
  |     }
  |     return t;
  |   }
  | 

output:

  | 21:48:59,396 DEBUG [PollingCycleBean:534] ejbStore(): converting values.
  | 21:48:59,406 DEBUG [PollingCycleBean:536] activationDate = 1086295664847
  | 21:48:59,406 DEBUG [PollingCycleBean:537] expirationDate = 1117831664847
  | 21:48:59,626 DEBUG [PollingCycleBean:544] adate = 1086295664847
  | 21:48:59,626 DEBUG [PollingCycleBean:545] edate = 1117831664847
  | 21:49:04,453 DEBUG [PollingCycleBean:514] ejbLoad(): converting values.
  | 21:49:04,453 DEBUG [PollingCycleBean:518] adate = 1086295664000nanos: 0
  | 21:49:04,453 DEBUG [PollingCycleBean:519] edate = 1117831664000nanos: 0
  | 21:49:04,453 DEBUG [PollingCycleBean:525] activationDate = 1086295664000
  | 21:49:04,453 DEBUG [PollingCycleBean:526] expirationDate = 1117831664000
  | 

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3842515#3842515

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3842515


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to