summaryrefslogtreecommitdiff
path: root/tests/unit/Data/SqlMap/maps/mssql/Order.xml
blob: 87a2d1a044af9dc0ce4b836bb24a70a512633042 (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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
<?xml version="1.0" encoding="UTF-8" ?>

<sqlMap namespace="Order" >


	<resultMap id="credit-card-result" class="string">
		<result property="value" column="Order_CardNumber"/>
	</resultMap>

	<resultMap id="order-with-lines-result" class="Order" 
							extends="lite-order-result-by-name" >
		<result property="LineItemsList" lazyLoad="true" column="Order_ID" select="GetLineItemsForOrder" />
	</resultMap>
	
	<resultMap id="order-with-lines-result-statement-namespaces" class="Order" 
							extends="lite-order-result-by-name" >
		<result property="LineItemsList" lazyLoad="true" column="Order_ID" select="LineItem.GetLineItemsForOrder" />
	</resultMap>		
	
	<resultMap id="order-with-lines-collection" class="Order"
							extends="lite-order-result-by-name" >
		<result property="LineItems" column="Order_ID"  select="GetLineItemsForOrderWithListClass" />
	</resultMap>
	
	<resultMap id="order-with-lines-array" class="Order"
							extends="lite-order-result-by-name">
		<result property="LineItemsArray" column="Order_ID" select="GetLineItemsForOrder"/>
	</resultMap>

	<resultMap id="lite-order-map-result" class="array">
		<result property="Id"         type="Int" column="Order_ID"/>
		<result property="Date"       type="date" column="Order_Date"/>
		<result property="CardExpiry" type="string" column="Order_CardExpiry"/>
		<result property="CardType"   type="string" column="Order_CardType"/>
		<result property="CardNumber" type="string" column="Order_CardNumber"/>
		<result property="Street"     type="string" column="Order_Street"/>
		<result property="City"       type="string" column="Order_City"/>
		<result property="Province"   type="string" column="Order_Province"/>
		<result property="PostalCode" type="string" column="Order_PostalCode"/>
	</resultMap>

	<resultMap id="lite-order-result-by-name" class="Order">
		<result property="Id"         column="Order_ID"/>
		<result property="Date"       type="date" column="Order_Date" nullValue="0001-01-01 00:00:00"/>
		<result property="CardExpiry" column="Order_CardExpiry"/>
		<result property="CardType"   column="Order_CardType"/>
		<result property="CardNumber" column="Order_CardNumber"/>
		<result property="Street"     column="Order_Street"/>
		<result property="City"       column="Order_City"/>
		<result property="Province"   column="Order_Province"/>
		<result property="PostalCode" column="Order_PostalCode"/>
	</resultMap>
	
	<resultMap id="order-with-types-result" class="Order">
		<result property="Id"         column="Order_ID"			dbType="Int"/><!-- Int for SqlClient, Obdc; Integer for Oledb -->
		<result property="Date"       type="date" column="Order_Date"		dbType="DateTime "/>
		<result property="CardExpiry" column="Order_CardExpiry" dbType="VarChar"/>
		<result property="CardType"   column="Order_CardType"	dbType="VarChar"/>
		<result property="CardNumber" column="Order_CardNumber" dbType="VarChar"/>
		<result property="Street"     column="Order_Street"		dbType="VarChar"/>
		<result property="City"       column="Order_City"		dbType="VarChar"/>
		<result property="Province"   column="Order_Province"	dbType="VarChar"/>
		<result property="PostalCode" column="Order_PostalCode" dbType="VarChar"/>
	</resultMap>
	
	<resultMap id="lite-order-result-by-index" class="Order">
		<result property="Id"         column="Order_ID"			columnIndex="0"/>
		<result property="Date"       type="date" column="Order_Date"		columnIndex="1" />
		<result property="CardExpiry" column="Order_CardExpiry" columnIndex="2"/>
		<result property="CardType"   column="Order_CardType"	columnIndex="3" />
		<result property="CardNumber" column="Order_CardNumber" columnIndex="4" />
		<result property="Street"     column="Order_Street"		columnIndex="5" />
		<result property="City"       column="Order_City"		columnIndex="6" />
		<result property="Province"   column="Order_Province"	columnIndex="7"/>
		<result property="PostalCode" column="Order_PostalCode" columnIndex="8" />
	</resultMap>
	
	<resultMap id="order-with-account-result" class="Order">
		<result property="Id"         column="Order_ID"/>
		<result property="Date"       type="date"  column="Order_Date"/>
		<result property="CardExpiry" column="Order_CardExpiry"/>
		<result property="CardType"   column="Order_CardType"/>
		<result property="CardNumber" column="Order_CardNumber"/>
		<result property="Street"     column="Order_Street"/>
		<result property="City"       column="Order_City"/>
		<result property="Province"   column="Order_Province"/>
		<result property="PostalCode" column="Order_PostalCode"/>
		<result property="Account"    column="Account_ID" select="GetAccountViaColumnName" />
	</resultMap>

	<resultMap id="order-with-sp-account-result" class="Order">
		<result property="Id"         column="Order_ID"/>
		<result property="Date"       type="date" column="Order_Date"/>
		<result property="CardExpiry" column="Order_CardExpiry"/>
		<result property="CardType"   column="Order_CardType"/>
		<result property="CardNumber" column="Order_CardNumber"/>
		<result property="Street"     column="Order_Street"/>
		<result property="City"       column="Order_City"/>
		<result property="Province"   column="Order_Province"/>
		<result property="PostalCode" column="Order_PostalCode"/>
		<result property="Account"    column="Account_ID=Account_ID" select="GetAccountViaSP" />
	</resultMap>
			
	<resultMap id="order-with-collection-result" class="Order">
		<result property="Id"				column="Order_ID"/>
		<result property="Date"				type="date" column="Order_Date"/>
		<result property="CardExpiry"		column="Order_CardExpiry"/>
		<result property="CardType"			column="Order_CardType"/>
		<result property="CardNumber"		column="Order_CardNumber"/>
		<result property="Street"			column="Order_Street"/>
		<result property="City"				column="Order_City"/>
		<result property="Province"			column="Order_Province"/>
		<result property="PostalCode"		column="Order_PostalCode"/>
		<result property="LineItemsList"	column="Order_ID" select="GetLineItemsForOrder" />	
		<result property="LineItems"		column="Order_ID" select="GetLineItemsForOrder" lazyLoad="false" />
	</resultMap>
	
	<resultMap id="order-with-favourite-line-item" class="Order">
		<result property="Id"					column="Order_ID"/>
		<result property="Date"					type="date"  column="Order_Date"/>
		<result property="CardExpiry"			column="Order_CardExpiry"/>
		<result property="CardType"				column="Order_CardType"/>
		<result property="CardNumber"			column="Order_CardNumber"/>
		<result property="Street"				column="Order_Street"/>
		<result property="City"					column="Order_City"/>
		<result property="Province"				column="Order_Province"/>
		<result property="PostalCode"			column="Order_PostalCode"/>
		<result property="FavouriteLineItem"	column="Order_ID=Order_ID,LineItem_ID=Order_FavouriteLineItem" select="GetSpecificLineItem" />
	</resultMap>
	
	<resultMap id="order-with-dyn-favourite-line-item" class="Order">
		<result property="Id"					column="Order_ID"/>
		<result property="Date"					type="date" column="Order_Date"/>
		<result property="CardExpiry"			column="Order_CardExpiry"/>
		<result property="CardType"				column="Order_CardType"/>
		<result property="CardNumber"			column="Order_CardNumber"/>
		<result property="Street"				column="Order_Street"/>
		<result property="City"					column="Order_City"/>
		<result property="Province"				column="Order_Province"/>
		<result property="PostalCode"			column="Order_PostalCode"/>
		<result property="FavouriteLineItem"	
					column="Order_ID=Order_ID,LineItem_ID=Order_FavouriteLineItem" 
					select="GetDynSpecificLineItem" />
	</resultMap>
	<resultMap id="order-joined-favourite" class="Order">
		<result property="Id"					column="Order_ID"/>
		<result property="Date"					type="date" column="Order_Date"/>
		<result property="CardExpiry"			column="Order_CardExpiry"/>
		<result property="CardType"				column="Order_CardType"/>
		<result property="CardNumber"			column="Order_CardNumber"/>
		<result property="Street"				column="Order_Street"/>
		<result property="City"					column="Order_City"/>
		<result property="Province"				column="Order_Province"/>
		<result property="PostalCode"			column="Order_PostalCode"/>
		<result property="FavouriteLineItem"	resultMapping="LineItem" />
	</resultMap>
	
	<resultMap id="order-joined-favourite2" class="Order">
		<result property="Id"					column="Order_ID"/>
		<result property="Date"					type="date" column="Order_Date"/>
		<result property="CardExpiry"			column="Order_CardExpiry"/>
		<result property="CardType"				column="Order_CardType"/>
		<result property="CardNumber"			column="Order_CardNumber"/>
		<result property="Street"				column="Order_Street"/>
		<result property="City"					column="Order_City"/>
		<result property="Province"				column="Order_Province"/>
		<result property="PostalCode"			column="Order_PostalCode"/>
		<result property="FavouriteLineItem.Id" column="LineItem_ID"/>
		<result property="FavouriteLineItem.Code" column="LineItem_Code"/>
		<result property="FavouriteLineItem.Quantity" column="LineItem_Quantity"/>
		<result property="FavouriteLineItem.Price" column="LineItem_Price"/>			
	</resultMap>

	<resultMap id="order-joined-with-account" class="Order">
		<result property="Id"         column="Order_ID"/>
		<result property="Date"       type="date" column="Order_Date" nullValue="0001-01-01 00:00:00"/>
		<result property="CardExpiry" column="Order_CardExpiry"/>
		<result property="CardType"   column="Order_CardType"/>
		<result property="CardNumber" column="Order_CardNumber"/>
		<result property="Street"     column="Order_Street"/>
		<result property="City"       column="Order_City"/>
		<result property="Province"   column="Order_Province"/>
		<result property="PostalCode" column="Order_PostalCode"/>
		<result property="Account"	resultMapping="account-result-nullable-email" />
	</resultMap>	
	
	<resultMap id="order-hash" class="array">
		<result property="Date"       column="Order_Date" nullValue="0001-01-01 00:00:00"/>
	</resultMap>	

	<statement id="GetOrderByHashTable"
				parameterClass="Int"
				resultMap="order-hash" >
		select Order_Date from Orders where Order_ID = #value#
	</statement>
		
	<statement id="GetOrderLiteByColumnName"
				parameterClass="Int"
				resultMap="lite-order-result-by-name" >
		select * from Orders where Order_ID = #value#
	</statement>
	
	<statement id="GetOrderLiteByColumnIndex"
				parameterClass="Int"
				resultMap="lite-order-result-by-index" >
		select
		Order_ID,
		Order_Date,
		Order_CardExpiry,
		Order_CardType,
		Order_CardNumber,
		Order_Street,
		Order_City,
		Order_Province,
		Order_PostalCode
		from Orders where Order_ID = #value#
	</statement>
	
	<statement id="GetOrderWithTypes"
				parameterClass="Int"
				resultMap="order-with-types-result" >
		select * from Orders where Order_ID = #value#
	</statement>
	
	<statement id="GetOrderWithLineItems"
				parameterClass="Integer"
				resultMap="order-with-lines-result" >
		select * from Orders where Order_ID = #value#
	</statement>
	
	<statement id="GetOrderWithLineItemsUsingStatementNamespaces"
				parameterClass="Integer"
				resultMap="order-with-lines-result-statement-namespaces" >
		select * from Orders where Order_ID = #value#
	</statement>		

	<statement id="GetAllOrderWithLineItems"
				parameterClass="Integer"
				resultMap="order-with-lines-result" >
		select * from Orders
	</statement>
	
	<statement id="GetOrderCardExpiryViaResultClass"
				parameterClass="int"
				resultClass="date">
		select
		Order_Date as datetime
		from Orders where Order_ID = #value#
	</statement>
	
	<statement id="GetOrderWithAccount"
				parameterClass="int"
				resultMap="order-with-account-result" >
		select * from Orders where Order_ID = #value#
	</statement>
	
	<statement id="GetOrderWithAccountViaSP"
				parameterClass="int"
				resultMap="order-with-sp-account-result" >
		select * from Orders where Order_ID = #value#
	</statement>
	
	<statement id="GetOrderWithLineItemsCollection"
				parameterClass="Integer"
				resultMap="order-with-collection-result" >
		select * from Orders where Order_ID = #value#
	</statement>
	
	 <statement id="GetOrderJoinedFavourite"
				parameterClass="Integer"
				resultMap="order-joined-favourite" >
		select * from Orders, LineItems
		where Orders.Order_ID = LineItems.Order_ID
		and Order_FavouriteLineItem = LineItems.LineItem_ID
		and Orders.Order_ID = #value#
	</statement>
	
	<statement id="GetOrderJoinedFavourite2"
				parameterClass="Integer"
				resultMap="order-joined-favourite2" >
		select * from Orders, LineItems
		where Orders.Order_ID = LineItems.Order_ID
		and Order_FavouriteLineItem = LineItems.LineItem_ID
		and Orders.Order_ID = #value#
	</statement>

	<statement id="GetOrderJoinedFavourite3"
				parameterClass="Integer"
				resultClass="Order" >
		select 
			Orders.Order_ID as Id,
			Order_Date as Date,
			Order_CardExpiry as CardExpiry,
			Order_CardType as CardType,
			Order_CardNumber as CardNumber,
			Order_Street as Street,
			Order_City as City,
			Order_Province as Province,
			Order_PostalCode as PostalCode,
			LineItem_ID as "FavouriteLineItem.Id",
			LineItem_Code as "FavouriteLineItem.Code",
			LineItem_Quantity as "FavouriteLineItem.Quantity",
			LineItem_Price as "FavouriteLineItem.Price"
		from Orders, LineItems
		where Orders.Order_ID = LineItems.Order_ID
		and Order_FavouriteLineItem = LineItems.LineItem_ID
		and Orders.Order_ID = #value#
	</statement>
	
	<statement id="GetOrderWithFavouriteLineItem"
				parameterClass="int"
				resultMap="order-with-favourite-line-item" >
		select * from Orders where Order_ID = #value#
	</statement>
	
	<statement id="GetOrderWithLineItemCollection"
				parameterClass="int"
				resultMap="order-with-lines-collection" >
		select * from Orders where Order_ID = #value#
	</statement>
	
	<statement id="GetOrderAsHastable"
				parameterClass="Integer"
				resultMap="lite-order-map-result" >
		select * from Orders where Order_ID = #value#
	</statement>
	
	<statement id="GetOrderWithLineItemArray"
			parameterClass="int"
			resultMap="order-with-lines-array">
			select * from Orders where Order_ID = #value#
	</statement>
	
	<statement id="GetAllCreditCardNumbersFromOrders"
			resultMap="credit-card-result" >
		select distinct Order_CardNumber from Orders
		order by Order_CardNumber
	</statement>
	
	<statement id="InsertOrderViaParameterMap"
				parameterMap="order-insert-params" >
		insert into Orders  
			(Order_ID, Account_ID, Order_Date, Order_CardExpiry, Order_CardType, 
				Order_CardNumber, Order_Street, Order_City, Order_Province, Order_PostalCode ) 
		values 
			(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
	</statement>		
	
	<statement id="InsertOrderViaExtendParameterMap"
				parameterMap="insert-extend" >
		insert into Orders  
			(Order_ID, Account_ID, Order_Date, Order_CardExpiry, Order_CardType, 
				Order_CardNumber, Order_Street, Order_City, Order_Province, Order_PostalCode ) 
		values 
			(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
	</statement>
	
	<statement id="InsertOrderViaPublicFields">
		insert into Orders  
			(Order_ID, Account_ID, Order_Date, Order_CardExpiry, Order_CardType, 
				Order_CardNumber, Order_Street, Order_City, Order_Province, Order_PostalCode ) 
		values 
			(#Id#, #Account.Id#, #Date#, #CardExpiry#, #CardType#, #CardNumber#, #Street#, #City#, #Province#, #PostalCode#)
	</statement>		
			
	<select id="GetOrderWithDynFavouriteLineItem"
			parameterClass="Integer"
			resultMap="order-with-dyn-favourite-line-item">
		select * from Orders where Order_ID = #value#
	</select>			
	
	<select id="SelectOrderByDate"
			parameterClass="array"
			resultMap="lite-order-result-by-name">
		select * from Orders where Order_Date = #Foo#
	</select>	
	
	<select id="SelectOrderByDateDynamic"
			parameterClass="array"
			resultMap="lite-order-result-by-name">
		select * from Orders
		where 1=1
		<isNotEmpty prepend="AND" property="Foo"> 
			(Order_Date = '$Foo$') 
		</isNotEmpty> 
	</select>
			
	<select id="GetAccountJIRA45"
			parameterClass="int"
			resultMap="indexed-account-result">
		select
		Account_ID,
		Account_FirstName,
		Account_LastName,
		Account_Email
		from Accounts
		where Account_ID = #value#
	</select>

	<select id="GetOrderJoinWithAccount"
			parameterClass="Integer"
			resultMap="order-joined-with-account">
		select 
			Order_ID, 
			Order_Date, 
			Order_CardExpiry, 
			Order_CardType,
			Order_CardNumber, 
			Order_Street, 
			Order_City, 
			Order_Province, 
			Order_PostalCode,
			acc.Account_ID,
			acc.Account_FirstName,
			acc.Account_LastName,
			acc.Account_Email 
		from Orders as ord
		LEFT OUTER JOIN Accounts as acc on acc.Account_ID = ord.Account_ID
		where Order_ID = #value#
	</select>	
			
	
	<parameterMap id="order-insert-params">
		<parameter property="Id" dbType="Int"/>	<!-- Int for SqlClient, Obdc; Integer for Oledb -->
		<parameter property="Account.Id" type="integer"/>
		<parameter property="Date" type="date" nullValue="0001-01-01 00:00:00" />
		<parameter property="CardExpiry" />
		<parameter property="CardType" />			
		<parameter property="CardNumber" />
		<parameter property="Street" />
		<parameter property="City" />			
		<parameter property="Province" />
		<parameter property="PostalCode" />
	</parameterMap>

	<parameterMap id="params-parent"> <!-- 1043181 support request -->
		<parameter property="Id" dbType="Int"/>	
		<parameter property="Account.Id"/>
		<parameter property="Date" type="date" nullValue="0001-01-01 00:00:00" />
		<parameter property="CardExpiry" />
		<parameter property="CardType" />			
		<parameter property="CardNumber" />
		<parameter property="Street" />
		<parameter property="City" />			
		<parameter property="Province" />
		<parameter property="PostalCode" />		
	</parameterMap>
	
	<parameterMap id="insert-extend" extends="params-parent">
	</parameterMap>
			
	<statement id="GetOrderWithLineItemsNoLazyLoad"
				parameterClass="Integer"
				resultMap="order-with-lines-result-no-lazy-load" >
		select * from Orders where Order_ID = #value#
	</statement>

	<resultMap id="order-with-lines-result-no-lazy-load" class="Order" 
							extends="lite-order-result-by-name" >
		<result property="LineItemsList" type="TList" column="Order_ID" select="GetLineItemsForOrder" />
	</resultMap>

		<statement id="GetOrderWithLineItemCollectionNoLazy"
				parameterClass="int"
				resultMap="order-with-lines-collection-no-lazy-load" >
		select * from Orders where Order_ID = #value#
	</statement>

	<resultMap id="order-with-lines-collection-no-lazy-load" class="Order"
							extends="lite-order-result-by-name" >
		<result property="LineItems" column="Order_ID" 
			select="GetLineItemsForOrderWithListClass" />
	</resultMap>

</sqlMap>