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 DaiMichael <da...@barcap.com> on 2008/09/10 19:09:02 UTC

Enum TypeHandlers issues...

Hi,

Having a few problems with converting our enums to varchars (it works one
way (i.e. getting it back from db if i directly ref it on the resultmap) but
not putting into the db), this is a legacy db so can't change the way it
works (hence using iBatis).

	<alias>
		<typeAlias alias="Currency" type="Research.Indices.Domain.Enums.Currency,
Research.Indices"/>
		<typeAlias alias="CurrencyTypeHandler"
type="Research.Indices.DataAccess.TypeHandlers.CurrencyTypeHandler,
Research.Indices"/>
		<typeAlias alias="DecimalTypeHandler"
type="Research.Indices.DataAccess.TypeHandlers.DecimalTypeHandler,
Research.Indices"/>
	</alias>  
	<typeHandlers>
		<typeHandler type="Currency" dbType="varchar"
callback="CurrencyTypeHandler"/>
		<typeHandler type="decimal" callback="DecimalTypeHandler"/>
	</typeHandlers>

It is picking up the DecimalTypeHandler as I have turned logging on (and
shows it overrides it) but when i put in my Currency/CurrencyTypeHandler i
get errors on xml validation, this makes me feel that the alias hasn't
worked as it can't load the type 'Currency' (which is an enum, just to be
clear) ...hmmmm... 

using 1.6.1, connecting to mssql 2000, provider sqlserver2.0

any idea's what is going on ? cheers for any replies !
-------- Error

IBatisNet.Common.Exceptions.ConfigurationException: 
- The error occurred while loading typeHandler.

at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
isCallFromDao) 
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Configure(XmlDocument
document) 
at Research.Indices.DataAccess.DataSource.IbatisIndexDBContext.initMapper()
in IbatisIndexDBContext.cs:line 28 
at Research.Indices.DataAccess.DataSource.IbatisIndexDBContext.Get() in
IbatisIndexDBContext.cs:line 39 
at Research.Indices.DataAccess.DataSource.IbatisDataSource.Get[T](ICommand
command) in IbatisDataSource.cs:line 11 
at
Research.Indices.Test.DataAccess.DataSource.IbatisFxRateTests.IBatisDataSourceCanLoadFxRateById()
in IbatisFxRateTests.cs:line 22 

IBatisNet.Common.Exceptions.ConfigurationException: Error registering
TypeHandler class "CurrencyTypeHandler" for handling .Net type "Currency"
and dbType "varchar". Cause: Could not load type from string value
'Currency'.

at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize() 
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
isCallFromDao) 

System.TypeLoadException: Could not load type from string value 'Currency'.

at IBatisNet.Common.Utilities.TypesResolver.TypeResolver.ResolveType(String
typeName) 
at IBatisNet.Common.Utilities.TypesResolver.TypeResolver.Resolve(String
typeName) 
at
IBatisNet.Common.Utilities.TypesResolver.CachedTypeResolver.Resolve(String
typeName) 
at IBatisNet.Common.Utilities.TypeUtils.ResolveType(String typeName) 
at
IBatisNet.DataMapper.Configuration.Serializers.TypeHandlerDeSerializer.Deserialize(XmlNode
node, ConfigurationScope configScope) 
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize() 

-- 
View this message in context: http://www.nabble.com/Enum-TypeHandlers-issues...-tp19415050p19415050.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


Re: Enum TypeHandlers issues...

Posted by DaiMichael <da...@barcap.com>.
I have searched my sqlmap.xml (files) and I haven't referenced it any where
else ? hmmmm, I think i might end up having to debug ibatis just to see what
I'm doing wrong.


