Mybatis 中 columnPrefix別名的用法

1.映射對應的屬性,區分他們分別屬於哪些類。(sql書寫的時候爲何要將前綴加上(別名),是由於便於它去尋找哪一個類的前綴是ANNEX_)sql

2.例:  以下所示當一個collection 定義了一個columnPrefix時,其含義是將ANNEX_前綴自動添加到它下面的column中,爲其彌上須要的前綴,(ANNEX_IDANNEX_ANNEXANNEX_ANNEXNAMspa

___________________________________________________________________________________________________________get

<collection property="brandnoticeannexes" ofType="com.hyphone.brand.entity.BrandNoticeAnnex" columnPrefix="ANNEX_">
    <id property="id" column="ID"/> (ANNEX_ID)
    <result property="annex" column="ANNEX"/> (ANNEX_ANNEX)
    <result property="annexname" column="ANNEXNAME"/> (ANNEX_ANNEXNAME)
</collection>it

 

<select id="getLocalNoticeById" resultMap="brandnoticeannexes">
  SELECT
    NA.ID            ANNEX_ID,
    NA.ANNEX       ANNEX_ANNEX,
    NA.ANNEXNAME    ANNEX_ANNEXNAME
    FROM U_USER
</select >io

___________________________________________________________________________________________________________
相關文章
相關標籤/搜索