85
85
The select statement is one of the most popular elements that you'll use in MyBatis.
86
86
Putting data in a database isn't terribly valuable until you get it back out, so most
87
87
applications query far more than they modify the data. For every insert, update or delete,
88
- there is probably many selects. This is one of the founding principles of MyBatis, and is the
88
+ there are probably many selects. This is one of the founding principles of MyBatis, and is the
89
89
reason so much focus and effort was placed on querying and result mapping. The select element is
90
90
quite simple for simple cases. For example:
91
91
</p >
@@ -541,7 +541,7 @@ ps.setInt(1,id);]]></source>
541
541
<p >
542
542
In all of the past statements, you've seen examples of simple parameters. Parameters are very
543
543
powerful elements in MyBatis. For simple situations, probably 90% of the cases, there's not much
544
- too them, for example:
544
+ to them, for example:
545
545
</p >
546
546
547
547
<source ><![CDATA[ <select id="selectUsers" resultType="User">
@@ -552,7 +552,7 @@ ps.setInt(1,id);]]></source>
552
552
553
553
<p >
554
554
The example above demonstrates a very simple named parameter mapping. The parameterType is set to
555
- <code >int</code >, so therefore the parameter could be named anything. Primitive or simply data types such as
555
+ <code >int</code >, so therefore the parameter could be named anything. Primitive or simple data types such as
556
556
<code >Integer</code > and <code >String</code > have no relevant properties, and thus will replace the full value of the
557
557
parameter entirely. However, if you pass in a complex object, then the behavior is a little
558
558
different. For example:
@@ -643,8 +643,8 @@ ps.setInt(1,id);]]></source>
643
643
<p >
644
644
By default, using the <code >#{}</code > syntax will cause MyBatis to generate <code >PreparedStatement</code > properties and
645
645
set the values safely against the <code >PreparedStatement</code > parameters (e.g. ?). While this is safer,
646
- faster and almost always preferred, sometimes you just want to directly inject a string
647
- unmodified into the SQL Statement. For example, for ORDER BY, you might use something like this:
646
+ faster and almost always preferred, sometimes you just want to directly inject an unmodified string
647
+ into the SQL Statement. For example, for ORDER BY, you might use something like this:
648
648
</p >
649
649
650
650
<source ><![CDATA[ ORDER BY ${columnName}]]> </source >
@@ -731,7 +731,7 @@ public class User {
731
731
</select>]]> </source >
732
732
733
733
<p >
734
- And remember that TypeAliases are your friend . Use them so that you don't have to keep typing the
734
+ And remember that TypeAliases are your friends . Use them so that you don't have to keep typing the
735
735
fully qualified path of your class out. For example:
736
736
</p >
737
737
@@ -787,7 +787,7 @@ public class User {
787
787
</select>]]> </source >
788
788
789
789
<p >
790
- Now if only the world were always that simple.
790
+ Now if only the world was always that simple.
791
791
</p >
792
792
793
793
<h4 >Advanced Result Maps</h4 >
@@ -965,7 +965,7 @@ public class User {
965
965
<result property="subject" column="post_subject"/>]]> </source >
966
966
967
967
<p >
968
- These are the most basic of result mappings. Both <i >id</i >, and
968
+ These are the most basic of result mappings. Both <i >id</i > and
969
969
<i >result</i > map a single column value to a
970
970
single property or field of a simple data type (String, int, double, Date, etc.).
971
971
</p >
0 commit comments