mybatisいくつかの使用履歴
1604 ワード
璣MyBatisを使って記録29858;べンの中に集合する 1.まずjava列でList<Answer>answerを定義する。 2.sqlmapファイルのresultMapタグの下にcollectionタグを設定し、property対応クラスの属性、javaType対応クラスの集合類、offype集合類のパラメータ変数を設定し、中を一般のResultmapで書けばいいです。
<collection property="answers" javaType="java.util.List" ofType="xx.Answer">
<id property="id" column="answer_id"/>
<result property="questionId" column="question_id" />
<result property="answerNo" column="answer_no" />
</collection>
3.赤い元素を集めて自分のsqlmapを設定し、それらの間はどのように関連していますか?TODO〓〓〓〓〓〓〓検索条件がListに入ってきました。リストの変数名はidです。 1. parameterTypeはリストと定義されています。 2. foreach <update id="recover" parameterType="list">
update table
where id in
<foreach collection="list" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</update>
##Oracleデータベース挿入ID設定<insert id="add" parameterType="xxx.pojo.xxBean">
<selectKey keyProperty="id" resultType="java.lang.Integer" order="BEFORE">
select seq_item.nextval as id from dual
</selectKey>
insert into table
(id)
values
(#{id})
</insert>