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 Blair Sutton <bs...@northps.com> on 2008/01/14 15:47:26 UTC
TypeHandler for Xml data type in Sql Server
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>
<resultMap id="SelectResult" class="Report">
<result property="Id" column="ID"/>
<result property="Config" column="Config" />
</resultMap>
</resultMaps>
<statements>
<select id="GetReport" parameterClass="int" resultMap="SelectResult">select * from dbo.Reports where ID = #Id#</select>
<select id="GetReportList" parameterClass="int" resultMap="SelectResult">select * from dbo.Reports</select>
...
</statements>
...
I was planning on my object along the lines of: -
public class report {
...
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
Posted by Gilles Bayon <ib...@gmail.com>.
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.
Here's a Java XML TypeHandler
http://opensource.atlassian.com/confluence/oss/display/IBATIS/Type+Handler+Callbacks
--
Cheers,
Gilles