关于iBatis分模块的配置,以及一点其他的疑问,基于JPetStore讨论

简单起见,拿JPetStore5.0来举例吧.

在配置文件sql-map-config.xml中,他是这么写的
<sqlMap resource="com/ibatis/jpetstore/persistence/sqlmapdao/sql/Account.xml"/>
  <sqlMap resource="com/ibatis/jpetstore/persistence/sqlmapdao/sql/Category.xml"/>
  <sqlMap resource="com/ibatis/jpetstore/persistence/sqlmapdao/sql/Product.xml"/>
  <sqlMap resource="com/ibatis/jpetstore/persistence/sqlmapdao/sql/Sequence.xml"/>
  <sqlMap resource="com/ibatis/jpetstore/persistence/sqlmapdao/sql/LineItem.xml"/>
  <sqlMap resource="com/ibatis/jpetstore/persistence/sqlmapdao/sql/Order.xml"/>
  <sqlMap resource="com/ibatis/jpetstore/persistence/sqlmapdao/sql/Item.xml"/>


其他是transactionManager的配置就不管了.

这里的Account.xml是不是就是分模块的配置文件?我猜想应该是的吧

再问问Account.xml里面的一些东西
<select id="getAccountByUsername" resultClass="account" parameterClass="string">
    SELECT
          SIGNON.USERNAME,
          ACCOUNT.EMAIL,
          ACCOUNT.FIRSTNAME,
          ACCOUNT.LASTNAME,
          ACCOUNT.STATUS,
          ACCOUNT.ADDR1 AS address1,
          ACCOUNT.ADDR2 AS address2,
          ACCOUNT.CITY,
          ACCOUNT.STATE,
          ACCOUNT.ZIP,
          ACCOUNT.COUNTRY,
          ACCOUNT.PHONE,
          PROFILE.LANGPREF AS languagePreference,
          PROFILE.FAVCATEGORY AS favouriteCategoryId,
          PROFILE.MYLISTOPT AS listOption,
          PROFILE.BANNEROPT AS bannerOption,
          BANNERDATA.BANNERNAME
    FROM ACCOUNT, PROFILE, SIGNON, BANNERDATA
    WHERE ACCOUNT.USERID = #username#
      AND SIGNON.USERNAME = ACCOUNT.USERID
      AND PROFILE.USERID = ACCOUNT.USERID
      AND PROFILE.FAVCATEGORY = BANNERDATA.FAVCATEGORY
  </select>


我知道iBatis并没有hibernate那样,显示的对应column和field的对应关系.
就拿上面的select语句来说, iBatis怎么知道, SIGNON.USERNAME 这个东西对应哪个字段呢?

你可能感兴趣的:(DAO,spring,框架,ibatis,配置管理)