summaryrefslogtreecommitdiff
path: root/tests/unit/Data/SqlMap/maps/sqlite/LineItem.xml
blob: 95cc4af76e8ec2c14ec055517b385682f691186f (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
<?xml version="1.0" encoding="UTF-8" ?>

<sqlMap namespace="LineItem" >
	
		<resultMap id="LineItem-Price" class="float">
			<result property="value"		column="LineItem_Price"/>
		</resultMap>
		
		<resultMap id="LineItem" class="LineItem">
			<result property="Id"			column="LineItem_Id"/>
			<result property="Code"			column="LineItem_Code"/>
			<result property="Quantity"		column="LineItem_Quantity"/>
			<result property="Price"		column="LineItem_Price"/>
		</resultMap>
		
		<resultMap id="LineItemWithNullReplacement" class="LineItem">
			<result property="Id"			column="LineItem_Id"/>
			<result property="Code"			column="LineItem_Code"/>
			<result property="Quantity"		column="LineItem_Quantity"/>
			<result property="Price"		column="LineItem_Price" nullValue="-77.77"/>
		</resultMap>
		
	
		<statement id="GetLineItemPrice"
					parameterClass="array"
					resultMap="LineItem-Price" >
			select
				LineItem_Price
				from LineItems
				where Order_ID = #Order_ID#
				and LineItem_ID = #LineItem_ID#
		</statement>
		
		<statement id="GetLineItemsForOrder"
			parameterClass="int"
			listClass="TList"
			resultClass="LineItem">
			select
				LineItem_ID as Id,
				LineItem_Code as Code,
				LineItem_Quantity as Quantity,
				LineItem_Price as Price
			from LineItems where Order_ID = #value#
		</statement>
		

		<statement id="GetLineItemsForOrderWithListClass"
			parameterClass="int"
			listClass="LineItemCollection"
			resultClass="LineItem">
			select
				LineItem_ID as Id,
				LineItem_Code as Code,
				LineItem_Quantity as Quantity,
				LineItem_Price as Price
			from LineItems where Order_ID = #value#
			order by LineItem_Code
		</statement>

		<statement id="GetSpecificLineItem"
					parameterClass="array"
					resultClass="LineItem">
			select
				LineItem_ID as Id,
				LineItem_Code as Code,
				LineItem_Quantity as Quantity,
				LineItem_Price as Price
				from LineItems
			where Order_ID = #Order_ID#
				and LineItem_ID = #LineItem_ID#
		</statement>
		
		<statement id="GetSpecificLineItemWithPicture"
					parameterClass="array"
					resultClass="LineItem">
			select
				LineItem_ID as Id,
				LineItem_Code as Code,
				LineItem_Quantity as Quantity,
				LineItem_Price as Price,
				LineItem_Picture as PictureData				
				from LineItems
			where Order_ID = #Order_ID#
				and LineItem_ID = #LineItem_ID#
		</statement>
		
		<select id="GetDynSpecificLineItem"
			parameterClass="array"
			resultClass="LineItem">
			select
				LineItem_ID as Id,
				LineItem_Code as Code,
				LineItem_Quantity as Quantity,
				LineItem_Price as Price
				from LineItems
			where Order_ID = #Order_ID#
			<dynamic>
				<isNotNull property="LineItem_ID">
					and LineItem_ID = #LineItem_ID#
				</isNotNull>
			</dynamic>
		</select>
		
		<statement id="GetSpecificLineItemWithNullReplacement"
					parameterClass="int"
					resultMap="LineItemWithNullReplacement">
			select
				LineItem_ID,
				LineItem_Code,
				LineItem_Quantity,
				LineItem_Price
				from LineItems
				where LineItem_ID =  #value#
		</statement>
		
		<statement id="InsertLineItem" 
					parameterMap="line-item-insert-params" >
			insert into LineItems
			(LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
			values
			(?, ?, ?, ?, ?);
		</statement>
		
		<statement id="InsertLineItemWithPicture" 
					parameterMap="line-item-insert-params-picture" >
			insert into LineItems
			(LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price, LineItem_Picture)
			values
			(?, ?, ?, ?, ?, ?);
		</statement>
		
		<insert id="InsertLineItemPostKey" parameterClass="LineItem">
			insert into LineItems
			(LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
			values
			(#Id#, #Order.Id#, #Code#, #Quantity#, #Price, type=float#)
			<selectKey property="Id" type="post" resultClass="int" >
				select 99 from LineItems where LineItem_ID = 1 and Order_ID=1
			</selectKey>
		</insert>	
		
		 <insert id="InsertLineItemPreKey" parameterClass="LineItem">
			<selectKey property="Id" type="pre" resultClass="int" >
				select 99 from LineItems where LineItem_ID = 1 and Order_ID=1
			</selectKey>
			insert into LineItems
			(LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
			values
			(#Id#, #Order.Id#, #Code#, #Quantity#, #Price, type=float#)
		</insert>
  
		<insert id="InsertLineItemNoKey" parameterClass="LineItem">
			insert into LineItems
			(LineItem_ID, Order_ID, LineItem_Code, LineItem_Quantity, LineItem_Price)
			values
			(#Id#, #Order.Id#, #Code#, #Quantity#, #Price, type=float#)
		</insert>
		
  		<!-- JIRA 23 -->
		<delete id="DeleteWithComments" >
			<!-- Delete LineItems -->
			delete from LineItems where Order_ID = 10;
			<!-- Delete LineItems -->
		</delete>		
		
		<parameterMap id="line-item-insert-params">
			<parameter property="Id" />
			<parameter property="Order.Id" />
			<parameter property="Code" />			
			<parameter property="Quantity" />
			<parameter property="Price" dbType="Decimal" nullValue="-99.99"/>
		</parameterMap>
				
		<parameterMap id="line-item-insert-params-picture">
			<parameter property="Id" />
			<parameter property="Order.Id" />
			<parameter property="Code" />			
			<parameter property="Quantity" />
			<parameter property="Price" dbType="Decimal" nullValue="-99.99"/>
			<parameter property="PictureData" dbType="Blob" />
		</parameterMap>
		
</sqlMap>