|
I'm using Spring, Ibatis, and postgreSql 8.0 one project call XxxDAO which manage all the DAO (no transaction) one project call XxxMgr which manage every transactions So when I lauch my junit test on XxxDAO, there is no transaction manager, only a SimpleDataSource from Ibatis. Here's the db config <beans> <bean id="myPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>arc/constante/jdbc.properties</value> </list> </property> </bean> <bean id="dataSourceArc" class="com.ibatis.common.jdbc.SimpleDataSource"> <constructor-arg> <map> <entry key="JDBC.Driver" value="${jdbc.driverClassName}"/> <entry key="JDBC.ConnectionURL" value="${jdbc.url}"/> <entry key="JDBC.Username" value="${jdbc.username}"/> <entry key="JDBC.Password" value="${jdbc.password}"/> <entry key="JDBC.DefaultAutoCommit" value="${jdbc.defaultAutoCommit}"/> <entry key="Pool.PingQuery" value="SELECT 1"/> <entry key="Pool.PingEnabled" value="true"/> <entry key="Pool.PingConnectionsOlderThan" value="1000000"/> </map> </constructor-arg> </bean> </beans> Then, I have a big file sql-init-config.xml which contains all my alias for ibatis for each table example : <typeAlias alias="plan" type="arc.db.model.Plan" /> <resultMap id="planResult" class="plan"> <result property="idPlan" column="plan_i_plan" /> <result property="idMandat" column="plan_i_mandat" /> <result property="infoAssedic" column="plan_t_info_assedic" /> <result property="avisControlleur" column="plan_t_avis_controlleur" /> <result property="avisRepresentantSalarie" column="plan_t_avis_representant_salarie" /> <result property="garantie" column="plan_t_garantie" /> <result property="remplacementDirigeant" column="plan_t_remplacement_dirigeant" /> <result property="actifSituation" column="plan_t_actif_situation" /> <result property="monCumulDeclaration" column="plan_m_cumul_declaration" /> <result property="idPlanOptionDef" column="plan_i_plan_option_def" /> <result property="idPlanOptionNon" column="plan_i_plan_option_non" /> <result property="isPrivi" column="plan_b_privi" /> <result property="isChiro" column="plan_b_chiro" /> <result property="isConteste" column="plan_b_conteste" /> <result property="isProvi" column="plan_b_provi" /> <result property="isAechoir" column="plan_b_aechoir" /> <result property="isValider" column="plan_b_valider" /> <result property="dateProchaineEcheance" column="plan_d_prochaine_echeance" /> <result property="isValidationEncours" column="plan_b_validation_encours" /> <result property="isEcheancier" column="plan_b_echeancier" /> <result property="isReprise" column="plan_b_reprise" /> </resultMap> <sql id="planColonne"> plan.i_plan AS plan_i_plan, plan.i_mandat AS plan_i_mandat, plan.t_info_assedic AS plan_t_info_assedic, plan.t_avis_controlleur AS plan_t_avis_controlleur, plan.t_avis_representant_salarie AS plan_t_avis_representant_salarie, plan.t_garantie AS plan_t_garantie, plan.t_remplacement_dirigeant AS plan_t_remplacement_dirigeant, plan.t_actif_situation AS plan_t_actif_situation, plan.m_cumul_declaration AS plan_m_cumul_declaration, plan.i_plan_option_def AS plan_i_plan_option_def, plan.i_plan_option_non AS plan_i_plan_option_non, plan.b_privi AS plan_b_privi, plan.b_chiro AS plan_b_chiro, plan.b_conteste AS plan_b_conteste, plan.b_provi AS plan_b_provi, plan.b_aechoir AS plan_b_aechoir, plan.b_valider AS plan_b_valider, plan.d_prochaine_echeance AS plan_d_prochaine_echeance, plan.b_validation_encours AS plan_b_validation_encours, plan.b_echeancier AS plan_b_echeancier, plan.b_reprise AS plan_b_reprise </sql> <sql id="getPlanSql"> SELECT <include refid="planColonne"/> FROM plan </sql> Then, one XxxSql.xml for each table which contains my failed query <select id="getPlanOptionFromIdPlan" resultMap="planOptionResult">
<include refid="getPlanOptionSql"/>
WHERE plan_option.i_plan = #id#
</select>
<select id="getEcheanceOptionFromIdPlan" resultMap="echeanceOptionResult">
<include refid="getEcheanceOptionSql"/>
WHERE echeance_option.i_plan = #id#
</select>
<select id="getEcheancePlanFromIdPlan" resultMap="echeancePlanResult">
<include refid="getEcheancePlanSql"/>
WHERE echeance_plan.i_plan = #id#
</select>
<resultMap id="planResult1N" class="plan" extends="planResult">
<result property="listEcheanceOption"
select="getEcheanceOptionFromIdPlan" column="plan_i_plan" />
<result property="listEcheancePlan"
select="getEcheancePlanFromIdPlan" column="plan_i_plan" />
<result property="listPlanOption" select="getPlanOptionFromIdPlan"
column="plan_i_plan" />
</resultMap>
<select id="getPlan1N" parameterClass="string" resultMap="planResult1N">
<include refid="getPlanSql"/>
$whereStr$
</select>
All xml files are in the sqlMapConfig, but i don't have any transaction manager... <sqlMapConfig> <sqlMap resource="arc/db/config/sql-init-config.xml"/> ... <sqlMap resource="arc/db/auto/dao/ibatis/config/PlanSQL.xml" /> ... </sqlMapConfig> Then, In my Spring application-context, I have <beans default-lazy-init="true"> <bean id="sqlMapClientArcDb" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation"> <value>classpath:arc/db/config/sql-map-config-arcdb.xml</value> </property> </bean> ... <bean id="planDAO" class="arc.db.auto.dao.ibatis.PlanDAOiBatis" lazy-init="true"> <property name="dataSource"><ref bean="dataSourceArc" /></property> <property name="sqlMapClient"><ref bean="sqlMapClientArcDb" /></property> <property name="sequenceDAO"><ref bean="sequenceDAO" /></property> </bean> ... My TestPlanDAOIbatis is a reproductible test case with my own data... I can give you everything if you want to reproduce it ! thanks, Tom Jeff Butler a écrit :
|
- Re: Problem with multi-select inside a resultMap since Ibatis... TNO