DaiMichael wrote:
> 
> Hi,
> 
> Having a few problems with converting our enums to varchars (it works one
> way (i.e. getting it back from db if i directly ref it on the resultmap)
> but not putting into the db), this is a legacy db so can't change the way
> it works (hence using iBatis).
> 
> 	<alias>
> 		<typeAlias alias="Currency"
> type="Research.Indices.Domain.Enums.Currency, Research.Indices"/>
> 		<typeAlias alias="CurrencyTypeHandler"
> type="Research.Indices.DataAccess.TypeHandlers.CurrencyTypeHandler,
> Research.Indices"/>
> 		<typeAlias alias="DecimalTypeHandler"
> type="Research.Indices.DataAccess.TypeHandlers.DecimalTypeHandler,
> Research.Indices"/>
> 	</alias>  
> 	<typeHandlers>
> 		<typeHandler type="Currency" dbType="varchar"
> callback="CurrencyTypeHandler"/>
> 		<typeHandler type="decimal" callback="DecimalTypeHandler"/>
> 	</typeHandlers>
> 
> It is picking up the DecimalTypeHandler as I have turned logging on (and
> shows it overrides it) but when i put in my Currency/CurrencyTypeHandler i
> get errors on xml validation, this makes me feel that the alias hasn't
> worked as it can't load the type 'Currency' (which is an enum, just to be
> clear) ...hmmmm... 
> 
> using 1.6.1, connecting to mssql 2000, provider sqlserver2.0
> 
> any idea's what is going on ? cheers for any replies !
> -------- Error
> 
> IBatisNet.Common.Exceptions.ConfigurationException: 
> - The error occurred while loading typeHandler.
> 
> at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
> document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
> isCallFromDao) 
> at
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Configure(XmlDocument
> document) 
> at
> Research.Indices.DataAccess.DataSource.IbatisIndexDBContext.initMapper()
> in IbatisIndexDBContext.cs:line 28 
> at Research.Indices.DataAccess.DataSource.IbatisIndexDBContext.Get() in
> IbatisIndexDBContext.cs:line 39 
> at Research.Indices.DataAccess.DataSource.IbatisDataSource.Get[T](ICommand
> command) in IbatisDataSource.cs:line 11 
> at
> Research.Indices.Test.DataAccess.DataSource.IbatisFxRateTests.IBatisDataSourceCanLoadFxRateById()
> in IbatisFxRateTests.cs:line 22 
> 
> IBatisNet.Common.Exceptions.ConfigurationException: Error registering
> TypeHandler class "CurrencyTypeHandler" for handling .Net type "Currency"
> and dbType "varchar". Cause: Could not load type from string value
> 'Currency'.
> 
> at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize() 
> at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
> document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
> isCallFromDao) 
> 
> System.TypeLoadException: Could not load type from string value
> 'Currency'.
> 
> at
> IBatisNet.Common.Utilities.TypesResolver.TypeResolver.ResolveType(String
> typeName) 
> at IBatisNet.Common.Utilities.TypesResolver.TypeResolver.Resolve(String
> typeName) 
> at
> IBatisNet.Common.Utilities.TypesResolver.CachedTypeResolver.Resolve(String
> typeName) 
> at IBatisNet.Common.Utilities.TypeUtils.ResolveType(String typeName) 
> at
> IBatisNet.DataMapper.Configuration.Serializers.TypeHandlerDeSerializer.Deserialize(XmlNode
> node, ConfigurationScope configScope) 
> at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize() 
> 
> 

-- 
View this message in context: http://www.nabble.com/Enum-TypeHandlers-issues...-tp19415050p19491730.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


RE: Enum TypeHandlers issues...

Posted by Milivoj Milani <mi...@gzr.hr>.
Did you use Currency alias somewhere else (in another .xml config file)?

-----Original Message-----
From: DaiMichael [mailto:david.michael@barcap.com] 
Sent: Monday, September 15, 2008 11:47 AM
To: user-cs@ibatis.apache.org
Subject: RE: Enum TypeHandlers issues...


Thanks for the reply, checked all that and it is correct. I did try with
a class and it didn't work either (i.e. it didn't load up the alias - it
is rather strange and fustrating.



Milivoj Milani wrote:
> 
> Hi,
> 
> could you just try converting Curreny to simple class (temporarly) and

