List Info

Thread: TypeHandler for Xml data type in Sql Server




TypeHandler for Xml data type in Sql Server
user name
2008-01-14 08:47:26

Hi

 

I was wondering if any one could provide any pointers on how I might map an SqlServer Xml data type using Ibatis.

 

I am using the following: -

 

CREATE TABLE [dbo].[Reports](

           ;     [ID] [int] IDENTITY(1,1) NOT NULL,

           ;     [Config] [xml] NOT NULL

) ON [PRIMARY]

 

Part of my sqlMap is as follows: -

 

<resultMaps>

 &nbsp; &nbsp; &nbsp; <resultMap id="SelectResult" class="Report";>

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; <result property="Id" column="ID"/>

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; <result property="Config&quot; column="Config"; />

 &nbsp; &nbsp; &nbsp; </resultMap>

</resultMaps>

<statements>

 &nbsp; &nbsp; &nbsp; <select id="GetReport" parameterClass="int" resultMap="SelectResult">select * from dbo.Reports where ID = #Id#</select>

 &nbsp; &nbsp; &nbsp; <select id="GetReportList" parameterClass="int" resultMap="SelectResult">select * from dbo.Reports</select&gt;

 &nbsp; &nbsp; &nbsp;  &nbsp;…

</statements>

 

I was planning on my object along the lines of: -

 

public class report {

 &nbsp; &nbsp; &nbsp; …

 &nbsp; &nbsp; &nbsp; public SqlXml Config { .. }

}

 

But I suspect I need to somehow deal with a Binary stream.

 

Any help would be greatly appreciated.

 

Thanks in advance

Blair

Re: TypeHandler for Xml data type in Sql Server
user name
2008-01-14 12:21:33
There's a unit test showing how to use an XML input parameter, search in SVN a unit test named TestXMLParameter using the store procedure SelectAccountViaXML and have a look for inspiration.

Here9;s a Java XML TypeHandle
http://opensource.atlassian.com/confluence/oss/display/IBATIS/Type+Handler+Callbacks


--
Cheers,
Gilles
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )