Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 10736CF25 for ; Fri, 21 Jun 2013 06:17:29 +0000 (UTC) Received: (qmail 60032 invoked by uid 500); 21 Jun 2013 06:17:29 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 59619 invoked by uid 500); 21 Jun 2013 06:17:19 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 59603 invoked by uid 99); 21 Jun 2013 06:17:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Jun 2013 06:17:16 +0000 X-ASF-Spam-Status: No, hits=0.3 required=5.0 tests=DC_IMAGE_SPAM_HTML,DC_IMAGE_SPAM_TEXT,DC_PNG_UNO_LARGO,RCVD_IN_DNSWL_NONE,SPF_PASS,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [216.82.251.11] (HELO mail1.bemta12.messagelabs.com) (216.82.251.11) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Jun 2013 06:17:12 +0000 Received: from [216.82.250.99:43944] by server-11.bemta-12.messagelabs.com id A4/92-22153-8CFE3C15; Fri, 21 Jun 2013 06:16:40 +0000 X-Env-Sender: Mick.Fong@kti.wa.edu.au X-Msg-Ref: server-6.tower-126.messagelabs.com!1371795397!9135877!1 X-Originating-IP: [167.30.56.238] X-StarScan-Received: X-StarScan-Version: 6.9.6; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2379 invoked from network); 21 Jun 2013 06:16:38 -0000 Received: from unknown (HELO mx2.dtwd.wa.gov.au) (167.30.56.238) by server-6.tower-126.messagelabs.com with SMTP; 21 Jun 2013 06:16:38 -0000 Received: from brm-08.kimberley.local ([10.160.244.157]) by mx2.dtwd.wa.gov.au with Microsoft SMTPSVC(7.5.7601.17514); Fri, 21 Jun 2013 14:16:39 +0800 Received: from BRM-10.kimberley.local ([fe80::4469:ad6f:e27e:3cfe]) by brm-08.kimberley.local ([fe80::e4c6:6899:f9ed:ef3d%13]) with mapi id 14.02.0342.003; Fri, 21 Jun 2013 14:16:35 +0800 From: Mick Fong To: "'user@cayenne.apache.org'" Subject: RE: java.sql.SQLException: Unknown Types value Thread-Topic: java.sql.SQLException: Unknown Types value Thread-Index: Ac5svVj1IsCz2j41Q0aYDJsXSiDkJv//4NsAgAFHgY6AAEbAAIAAcuoA//7QKgA= Date: Fri, 21 Jun 2013 06:16:35 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US, en-AU Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [10.160.240.20] Content-Type: multipart/mixed; boundary="_002_A62B0A6D6B5FA04D81F31BCDF6960D1D08B7113Dbrm10kimberleyl_" MIME-Version: 1.0 X-OriginalArrivalTime: 21 Jun 2013 06:16:39.0744 (UTC) FILETIME=[E44E8400:01CE6E46] X-Virus-Checked: Checked by ClamAV on apache.org --_002_A62B0A6D6B5FA04D81F31BCDF6960D1D08B7113Dbrm10kimberleyl_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Andrus, Yes I am running, 3.0.2 (on windows). The type value I get is "2147483647" (which is the max int obviously) Attached image shows it in the debugger. cheers Mick Fong Simulator Engineer =A0 p (08) 9193 8921 m=A00413 113 099 f (08) 9192 9111 e mick.fong@kti.wa.edu.au a PO Box 1380, Broome WA 6725 -----Original Message----- From: Andrus Adamchik [mailto:andrus@objectstyle.org]=20 Sent: Friday, 21 June 2013 4:05 AM To: user@cayenne.apache.org Subject: Re: java.sql.SQLException: Unknown Types value >From checking the sources, I am also assuming 3.0.*: public void setJdbcObject( PreparedStatement st, Object value, int pos, int type, int scale) throws Exception { // if this is a CLOB column, set the value as "String" // instead. This should work with most drivers if (type =3D=3D Types.CLOB) { st.setString(pos, (String) value); } else if (scale !=3D -1) { st.setObject(pos, value, type, scale); } else { // THIS IS LINE 169 st.setObject(pos, value, type); } } Mick, Could you possibly run this in debugger and tell us what the value of= the "type" variable is? Andrus On Jun 20, 2013, at 9:13 AM, Michael Gentry wrote: > Hi Mick, >=20 > Did you maybe map a CHAR in your Cayenne DbEntity to a VARCHAR column=20 > or vice-versa? I could see this causing a problem. >=20 > We use views just fine with Cayenne and have both CHAR and VARCHAR=20 > mappings (to the appropriate DB types) in Cayenne 3.0. You didn't=20 > mention which version of Cayenne you are using, so I'm guessing 3.0 curre= ntly. >=20 > mrg >=20 >=20 >=20 > On Wed, Jun 19, 2013 at 9:11 PM, Mick Fong wrot= e: >=20 >> Hi Michael, >>=20 >> The type is definitely a varchar in the view. >>=20 >> The error is when the you are setting the query object for the=20 >> PreparedStatement. It appears that the=20 >> org.apache.cayenne.access.types.CharType is not being recognised as a=20 >> MySQL varchar type. >>=20 >> The exception is thrown from a switch on the parameter SQL type: >>=20 >> switch (targetSqlType) { >> . >> . >> case Types.CHAR: >> case Types.VARCHAR: >> case Types.LONGVARCHAR: >> if (parameterObj instanceof BigDecimal) { >>=20 >> setString(parameterIndex,(StringUtils.fixDecimalExponent(StringUtils. >> consistentToString((BigDecimal) >> parameterObj)))); >> } else { >> setString(parameterIndex, parameterObj.toString()); >> } >>=20 >> break; >> . >> . >> default: >> throw >> SQLError.createSQLException(Messages.getString("PreparedStatement.16" >> ), >> //$NON-NLS-1$ >> SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor()); } >>=20 >>=20 >> The property value for the message is: >> PreparedStatement.16=3DUnknown Types value >>=20 >>=20 >> The error occurs just when setting the parameters because the=20 >> CharType is not recognised. >>=20 >> thanks >>=20 >> mick >>=20 >> [Kimberley Training Institute Logo] >> Toll Free: 1300 996 573 | Website: www.kti.wa.edu.au<=20 >> http://www.kti.wa.edu.au> Find us on=20 >> Facebook >>=20 >> Please consider the environment before printing this email. >>=20 --_002_A62B0A6D6B5FA04D81F31BCDF6960D1D08B7113Dbrm10kimberleyl_--