> see what happens. Maybe it's an enum issue? I am using type handlers 
> with classes, didn't try it on enums. Also, make sure the enum full 
> name is correct, dll name is correct and enum is public.
> 
> This kind of message usually indicates wrong path or "strange
behaviour"
> ;)
> 
> Cheers.
> 
> -----Original Message-----
> From: DaiMichael [mailto:david.michael@barcap.com]
> Sent: Wednesday, September 10, 2008 7:09 PM
> To: user-cs@ibatis.apache.org
> Subject: Enum TypeHandlers issues...
> 
> 
> Hi,
> 
> Having a few problems with converting our enums to varchars (it works 
> one way (i.e. getting it back from db if i directly ref it on the 
> resultmap) but not putting into the db), this is a legacy db so can't 
> change the way it works (hence using iBatis).
> 
> 	<alias>
> 		<typeAlias alias="Currency"
> type="Research.Indices.Domain.Enums.Currency,
> Research.Indices"/>
> 		<typeAlias alias="CurrencyTypeHandler"
> type="Research.Indices.DataAccess.TypeHandlers.CurrencyTypeHandler,
> Research.Indices"/>
> 		<typeAlias alias="DecimalTypeHandler"
> type="Research.Indices.DataAccess.TypeHandlers.DecimalTypeHandler,
> Research.Indices"/>
> 	</alias>  
> 	<typeHandlers>
> 		<typeHandler type="Currency" dbType="varchar"
> callback="CurrencyTypeHandler"/>
> 		<typeHandler type="decimal"
> callback="DecimalTypeHandler"/>
> 	</typeHandlers>
> 
> It is picking up the DecimalTypeHandler as I have turned logging on 
> (and shows it overrides it) but when i put in my 
> Currency/CurrencyTypeHandler i get errors on xml validation, this 
> makes me feel that the alias hasn't worked as it can't load the type 
> 'Currency' (which is an enum, just to be
> clear) ...hmmmm... 
> 
> using 1.6.1, connecting to mssql 2000, provider sqlserver2.0
> 
> any idea's what is going on ? cheers for any replies !
> -------- Error
> 
> IBatisNet.Common.Exceptions.ConfigurationException: 
> - The error occurred while loading typeHandler.
> 
> at 
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
> document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
> isCallFromDao)
> at
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Configure(XmlDocum
> en
> t
> document)
> at
> Research.Indices.DataAccess.DataSource.IbatisIndexDBContext.initMapper
> ()
> in IbatisIndexDBContext.cs:line 28
> at Research.Indices.DataAccess.DataSource.IbatisIndexDBContext.Get() 
> in IbatisIndexDBContext.cs:line 39 at 
> Research.Indices.DataAccess.DataSource.IbatisDataSource.Get[T](IComman
> d
> command) in IbatisDataSource.cs:line 11 at 
> Research.Indices.Test.DataAccess.DataSource.IbatisFxRateTests.IBatisDa
> ta
> SourceCanLoadFxRateById()
> in IbatisFxRateTests.cs:line 22
> 
> IBatisNet.Common.Exceptions.ConfigurationException: Error registering 
> TypeHandler class "CurrencyTypeHandler" for handling .Net type 
> "Currency"
> and dbType "varchar". Cause: Could not load type from string value 
> 'Currency'.
> 
> at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize()
> at 
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
> document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
> isCallFromDao)
> 
> System.TypeLoadException: Could not load type from string value 
> 'Currency'.
> 
> at
> IBatisNet.Common.Utilities.TypesResolver.TypeResolver.ResolveType(Stri
> ng
> typeName)
> at 
> IBatisNet.Common.Utilities.TypesResolver.TypeResolver.Resolve(String
> typeName)
> at
> IBatisNet.Common.Utilities.TypesResolver.CachedTypeResolver.Resolve(St
> ri
> ng
> typeName)
> at IBatisNet.Common.Utilities.TypeUtils.ResolveType(String typeName) 
> at 
> IBatisNet.DataMapper.Configuration.Serializers.TypeHandlerDeSerializer
> .D
> eserialize(XmlNode
> node, ConfigurationScope configScope) at 
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize()
> 
> --
> View this message in context:
> http://www.nabble.com/Enum-TypeHandlers-issues...-tp19415050p19415050.
> ht
> ml
> Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
> 
> 
> 

