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 98932F2D5 for ; Tue, 23 Apr 2013 00:21:41 +0000 (UTC) Received: (qmail 67886 invoked by uid 500); 23 Apr 2013 00:21:41 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 67866 invoked by uid 500); 23 Apr 2013 00:21:41 -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 67854 invoked by uid 99); 23 Apr 2013 00:21:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Apr 2013 00:21:41 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests= X-Spam-Check-By: apache.org Received-SPF: error (athena.apache.org: local policy) Received: from [59.167.240.32] (HELO fish.ish.com.au) (59.167.240.32) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Apr 2013 00:21:36 +0000 Received: from ip-136.ish.com.au ([203.29.62.136]:59797) by fish.ish.com.au with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.76) (envelope-from ) id 1UUQyY-0004TC-04 for user@cayenne.apache.org; Tue, 23 Apr 2013 10:20:50 +1000 X-CTCH-RefID: str=0001.0A15020A.5175D3E2.003E,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 Message-ID: <5175D3E2.5030604@maniatis.org> Date: Tue, 23 Apr 2013 10:20:50 +1000 From: Aristedes Maniatis User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Thunderbird/21.0 MIME-Version: 1.0 To: user@cayenne.apache.org Subject: Re: Convert Oracle Type NUMBER to java.lang.Boolean References: <4C477FFD-D9A8-44D3-AA03-92C993001109@objectstyle.org> In-Reply-To: <4C477FFD-D9A8-44D3-AA03-92C993001109@objectstyle.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Yes, I do that all the time: integer in the database and boolean in the model. On the plus side when you (inevitably it seems) discover that your boolean actually needs 4 values, migrating to an enum is simple since you can leave the database alone and just change the model. Remember the good old days when sex was just male/female/null? Ari On 23/04/13 1:23am, Andrus Adamchik wrote: > Actually this should just work. No hacks are needed. But it should be mapped as NUMBER on the DbEntity side, and as java.lang.Boolean - on the ObjEntity side. If it doesn't, it is a bug that we need to fix. > > Andrus > > On Apr 22, 2013, at 4:51 AM, Markus Reich wrote: >> Hi, >> >> I've a problem with using boolean values in my cayenne class. >> In Oracle DB the field has type NUMBER and contains only 0 or 1 as value. >> Now I thought I can map this to a Boolean? >> I came to this because it also works when I select with an Expression: >> ExpressionFactory.matchExp(MiiPickingcontainer.DELETED_PROPERTY, false)); >> >> But when I make a check with getDeleted()==false, it doesn't work as >> getDeleted() always returns false? >> >> What would be the best approach to transform a Oracle NUMBER to a Boolean? >> >> Markus > -- --------------------------> Aristedes Maniatis GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A