Skip to content

Commit

Permalink
Merge pull request #10079 from haynescd/bugfix/ch/Fix-incompatible-wi…
Browse files Browse the repository at this point in the history
…th-sqlmodeOnlyFullGroupBy

Update SQL to fix incompatibility with sqlmode OnlyFullGroupBy
  • Loading branch information
haynescd committed Mar 15, 2023
2 parents 6c0275b + c1a38a8 commit f375e62
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
12 changes: 11 additions & 1 deletion core/src/test/resources/applicationContext-dao.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,16 @@
<property name="maxTotal" value="100" />
<property name="poolPreparedStatements" value="true" />
</bean>


<bean id="databaseIdProvider" class="org.apache.ibatis.mapping.VendorDatabaseIdProvider">
<property name="properties">
<props>
<prop key="MySQL">mysql</prop>
<prop key="H2">h2</prop>
</props>
</property>
</bean>

<!-- define the SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="businessDataSource" />
Expand All @@ -76,6 +85,7 @@
<!-- mapper locations is set here to support interdependency between mappers without -->
<!-- having to autowire repositories into java classes that do not make direct uses of them -->
<property name="mapperLocations" value="classpath*:org/cbioportal/persistence/mybatis/**/*.xml"/>
<property name="databaseIdProvider" ref="databaseIdProvider"/>
</bean>

<!-- scan for mappers and let them be autowired -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@
</bean>

<bean id="customObjectFactory" class="org.cbioportal.persistence.mybatis.util.CustomMyBatisObjectFactory" />


<bean id="databaseIdProvider" class="org.apache.ibatis.mapping.VendorDatabaseIdProvider">
<property name="properties">
<props>
<prop key="MySQL">mysql</prop>
<prop key="H2">h2</prop>
</props>
</property>
</bean>
<!-- define the SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="businessDataSource" />
Expand All @@ -60,6 +68,7 @@
<!-- mapper locations is set here to support interdependency between mappers without -->
<!-- having to autowire repositories into java classes that do not make direct use of them -->
<property name="mapperLocations" value="classpath*:org/cbioportal/persistence/mybatis/**/*.xml" />
<property name="databaseIdProvider" ref="databaseIdProvider"/>
</bean>
</beans>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,14 @@

<select id="getPatientsDistinctClinicalEventInStudies" resultType="org.cbioportal.model.ClinicalEvent">
SELECT
clinical_event.CLINICAL_EVENT_ID AS clinicalEventId,
<choose>
<when test="_databaseId == 'mysql'">
ANY_VALUE(clinical_event.CLINICAL_EVENT_ID) AS clinicalEventId,
</when>
<when test="_databaseId == 'h2'">
clinical_event.CLINICAL_EVENT_ID AS clinicalEventId,
</when>
</choose>
clinical_event.EVENT_TYPE AS eventType,
patient.STABLE_ID AS patientId
<include refid="from"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,20 @@
<property name="url" value="jdbc:h2:mem:;MODE=MySQL;DATABASE_TO_UPPER=false;INIT=RUNSCRIPT FROM 'classpath:cgds-test.sql'\;RUNSCRIPT FROM 'classpath:testSql.sql'"/>
</bean>

<bean id="databaseIdProvider" class="org.apache.ibatis.mapping.VendorDatabaseIdProvider">
<property name="properties">
<props>
<prop key="MySQL">mysql</prop>
<prop key="H2">h2</prop>
</props>
</property>
</bean>

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dbcpDataSource"/>
<property name="typeAliasesPackage" value="org.mskcc.cbio.portal.model"/>
<property name="typeHandlersPackage" value="org.cbioportal.persistence.mybatis.typehandler"/>
<property name="databaseIdProvider" ref="databaseIdProvider"/>
</bean>

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
Expand Down

0 comments on commit f375e62

Please sign in to comment.