--
View this message in context:
http://www.nabble.com/Enum-TypeHandlers-issues...-tp19415050p19489959.ht
ml
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


RE: Enum TypeHandlers issues...

Posted by DaiMichael <da...@barcap.com>.
Thanks for the reply, checked all that and it is correct. I did try with a
class and it didn't work either (i.e. it didn't load up the alias - it is
rather strange and fustrating.



Milivoj Milani wrote:
> 
> Hi,
> 
> could you just try converting Curreny to simple class (temporarly) and
> see what happens. Maybe it's an enum issue? I am using type handlers
> with classes, didn't try it on enums. Also, make sure the enum full name
> is correct, dll name is correct and enum is public. 
> 
> This kind of message usually indicates wrong path or "strange behaviour"
> ;)
> 
> Cheers.
> 
> -----Original Message-----
> From: DaiMichael [mailto:david.michael@barcap.com] 
> Sent: Wednesday, September 10, 2008 7:09 PM
> To: user-cs@ibatis.apache.org
> Subject: Enum TypeHandlers issues...
> 
> 
> Hi,
> 
> Having a few problems with converting our enums to varchars (it works
> one
> way (i.e. getting it back from db if i directly ref it on the resultmap)
> but
> not putting into the db), this is a legacy db so can't change the way it
> works (hence using iBatis).
> 
> 	<alias>
> 		<typeAlias alias="Currency"
> type="Research.Indices.Domain.Enums.Currency,
> Research.Indices"/>
> 		<typeAlias alias="CurrencyTypeHandler"
> type="Research.Indices.DataAccess.TypeHandlers.CurrencyTypeHandler,
> Research.Indices"/>
> 		<typeAlias alias="DecimalTypeHandler"
> type="Research.Indices.DataAccess.TypeHandlers.DecimalTypeHandler,
> Research.Indices"/>
> 	</alias>  
> 	<typeHandlers>
> 		<typeHandler type="Currency" dbType="varchar"
> callback="CurrencyTypeHandler"/>
> 		<typeHandler type="decimal"
> callback="DecimalTypeHandler"/>
> 	</typeHandlers>
> 
> It is picking up the DecimalTypeHandler as I have turned logging on (and
> shows it overrides it) but when i put in my Currency/CurrencyTypeHandler
> i
> get errors on xml validation, this makes me feel that the alias hasn't
> worked as it can't load the type 'Currency' (which is an enum, just to
> be
> clear) ...hmmmm... 
> 
> using 1.6.1, connecting to mssql 2000, provider sqlserver2.0
> 
> any idea's what is going on ? cheers for any replies !
> -------- Error
> 
> IBatisNet.Common.Exceptions.ConfigurationException: 
> - The error occurred while loading typeHandler.
> 
> at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
> document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
> isCallFromDao) 
> at
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Configure(XmlDocumen
> t
> document) 
> at
> Research.Indices.DataAccess.DataSource.IbatisIndexDBContext.initMapper()
> in IbatisIndexDBContext.cs:line 28 
> at Research.Indices.DataAccess.DataSource.IbatisIndexDBContext.Get() in
> IbatisIndexDBContext.cs:line 39 
> at
> Research.Indices.DataAccess.DataSource.IbatisDataSource.Get[T](ICommand
> command) in IbatisDataSource.cs:line 11 
> at
> Research.Indices.Test.DataAccess.DataSource.IbatisFxRateTests.IBatisData
> SourceCanLoadFxRateById()
> in IbatisFxRateTests.cs:line 22 
> 
> IBatisNet.Common.Exceptions.ConfigurationException: Error registering
> TypeHandler class "CurrencyTypeHandler" for handling .Net type
> "Currency"
> and dbType "varchar". Cause: Could not load type from string value
> 'Currency'.
> 
> at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize() 
> at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
> document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
> isCallFromDao) 
> 
> System.TypeLoadException: Could not load type from string value
> 'Currency'.
> 
> at
> IBatisNet.Common.Utilities.TypesResolver.TypeResolver.ResolveType(String
> typeName) 
> at IBatisNet.Common.Utilities.TypesResolver.TypeResolver.Resolve(String
> typeName) 
> at
> IBatisNet.Common.Utilities.TypesResolver.CachedTypeResolver.Resolve(Stri
> ng
> typeName) 
> at IBatisNet.Common.Utilities.TypeUtils.ResolveType(String typeName) 
> at
> IBatisNet.DataMapper.Configuration.Serializers.TypeHandlerDeSerializer.D
> eserialize(XmlNode
> node, ConfigurationScope configScope) 
> at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize() 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Enum-TypeHandlers-issues...-tp19415050p19415050.ht
> ml
> Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Enum-TypeHandlers-issues...-tp19415050p19489959.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


