cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hugi Thordarson <>
Subject Re: Reading boolean values stored in a database as chars
Date Thu, 08 Oct 2015 09:19:43 GMT
Thanks for the advice everyone. I think this is the correct way, writing cover methods won't
really cut it in my case since I’m going to perform queries using the fields in question.
The DB mixes different types for booleans in the database (some are strings, others are proper
booleans) but It looks like I can check for the type of the field in the type adaptor before
performing my operations, so I should be able to handle this correctly.

Do you know how I register my own type adaptor for BooleanType?

- hugi

> On 7. okt. 2015, at 19:08, John Huss < <>>
> Check out the code for org.apache.cayenne.access.types.BooleanType and it's
> subclasses.  I think you need to create your own extended type to handle
> it.  Not sure if you can have multiple different BooleanTypes in the same
> runtime, but you could have one that detects and switches
> behavior dynamically I guess.
> On Wed, Oct 7, 2015 at 12:19 PM Hugi Thordarson < <>>
>> Hi all.
>> Oh the joys of working with legacy databases… :) I’m now using a database
>> that sometimes stores boolean values as a char field with the value ’t’ or
>> ‘f’ (true or false). Can Cayenne help me map these fields to actual
>> booleans in my entities so I don’t have to think about this in my logic?
>> Cheers,
>> - hugi

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