cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <mgen...@masslight.net>
Subject Re: Convert Oracle Type NUMBER to java.lang.Boolean
Date Mon, 22 Apr 2013 12:40:13 GMT
Hi Markus,

I've always found booleans to be a little odd to work with, especially when
you have allows null.  You could always define your own TRUE/FALSE enum (or
ExtendedEnumeration) as 1 and 0 respectively and then do:

ExpressionFactory.matchExp(MiiPickingcontainer.DELETED_PROPERTY,
MyEnum.FALSE));

Keep in mind if your deleted property allows nulls, though, then false !=
null.

mrg



On Mon, Apr 22, 2013 at 4:51 AM, Markus Reich
<markus.reich@markusreich.at>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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message