RE: Enum TypeHandlers issues...

Posted by Milivoj Milani <mi...@gzr.hr>.
Hi,

could you just try converting Curreny to simple class (temporarly) and
see what happens. Maybe it's an enum issue? I am using type handlers
with classes, didn't try it on enums. Also, make sure the enum full name
is correct, dll name is correct and enum is public. 

This kind of message usually indicates wrong path or "strange behaviour"
;)

Cheers.

-----Original Message-----
From: DaiMichael [mailto:david.michael@barcap.com] 
Sent: Wednesday, September 10, 2008 7:09 PM
To: user-cs@ibatis.apache.org
Subject: Enum TypeHandlers issues...


Hi,

Having a few problems with converting our enums to varchars (it works
one
way (i.e. getting it back from db if i directly ref it on the resultmap)
but
not putting into the db), this is a legacy db so can't change the way it
works (hence using iBatis).

	<alias>
		<typeAlias alias="Currency"
type="Research.Indices.Domain.Enums.Currency,
Research.Indices"/>
		<typeAlias alias="CurrencyTypeHandler"
type="Research.Indices.DataAccess.TypeHandlers.CurrencyTypeHandler,
Research.Indices"/>
		<typeAlias alias="DecimalTypeHandler"
type="Research.Indices.DataAccess.TypeHandlers.DecimalTypeHandler,
Research.Indices"/>
	</alias>  
	<typeHandlers>
		<typeHandler type="Currency" dbType="varchar"
callback="CurrencyTypeHandler"/>
		<typeHandler type="decimal"
callback="DecimalTypeHandler"/>
	</typeHandlers>

It is picking up the DecimalTypeHandler as I have turned logging on (and
shows it overrides it) but when i put in my Currency/CurrencyTypeHandler
i
get errors on xml validation, this makes me feel that the alias hasn't
worked as it can't load the type 'Currency' (which is an enum, just to
be
clear) ...hmmmm... 

using 1.6.1, connecting to mssql 2000, provider sqlserver2.0

any idea's what is going on ? cheers for any replies !
-------- Error

IBatisNet.Common.Exceptions.ConfigurationException: 
- The error occurred while loading typeHandler.

at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
isCallFromDao) 
at
IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Configure(XmlDocumen
t
document) 
at
Research.Indices.DataAccess.DataSource.IbatisIndexDBContext.initMapper()
in IbatisIndexDBContext.cs:line 28 
at Research.Indices.DataAccess.DataSource.IbatisIndexDBContext.Get() in
IbatisIndexDBContext.cs:line 39 
at
Research.Indices.DataAccess.DataSource.IbatisDataSource.Get[T](ICommand
command) in IbatisDataSource.cs:line 11 
at
Research.Indices.Test.DataAccess.DataSource.IbatisFxRateTests.IBatisData
SourceCanLoadFxRateById()
in IbatisFxRateTests.cs:line 22 

