-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Why the expensive create in TimestampType?
PostPosted: Tue Oct 12, 2004 11:09 am 
Beginner
Beginner

Joined: Mon Sep 27, 2004 4:28 pm
Posts: 44
Hibernate version: 2.1.6


In doing some profiling I noticed that I'm spending a lot of time creating SimpleDateFormat objects in TimestampType...

I found the following:

Code:
private static final String TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss";

   public Object fromStringValue(String xml) throws HibernateException {
      try {
         return new Timestamp(new SimpleDateFormat(TIMESTAMP_FORMAT).parse(xml).getTime());
      }
      catch (ParseException pe) {
         throw new HibernateException("could not parse XML", pe);
      }
   }

   public String toString(Object val) {
      return new SimpleDateFormat(TIMESTAMP_FORMAT).format( (java.util.Date) val );
   }



Why create this object on the way in and out of every Timestamp column?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 12, 2004 11:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
get() and set() are used when brokering to/from the database; not fromStringValue() and toString(). Thus the formatter is not being used to read or write the column. Now, if you are logging the bind parameters the toString() would get used for that.

Now, this probably should use a static formatter for the cases where it does get used. Submit a JIRA request.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.