1 10 11 package com.triactive.jdo.store; 12 13 import com.triactive.jdo.PersistenceManager; 14 import java.sql.PreparedStatement ; 15 import java.sql.ResultSet ; 16 import java.sql.Timestamp ; 17 import java.util.Date ; 18 19 20 public class DateMapping extends SqlTimestampMapping 21 { 22 public DateMapping(DatabaseAdapter dba, Class type) 23 { 24 super(dba, type); 25 } 26 27 public DateMapping(Column col) 28 { 29 super(col); 30 } 31 32 public DateMapping(ClassBaseTable table, int relativeFieldNumber) 33 { 34 super(table, relativeFieldNumber); 35 } 36 37 public void setObject(PersistenceManager pm, PreparedStatement ps, int param, Object value) 38 { 39 super.setObject(pm, ps, param, value == null ? null : new Timestamp (((Date )value).getTime())); 40 } 41 42 public Object getObject(PersistenceManager pm, ResultSet rs, int param) 43 { 44 Timestamp value = getTimestamp(rs, param); 45 46 if (value == null) 47 return null; 48 else 49 return new Date (value.getTime()); 50 } 51 52 public SQLExpression newSQLLiteral(QueryStatement qs, Object value) 53 { 54 return super.newSQLLiteral(qs, new Timestamp (((Date )value).getTime())); 55 } 56 } 57 | Popular Tags |