IBatisNet.Common.Exceptions.ConfigurationException: Error registering
TypeHandler class "CurrencyTypeHandler" for handling .Net type
"Currency"
and dbType "varchar". Cause: Could not load type from string value
'Currency'.

at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize() 
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
isCallFromDao) 

System.TypeLoadException: Could not load type from string value
'Currency'.

at
IBatisNet.Common.Utilities.TypesResolver.TypeResolver.ResolveType(String
typeName) 
at IBatisNet.Common.Utilities.TypesResolver.TypeResolver.Resolve(String
typeName) 
at
IBatisNet.Common.Utilities.TypesResolver.CachedTypeResolver.Resolve(Stri
ng
typeName) 
at IBatisNet.Common.Utilities.TypeUtils.ResolveType(String typeName) 
at
IBatisNet.DataMapper.Configuration.Serializers.TypeHandlerDeSerializer.D
eserialize(XmlNode
node, ConfigurationScope configScope) 
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize() 

-- 
View this message in context:
http://www.nabble.com/Enum-TypeHandlers-issues...-tp19415050p19415050.ht
ml
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


RE: Enum TypeHandlers issues...

Posted by Milivoj Milani <mi...@gzr.hr>.
Hm, yes, I was looking this very minute at my code. I have the same
thing, not using aliases for type handler class. Sorry for not looking
there before, i think your feature request looks reasonable.

  <resultMaps>
    <resultMap id="FullResultMap" class="WorkOrderTask">
      <result property="Id" column="ID" />
      <result property="Leader" column="LEADER" />
      <result property="EstimatedWork" column="ESTIMATED_WORK"
typeHandler="IPS.Finance.OracleDataAccessLayer.NumberTypeHandler,
IPS.Finance.OracleDataAccessLayer"/>
      <result property="Name" column="NAME" />
      <result property="Description" column="DESCRIPTION"/>
      <result property="EstimatedStartDate"
column="ESTIMATED_START_DATE"/>
      <result property="EstimatedEndDate" column="ESTIMATED_END_DATE"/>
      <result property="Completed" column="COMPLETED"
typeHandler="IPS.Finance.OracleDataAccessLayer.BooleanTypeHandler,
IPS.Finance.OracleDataAccessLayer"/>
    </resultMap>
  </resultMaps> 

Glad it works ;)

Cheers.

-----Original Message-----
From: DaiMichael [mailto:david.michael@barcap.com] 
Sent: Monday, September 15, 2008 2:40 PM
To: user-cs@ibatis.apache.org
Subject: Re: Enum TypeHandlers issues...


Sorry to reply to my own thread.. poor form, but i wanted to share my
solution which isn't fixed but at least working.

---
So basically I'm still unable to alias the enums and assign them to the
typehandler although un-alias seems to work fine :

<typeHandlers>
  <typeHandler type="Research.Indices.Domain.Enums.Currency"
callback="CurrencyTypeHandler"/>
  ....
  <typeHandler type="decimal" callback="DecimalTypeHandler"/>
</typeHandlers>

but all I need to do then in my sqlMap files is specifically call the
typeHandler in the property, again this works and means that my code to
map enums to and from db (via result/parameter maps) now works fine. The
only "extra" work i have in the xml code is specifically assigning the
typeHandlers rather than iBatis working it out by types which would have
been nice but doesn't really make any difference to our c#
implimentation and I might take a look in my spare time on how to fix
this issue.

Thanks for looking at the issues Milivoj.


