Return-Path: X-Original-To: apmail-openjpa-users-archive@minotaur.apache.org Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0E93F109B6 for ; Wed, 8 Jan 2014 17:22:09 +0000 (UTC) Received: (qmail 87813 invoked by uid 500); 8 Jan 2014 17:19:52 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 87748 invoked by uid 500); 8 Jan 2014 17:19:46 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 87505 invoked by uid 99); 8 Jan 2014 17:19:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jan 2014 17:19:11 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of hal.hildebrand@me.com designates 17.158.236.236 as permitted sender) Received: from [17.158.236.236] (HELO nk11p04mm-asmtp001.mac.com) (17.158.236.236) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jan 2014 17:19:07 +0000 Received: from constantine.internal.salesforce.com (unknown [204.14.239.147]) by nk11p04mm-asmtp001.mac.com (Oracle Communications Messaging Server 7u4-27.08(7.0.4.27.7) 64bit (built Aug 22 2013)) with ESMTPSA id <0MZ3001ODER8JE20@nk11p04mm-asmtp001.mac.com> for users@openjpa.apache.org; Wed, 08 Jan 2014 17:18:45 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.11.87,1.0.14,0.0.0000 definitions=2014-01-08_07:2014-01-07,2014-01-08,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=1 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1308280000 definitions=main-1401080090 Content-type: text/plain; charset=windows-1252 MIME-version: 1.0 (Mac OS X Mail 7.1 \(1827\)) Subject: Re: PostgreSQL BIT/Boolean madness From: Hal Hildebrand In-reply-to: Date: Wed, 08 Jan 2014 09:18:29 -0800 Content-transfer-encoding: quoted-printable Message-id: <339DBAB1-6652-4297-BE70-8FD8E20EE968@me.com> References: <24B44489-BD08-4019-B166-B26987EB1E07@me.com> To: users@openjpa.apache.org X-Mailer: Apple Mail (2.1827) X-Virus-Checked: Checked by ClamAV on apache.org I tried this same trick in my app server -> DB test and oddly it had no = effect either way. I=92m wondering if I=92m actually doing anything here with this = property. I do see the log line: 606 CoRE INFO [main] openjpa.jdbc.JDBC - Using dictionary = class "org.apache.openjpa.jdbc.sql.PostgresDictionary=94. So I=92m assuming that this property will in fact, do something to the = db dictionary. But the default already is =93BIT=94, so it=92s unclear = that this is where the problem lies. On Jan 8, 2014, at 8:29 AM, Hal Hildebrand = wrote: > So, I tried it with both =93BIT=94 and =93BOOLEAN=94 with the same = result. >=20 > Wonder where OpenJPA is getting this metadata from? >=20 > Here=92s the stack trace, in case that catches someone=92s eye: >=20 > Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: column = "boolean_value" is of type boolean but expression is of type bit = {prepstmnt 1254242409=20 > INSERT INTO ruleform.job_attribute (id, notes, update_date, = binary_value,=20 > boolean_value, integer_value, numeric_value, sequence_number,=20= > text_value, timestamp_value, job, updated_by, attribute, unit)=20= > VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)=20 > [params=3D(long) 301, (null) null, (null) null, (null) null, (null) = null, (int) 1500, (null) null, (int) 1, (null) null, (null) null, (long) = 605, (long) 4, (long) 56, (null) null]} [code=3D0, state=3D42804] > at = org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnect= ionDecorator.java:219) > at = org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnect= ionDecorator.java:195) > at = org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$1000(Logging= ConnectionDecorator.java:59) > at = org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$L= oggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:1134= ) > at = org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(Dele= gatingPreparedStatement.java:275) > at = org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(Dele= gatingPreparedStatement.java:275) > at = org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.ex= ecuteUpdate(JDBCStoreManager.java:1792) > at = org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(= PreparedStatementManagerImpl.java:268) > at = org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate= (PreparedStatementManagerImpl.java:119) >=20 > On Jan 7, 2014, at 7:31 PM, Rick Curtis wrote: >=20 >> It isn't clear to me what is going on, but with the DBDictionary you = can >> change the type of column that boolean / bit field types are mapped = to. >> Perhaps you can change the bitTypeName / booleanTypeName to see if = you can >> get something working? To change these values you can change the type = to >> set the property = openjpa.jdbc.DBDictionary=3Dpostgres(bitTypeName=3D"BIT"). >>=20 >> HTH, >> Rick >>=20 >>=20 >> On Tue, Jan 7, 2014 at 7:38 PM, Hal Hildebrand = wrote: >>=20 >>> So, I have a serious problem. I have tables that are defined to = have >>> BOOLEAN columns. When I run this with PostgreSQL JDBC drivers, from = the >>> middle tier, this works just fine. Everything peachy keen. = However=85. >>>=20 >>> I=92m also running this code inside the database via PL/Java. When = running >>> inside the session as a stored procedure, a different JDBC driver is = used - >>> i.e. the one integrated into PL/Java. This JDBC driver works fine = for the >>> most part. But the problem is that when I try to set NULL to = BOOLEAN >>> columns, OpenJPA barfs: >>>=20 >>> Caused by: >>> org.apache.openjpa.persistence.PersistenceException: column = "boolean_value" >>> is of type boolean but expression is of type bit {prepstmnt = 108675190 >>> INSERT INTO ruleform.job_attribute (id, notes, update_date, = binary_value, >>> boolean_value, integer_value, numeric_value, sequence_number, >>> text_value, timestamp_value, job, research, updated_by, = attribute, >>> unit) >>> VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) >>> [params=3D(long) 1, (null) null, (null) null, (null) null, (null) = null, >>> (null) null, (BigDecimal) 1500, (int) 1, (null) null, (null) null, = (long) >>> 55, (null) null, (long) 3, (long) 56, (null) null]} [code=3D0, = state=3D42804] >>>=20 >>> I have created a test case where I create a simple table with a = BOOLEAN >>> column and then use the raw JDBC driver to insert a NULL value into = a row >>> when running inside of PL/Java and it just works fine. >>>=20 >>> So I=92m guessing there=92s some weird meta data thing going on. I = did a lot >>> of googling to see what I could find out, and basically it seems = like >>> there=92s an issue with type 2 drivers vs type 3 drivers with = PostgreSQL BIT >>> and BOOLEAN. >>>=20 >>> Thus, the question I have is there some setting in OpenJPA I can use = to >>> get around this? Things seem to turn nightmarish if I convert all = my >>> columns to BIT and try to deal with that. But hey, if there=92s a = SQL way >>> out of this level of hell, I=92ll gladly do that as well. >>>=20 >>> Any help would be appreciated. >>>=20 >>> -Hal >>=20 >>=20 >>=20 >>=20 >> --=20 >> *Rick Curtis* >=20