在oracle裡寫各種語句得心應手,但是在mybatis.xml檔案裡呢?

來源:互聯網
上載者:User

標籤:

這個問題我讓我搞了大半天,實在氣人,話不多說,直接上代碼

<select id="*" resultMap="Blog" parameterType="Integer">
  select * (select count(*) from table_name c where c.bbs_id=t.id) as plcount,      //子查詢     plcount為虛擬欄位    排序 
   from table_name t <![CDATA[ where rownum <=10 ]]> order by t.pvcount desc    //mybatis識別不出來<或>,用<![CDATA[ where rownum <=10 ]]>可以
</select>

插入語句的編寫

<insert id="*" parameterType="Blog">
<selectKey order="BEFORE" resultType="java.lang.Long" keyProperty="id">
  select ZDCJ_BLOG_SEQ.Nextval from dual         //序列,在後台執行添加的時候,建構函式沒有序列ID
</selectKey>
  insert into table_name (ID,BBS_TITLE,BBS_CENTER,BBS_DATE,AUTHOR,AC,BANKUAI,PVCOUNT,CREATE_DATE,CREATE_USER,POPULARITY) values(#{id,jdbcType=NUMERIC},#          {bbsTitle,jdbcType=VARCHAR},#{bbsCenter,jdbcType=VARCHAR},#{bbsDate,jdbcType=VARCHAR},#{author,jdbcType=VARCHAR},#{ac,jdbcType=VARCHAR},#                   {bankuai,jdbcType=VARCHAR},#{pvcount,jdbcType=VARCHAR},#{createDate,jdbcType=VARCHAR},#{createUserid,jdbcType=NUMERIC},#{popularity,jdbcType=VARCHAR})
</insert>

//這是我自己想出來的表串連查詢,效果可以實現,可能不太專業,請諒解

<select id="*" resultType="Blog" parameterType="Integer">
  select * from table_name1 u,table_name2 t where u.BLOG_ID = t.ID AND t.CREATE_USER=#{createUserid}
</select>

在oracle裡寫各種語句得心應手,但是在mybatis.xml檔案裡呢?

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.