DaiMichael wrote:
> 
> Hi,
> 
> Having a few problems with converting our enums to varchars (it works 
> one way (i.e. getting it back from db if i directly ref it on the 
> resultmap) but not putting into the db), this is a legacy db so can't 
> change the way it works (hence using iBatis).
> 
> 	<alias>
> 		<typeAlias alias="Currency"
> type="Research.Indices.Domain.Enums.Currency, Research.Indices"/>
> 		<typeAlias alias="CurrencyTypeHandler"
> type="Research.Indices.DataAccess.TypeHandlers.CurrencyTypeHandler,
> Research.Indices"/>
> 		<typeAlias alias="DecimalTypeHandler"
> type="Research.Indices.DataAccess.TypeHandlers.DecimalTypeHandler,
> Research.Indices"/>
> 	</alias>  
> 	<typeHandlers>
> 		<typeHandler type="Currency" dbType="varchar"
> callback="CurrencyTypeHandler"/>
> 		<typeHandler type="decimal"
callback="DecimalTypeHandler"/>
> 	</typeHandlers>
> 
> It is picking up the DecimalTypeHandler as I have turned logging on 
> (and shows it overrides it) but when i put in my 
> Currency/CurrencyTypeHandler i get errors on xml validation, this 
> makes me feel that the alias hasn't worked as it can't load the type 
> 'Currency' (which is an enum, just to be
> clear) ...hmmmm... 
> 
> using 1.6.1, connecting to mssql 2000, provider sqlserver2.0
> 
> any idea's what is going on ? cheers for any replies !
> -------- Error
> 
> IBatisNet.Common.Exceptions.ConfigurationException: 
> - The error occurred while loading typeHandler.
> 
> at 
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
> document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
> isCallFromDao)
> at
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Configure(XmlDocum
> ent
> document)
> at
> Research.Indices.DataAccess.DataSource.IbatisIndexDBContext.initMapper
> ()
> in IbatisIndexDBContext.cs:line 28
> at Research.Indices.DataAccess.DataSource.IbatisIndexDBContext.Get() 
> in IbatisIndexDBContext.cs:line 39 at 
> Research.Indices.DataAccess.DataSource.IbatisDataSource.Get[T](IComman
> d
> command) in IbatisDataSource.cs:line 11 at
> Research.Indices.Test.DataAccess.DataSource.IbatisFxRateTests.IBatisDa
> taSourceCanLoadFxRateById()
> in IbatisFxRateTests.cs:line 22
> 
> IBatisNet.Common.Exceptions.ConfigurationException: Error registering 
> TypeHandler class "CurrencyTypeHandler" for handling .Net type
"Currency"
> and dbType "varchar". Cause: Could not load type from string value 
> 'Currency'.
> 
> at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize()
> at 
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
> document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
> isCallFromDao)
> 
> System.TypeLoadException: Could not load type from string value 
> 'Currency'.
> 
> at
> IBatisNet.Common.Utilities.TypesResolver.TypeResolver.ResolveType(Stri
> ng
> typeName)
> at 
> IBatisNet.Common.Utilities.TypesResolver.TypeResolver.Resolve(String
> typeName)
> at
> IBatisNet.Common.Utilities.TypesResolver.CachedTypeResolver.Resolve(St
> ring
> typeName)
> at IBatisNet.Common.Utilities.TypeUtils.ResolveType(String typeName) 
> at 
> IBatisNet.DataMapper.Configuration.Serializers.TypeHandlerDeSerializer
> .Deserialize(XmlNode node, ConfigurationScope configScope) at 
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize()
> 
> 

--
View this message in context:
http://www.nabble.com/Enum-TypeHandlers-issues...-tp19415050p19492154.ht
ml
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


Re: Enum TypeHandlers issues...

Posted by DaiMichael <da...@barcap.com>.
Sorry to reply to my own thread.. poor form, but i wanted to share my
solution which isn't fixed but at least working.

---
So basically I'm still unable to alias the enums and assign them to the
typehandler although un-alias seems to work fine :

<typeHandlers>
  <typeHandler type="Research.Indices.Domain.Enums.Currency"
callback="CurrencyTypeHandler"/>
  ....
  <typeHandler type="decimal" callback="DecimalTypeHandler"/>
</typeHandlers>

