<?xml version="1.0" encoding="utf-8"?>
<sqlMap namespace="Other" xmlns="http://ibatis.apache.org/mapping" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
	
	<alias>
		<typeAlias alias="Other" type="IBatisNet.DataMapper.Test.Domain.Other, IBatisNet.DataMapper.Test"/>
		<typeAlias alias="OneZeroBool" type="IBatisNet.DataMapper.Test.Domain.OneZeroBoolTypeHandlerCallback, IBatisNet.DataMapper.Test"/>
		<typeAlias alias="A" type="IBatisNet.DataMapper.Test.Domain.A, IBatisNet.DataMapper.Test"/>
		<typeAlias alias="B" type="IBatisNet.DataMapper.Test.Domain.B, IBatisNet.DataMapper.Test"/>
		<typeAlias alias="C" type="IBatisNet.DataMapper.Test.Domain.C, IBatisNet.DataMapper.Test"/>
		<typeAlias alias="D" type="IBatisNet.DataMapper.Test.Domain.D, IBatisNet.DataMapper.Test"/>
		<typeAlias alias="E" type="IBatisNet.DataMapper.Test.Domain.E, IBatisNet.DataMapper.Test"/>
		<typeAlias alias="F" type="IBatisNet.DataMapper.Test.Domain.F, IBatisNet.DataMapper.Test"/>		
	</alias>
	
	<resultMaps>                                    
		<resultMap id="other-result"  class="Other" >
			<result property="Int"		column="Other_Int" dbType="Int32"/>
			<result property="Long"		column="Other_Long" dbType="Int64"/>
			<result property="Bool"		column="Other_Bit" typeHandler="OneZeroBool"/>
			<result property="Bool2"	column="Other_String" typeHandler="OuiNonBool"/>
		</resultMap>

		<resultMap id="A-result"  class="A" >
			<result property="Id"		column="A_ID"/>
			<result property="Libelle"	column="A_Libelle"/>
			<result property="B"		resultMapping="Other.B-result"/>
			<result property="E"		resultMapping="Other.E-result"/>
			<result property="F"		resultMapping="Other.F-result"/>
		</resultMap>
			
		<resultMap id="B-result"  class="B" >
			<result property="Id"		column="B_ID"/>
			<result property="Libelle"	column="B_Libelle"/>
			<result property="C"		resultMapping="Other.C-result"/>
			<result property="D"		resultMapping="Other.D-result"/>
		</resultMap>
				
		<resultMap id="C-result"  class="C" >
			<result property="Id"		column="C_ID"/>
			<result property="Libelle"	column="C_Libelle"/>
		</resultMap>
		
		<resultMap id="D-result"  class="D" >
			<result property="Id"		column="D_ID"/>
			<result property="Libelle"	column="D_Libelle"/>
		</resultMap>

		<resultMap id="E-result"  class="E" >
			<result property="Id"		column="E_ID"/>
			<result property="Libelle"	column="E_Libelle"/>
		</resultMap>	

		<resultMap id="F-result"  class="F" >
			<result property="Id"		column="F_ID"/>
			<result property="Libelle"	column="F_Libelle"/>
		</resultMap>		
	</resultMaps>
	
	<statements>

		<select id="SelectComplexJoined" resultMap="A-result">
		SELECT     
			A.Id AS A_ID,
			A.A_Libelle AS A_Libelle, 
			B.ID AS B_ID,
			B.B_Libelle AS B_Libelle,
			C.ID AS C_ID,
			C.C_Libelle AS C_Libelle,
			D.ID AS D_ID,
			D.D_Libelle AS D_Libelle,
			E.ID AS E_ID,
			E.E_Libelle AS E_Libelle,
			F.ID AS F_ID,
			F.F_Libelle AS F_Libelle 
			FROM         A 
			LEFT OUTER JOIN B ON A.B_ID = B.ID 
			LEFT OUTER JOIN C ON B.C_ID = C.ID
			LEFT OUTER JOIN D ON B.D_ID = D.ID
			LEFT OUTER JOIN E ON A.E_ID = E.ID
			LEFT OUTER JOIN F ON A.F_ID = F.ID
		</select>

		<statement id="DynamicSelectByIntLong" 
			parameterClass="Hashtable" 
			resultMap="other-result">
			select
				Other_Int,
				Other_Long,
				Other_Bit, 
				Other_String
			from Others  
			<dynamic prepend="WHERE"> 
				<isNotEqual prepend="AND" property="year" compareValue="0"> 
				Other_Int = #year#  
				</isNotEqual> 
				 
				<isNotEqual prepend="AND" property="areaid" compareValue="0"> 
				Other_Long = #areaid:Int64# 
				</isNotEqual>  
			</dynamic> 
		</statement>
				
		<!--
		Use custom typeHandler to get around error since Oracle column is an integer and 
		ODP does not have a proper typeHandler to convert bool to Oracle integer data type

		Otherwise...		
		Throws System.ArgumentException : 
		Value does not fall within the expected range.
		
		at Oracle.DataAccess.Client.OracleParameter.set_Value(Object value)
		at IBatisNet.DataMapper.Commands.DefaultPreparedCommand.ApplyParameterMap(IDalSession session, IDbCommand command, RequestScope request, IStatement statement, Object parameterObject) in c:\projects\ibatis\asf\trunk\cs\mapper\ibatisnet.datamapper\commands\defaultpreparedcommand.cs:line 169
		at IBatisNet.DataMapper.Commands.DefaultPreparedCommand.Create(RequestScope request, IDalSession session, IStatement statement, Object parameterObject) in c:\projects\ibatis\asf\trunk\cs\mapper\ibatisnet.datamapper\commands\defaultpreparedcommand.cs:line 80
		at IBatisNet.DataMapper.MappedStatements.MappedStatement.RunQueryForObject(RequestScope request, IDalSession session, Object parameterObject, Object resultObject) in C:\projects\ibatis\asf\trunk\cs\mapper\IBatisNet.DataMapper\MappedStatements\MappedStatement.cs:line 569
		at IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObject(IDalSession session, Object parameterObject, Object resultObject) in C:\projects\ibatis\asf\trunk\cs\mapper\IBatisNet.DataMapper\MappedStatements\MappedStatement.cs:line 517
		at IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObject(IDalSession session, Object parameterObject) in C:\projects\ibatis\asf\trunk\cs\mapper\IBatisNet.DataMapper\MappedStatements\MappedStatement.cs:line 498
		at IBatisNet.DataMapper.SqlMapper.QueryForObject(String statementName, Object parameterObject) in C:\projects\ibatis\asf\trunk\cs\mapper\IBatisNet.DataMapper\SqlMapper.cs:line 508
		at IBatisNet.DataMapper.Test.NUnit.SqlMapTests.DynamicPrependTest.TestDynamicSelectByBool() in C:\projects\ibatis\asf\trunk\cs\mapper\IBatisNet.DataMapper.Test\NUnit\SqlMapTests\DynamicPrependTest.cs:line 338
		-->
		<statement id="DynamicSelectByBool" 
			parameterClass="Other" 
			resultMap="other-result">
			select
				Other_Int,
				Other_Long,
				Other_Bit, 
				Other_String
			from Others  
			Where Other_Bit = #Bool,handler=OneZeroBool# 
		</statement>
		
		<!--
		Use typeHandler to get around error since Oracle column is an integer and 
		ODP does not have a proper typeHandler to convert bool to Oracle integer data type
		-->		
		<statement id="InsertBool" 
			parameterClass="Other">
			Insert into Others
				( Other_Int, Other_Long, Other_Bit, Other_String )
			values
			( #Int#, #Long#, #Bool,handler=OneZeroBool#, 'Yes')
		</statement>	
		
		<statement id="InsertCustomTypeHandler" 
			parameterMap="insert-params">
			Insert into Others
				( Other_Int, Other_Long, Other_Bit, Other_String  )
			values
			( ?, ?, ?, ?)
		</statement>
		
		<statement id="SelectByInt" 
			parameterClass="int" 
			resultMap="other-result">
			select
				Other_Int,
				Other_Long,
				Other_Bit, 
				Other_String
			from Others  
			Where Other_Int = #value#
		</statement>

		<statement id="InsertInlineCustomTypeHandlerV1" 
			parameterClass="Other">
			Insert into Others
				( Other_Int, Other_Long, Other_Bit, Other_String  )
			values
			( #Int#, #Long#, #Bool,handler=OneZeroBool#, #Bool2,type=bool,dbType=Varchar2#)
		</statement>
		
		<statement id="InsertInlineCustomTypeHandlerV2" 
			parameterClass="Other">
			Insert into Others
				( Other_Int, Other_Long, Other_Bit, Other_String  )
			values
			( #Int#, #Long#, #Bool,handler=OneZeroBool#, #Bool2,handler=OuiNonBool#)
		</statement>							
	</statements>
	
	<parameterMaps>   
		<parameterMap id="insert-params" class="Other">
			<parameter property="Int" />
			<parameter property="Long" />
			<parameter property="Bool" typeHandler="OneZeroBool"/>			
			<parameter property="Bool2" typeHandler="OuiNonBool"/>
		</parameterMap>
	</parameterMaps>
	
</sqlMap>
