Return-Path: Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 83598 invoked by uid 500); 7 Jul 2003 23:34:16 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 83585 invoked from network); 7 Jul 2003 23:34:15 -0000 Received: from chorgh.serverconfig.com (162.42.208.249) by daedalus.apache.org with SMTP; 7 Jul 2003 23:34:15 -0000 Received: from adsl-63-196-4-147.dsl.snfc21.pacbell.net ([63.196.4.147] helo=mpearce) by chorgh.serverconfig.com with smtp (Exim 4.20) id 19ZfV4-0006TR-CL for ojb-dev@db.apache.org; Mon, 07 Jul 2003 19:34:26 -0400 Message-ID: <00d701c344e0$639f4050$0200a8c0@mpearce> From: "Mike Pearce" To: "OJB Developers List" References: <00b801c344dc$dc339dd0$0200a8c0@mpearce> <010001c344dd$cf1d4910$6479fea9@win> Subject: Re: Timestamp brokering in HSQL, et al Date: Mon, 7 Jul 2003 16:35:02 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - chorgh.serverconfig.com X-AntiAbuse: Original Domain - db.apache.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - studioelectrica.com X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Shouldn't the FieldConversion attribute be used only for "non-standard" configurations. I am creating a new database with OJB/Torque. Under this situation, the field conversions should already be correct - which they are not. :) BTW, should this have been sent to the users' list? -mike ----- Original Message ----- From: "Armin Waibel" To: "OJB Developers List" Sent: Monday, July 07, 2003 4:16 PM Subject: Re: Timestamp brokering in HSQL, et al > Hi Mike, > > I think the better way is to use a > FieldConversion (attribute of field-descriptor) > for your field. e.g. > org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConve > rsion > > regards, > Armin > > ----- Original Message ----- > From: "Mike Pearce" > To: > Sent: Tuesday, July 08, 2003 1:09 AM > Subject: Timestamp brokering in HSQL, et al > > > > When trying to do a simple store of a Persistent Object with a > > java.util.Date field (represented as a TIMESTAMP column in the HSQL > > database), i get an exception that arises from HSQL's inability to > convert > > the java.util.Date to a java.sql.Timestamp (see stacktrace below). It > > appears that the HSQLDB driver does not accept java.util.Date's as a > > parameter to the PreparedStatement.setObject() method when the type is > > Types.TIMESTAMP (and probably Types.TIME and Types.DATE). > > > > To correct the error, I modified the > > PlatformDefaultImpl.setObjectForStatement() method to test for the > case of a > > java.util.Date, thinking that this problem could also show up with > other > > JDBC drivers: > > else if (value instanceof java.util.Date) > > { > > // convert java.util.Date objects to the java.sql > equivalent > > if (Types.DATE == sqlType && ! (value instanceof > java.sql.Date)) > > { > > value = new java.sql.Date(((java.util.Date) > > value).getTime()); > > } > > else if (Types.TIMESTAMP == sqlType && ! (value instanceof > > java.sql.Timestamp)) > > { > > value = new java.sql.Timestamp(((java.util.Date) > > value).getTime()); > > } > > else if (Types.TIME == sqlType && ! (value instanceof > > java.sql.Time)) > > { > > value = new java.sql.Time(((java.util.Date) > > value).getTime()); > > } > > > > ps.setObject(index, value, sqlType); > > } > > > > > > Stack Trace: > > java.lang.IllegalArgumentException: Timestamp format must be > yyyy-mm-dd > > hh:mm:ss > > .fffffffff > > at java.sql.Timestamp.valueOf(Timestamp.java:188) > > at > org.hsqldb.lib.HsqlDateTime.timestampValue(HsqlDateTime.java:82) > > at org.hsqldb.Column.convertString(Column.java:1292) > > at org.hsqldb.Column.convertObject(Column.java:1239) > > at > > org.hsqldb.jdbcPreparedStatement.setObject(jdbcPreparedStatement.java > > :1137) > > at > > org.apache.ojb.broker.platforms.PlatformDefaultImpl.setObjectForState > > ment(Unknown Source) > > at > > org.apache.ojb.broker.accesslayer.StatementManager.bindInsert(Unknown > > Source) > > at > > org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(Unknow > > n Source) > > at > > org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(Unknown So > > urce) > > at > org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown > > Source > > ) > > at > org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown > > Source > > ) > > at > > org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown > > Source) > > at > > org.apache.ojb.jdori.sql.OjbStoreManager.insert(OjbStoreManager.java: > > > > -mike > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org > > For additional commands, e-mail: ojb-dev-help@db.apache.org > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org > For additional commands, e-mail: ojb-dev-help@db.apache.org > > > --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org