but all I need to do then in my sqlMap files is specifically call the
typeHandler in the property, again this works and means that my code to map
enums to and from db (via result/parameter maps) now works fine. The only
"extra" work i have in the xml code is specifically assigning the
typeHandlers rather than iBatis working it out by types which would have
been nice but doesn't really make any difference to our c# implimentation
and I might take a look in my spare time on how to fix this issue.

Thanks for looking at the issues Milivoj.


DaiMichael wrote:
> 
> Hi,
> 
> Having a few problems with converting our enums to varchars (it works one
> way (i.e. getting it back from db if i directly ref it on the resultmap)
> but not putting into the db), this is a legacy db so can't change the way
> it works (hence using iBatis).
> 
> 	<alias>
> 		<typeAlias alias="Currency"
> type="Research.Indices.Domain.Enums.Currency, Research.Indices"/>
> 		<typeAlias alias="CurrencyTypeHandler"
> type="Research.Indices.DataAccess.TypeHandlers.CurrencyTypeHandler,
> Research.Indices"/>
> 		<typeAlias alias="DecimalTypeHandler"
> type="Research.Indices.DataAccess.TypeHandlers.DecimalTypeHandler,
> Research.Indices"/>
> 	</alias>  
> 	<typeHandlers>
> 		<typeHandler type="Currency" dbType="varchar"
> callback="CurrencyTypeHandler"/>
> 		<typeHandler type="decimal" callback="DecimalTypeHandler"/>
> 	</typeHandlers>
> 
> It is picking up the DecimalTypeHandler as I have turned logging on (and
> shows it overrides it) but when i put in my Currency/CurrencyTypeHandler i
> get errors on xml validation, this makes me feel that the alias hasn't
> worked as it can't load the type 'Currency' (which is an enum, just to be
> clear) ...hmmmm... 
> 
> using 1.6.1, connecting to mssql 2000, provider sqlserver2.0
> 
> any idea's what is going on ? cheers for any replies !
> -------- Error
> 
> IBatisNet.Common.Exceptions.ConfigurationException: 
> - The error occurred while loading typeHandler.
> 
> at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
> document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
> isCallFromDao) 
> at
> IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Configure(XmlDocument
> document) 
> at
> Research.Indices.DataAccess.DataSource.IbatisIndexDBContext.initMapper()
> in IbatisIndexDBContext.cs:line 28 
> at Research.Indices.DataAccess.DataSource.IbatisIndexDBContext.Get() in
> IbatisIndexDBContext.cs:line 39 
> at Research.Indices.DataAccess.DataSource.IbatisDataSource.Get[T](ICommand
> command) in IbatisDataSource.cs:line 11 
> at
> Research.Indices.Test.DataAccess.DataSource.IbatisFxRateTests.IBatisDataSourceCanLoadFxRateById()
> in IbatisFxRateTests.cs:line 22 
> 
> IBatisNet.Common.Exceptions.ConfigurationException: Error registering
> TypeHandler class "CurrencyTypeHandler" for handling .Net type "Currency"
> and dbType "varchar". Cause: Could not load type from string value
> 'Currency'.
> 
> at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize() 
> at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
> document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
> isCallFromDao) 
> 
> System.TypeLoadException: Could not load type from string value
> 'Currency'.
> 
> at
> IBatisNet.Common.Utilities.TypesResolver.TypeResolver.ResolveType(String
> typeName) 
> at IBatisNet.Common.Utilities.TypesResolver.TypeResolver.Resolve(String
> typeName) 
> at
> IBatisNet.Common.Utilities.TypesResolver.CachedTypeResolver.Resolve(String
> typeName) 
> at IBatisNet.Common.Utilities.TypeUtils.ResolveType(String typeName) 
> at
> IBatisNet.DataMapper.Configuration.Serializers.TypeHandlerDeSerializer.Deserialize(XmlNode
> node, ConfigurationScope configScope) 
> at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize() 
> 
> 

-- 
View this message in context: http://www.nabble.com/Enum-TypeHandlers-issues...-tp19415050p19492154.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.