You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Roberto Rabe <ro...@apache.org> on 2005/04/01 04:26:09 UTC

RE: Boolean properties with Microsoft OracleClient

It's on the radar:

http://wiki.apache.org/ibatis/Roadmap

(RoadMap hasn't been updated in a bit...but unfortunately, with the
current wiki issues, I think I'd rather wait until those wiki issues are
resolved before updating it.)

:-)

On Wed, March 30, 2005 11:52, Thompson, Kent said:
> Thanks.  I think I'll have to use the approach you mentioned (possibly
> storing an integer value of 0 or 1 in a separate property).
>
> Do you have any time frame when the 'custom type handler' feature might
> be included in the .NET version of Ibatis?  Seems like this could be
> used to overcome some of the shortcommings in the OracleClient.
>
> Thanks again,
> Kent
>
> -----Original Message-----
> From: Roberto Rabe [mailto:roberto@apache.org]
> Sent: Tuesday, March 29, 2005 3:00 PM
> To: ibatis-user-cs@incubator.apache.org
> Subject: Re: Boolean properties with Microsoft OracleClient
>
> Yes, there are known issues with GetBoolean and GetByte with the
> OracleClient provider (not supported).
>
> This is not a clean workaround, but you could create a 2nd set of
> property accessors in your class that is used by the mapper that
> actually sets the class bool field just to get it working.
>
> For example, the iBATIS NUnit tests use a class with a Guid property but
> the tests store it in a varchar field in Oracle.  To make the test pass,
> this is used (not great but it works with the provider and works on the
> same class' private field _guid):
>
> public Guid Guid
> {
> 	get
> 	{
> 		return _guid;
> 	}
> 	set
> 	{
> 		_guid = value;
> 	}
> }
>
> public string GuidString {
> 	get {
> 		return _guid.ToString();
> 	}
> 	set {
> 		if (value == null) {
> 			_guid = Guid.Empty;
> 		}
> 		else {
> 			_guid = new Guid(value.ToString());
> 		}
> 	}
> }
>
> Probably could poke holes in there like String.Empty but I dan't think
> the DataMapper passes that back as a result currently.  :-)
>
> Hope this helps!
>
> Roberto
>
>
>
> On Tue, March 29, 2005 12:02, Pablo Lopez said:
>> Hi Kent,
>>
>> I also had some problems with booleans with PostgreSQL. This was my
>> email and my problem:
>>
>>> Hi everybody,
>>>
>>> I'm using iBatis under .NET and PostgreSQL (ODBC driver). I'm trying
>>> my first mappings and I have a problem with the boolean datatype.
>>>
>>> Integer mapping is working okay, and I can query / insert objects
>>> without any trouble, but the problem arises when one of the
>>> attributes is a boolean (bool under .NET / bool under PostgreSQL).
>>>
>>> When I insert an object there is no problem, but when I query the
>>> database to populate an object, the following exception arises:
>>>
>>> "Uncontrolled Exception: System.InvalidCastException: "Specified
>>> conversion is not valid" (at
>>> System.Data.Odbc.OdbcDataReader.GetBoolean(Int32 i)
>>>
>>>
>>> I don't know what the problem is, cause I'm using bool types under
>>> .Net and under PostgreSQL. I also tried the bit type (in the
>>> documentation), but it doesn't work.
>>>
>>> What annoys me is that insertions are correct, but queries are not.
>>
>> I tried several solutions (specifying a dbtype = 'bool' in the
>> resultMap property, for example) but none of them worked, so now I'm
>> using shorts even it's still spring ;) (bad joke)
>>
>> Talking seriously, I know using a short type instead is messy and not
>> elegant, in fact it annoys me quite a lot, but it's the only one that
>> did work.
>>
>> I hope you're luckier. Just keep in touch if you come across
> something.
>>
>> See you,
>>
>> Pablo.
>>
>>
>>
>
>
>
>