summaryrefslogtreecommitdiff
path: root/tests/unit/Data/SqlMap/maps/sqlite/Other.xml
blob: f8683f7e05cd51fd41908160374554b23f98a8a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?xml version="1.0" encoding="utf-8"?>
<sqlMap namespace="Other" >

	<resultMap id="other-result"  class="Other" >
		<result property="Int"		column="Other_Int"/>
		<result property="Long"		column="Other_Long"/>
		<result property="Bool"		column="Other_Bit"/>
		<result property="Bool2"	column="Other_String" typeHandler="OuiNonBool"/>
	</resultMap>

	<resultMap id="other-result-V1"  class="Other" >
		<result property="Int"		column="Other_Int"/>
		<result property="Long"		column="Other_Long"/>
		<result property="Bool"		column="Other_Bit"/>
		<result property="Bool2"	column="Other_String" />
	</resultMap>

	<resultMap id="A-result"  class="A" >
		<result property="Id"		column="A_ID"/>
		<result property="Libelle"	column="A_Libelle"/>
		<result property="B"		resultMapping="B-result"/>
		<result property="E"		resultMapping="E-result"/>
		<result property="F"		resultMapping="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="C-result"/>
		<result property="D"		resultMapping="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>

	<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#
			</isNotEqual>
		</dynamic>
	</statement>

	<statement id="DynamicSelectByBool"
		parameterClass="Other"
		resultMap="other-result">
		select
			Other_Int,
			Other_Long,
			Other_Bit,
			Other_String
		from Others
		Where Other_Bit = #Bool#
	</statement>

	<statement id="InsertBool"
		parameterClass="Other">
		Insert into Others
			( Other_Int, Other_Long, Other_Bit, Other_String )
		values
		( #Int#, #Long#, #Bool#, 'Yes')
	</statement>

	<statement id="InsertCustomTypeHandler"
		parameterMap="other-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="SelectByIntV1"
		parameterClass="int"
		resultMap="other-result-V1">
		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#, #Bool2,type=bool,dbType=Varchar#)
	</statement>

	<statement id="InsertInlineCustomTypeHandlerV2"
		parameterClass="Other">
		Insert into Others
			( Other_Int, Other_Long, Other_Bit, Other_String  )
		values
		( #Int#, #Long#, #Bool#, #Bool2,typeHandler=OuiNonBool#)
	</statement>

	<parameterMap id="other-insert-params">
		<parameter property="Int" />
		<parameter property="Long" />
		<parameter property="Bool" />
		<parameter property="Bool2" typeHandler="OuiNonBool"/>
	</parameterMap>
</sqlMap>