I am running Spring Batch and using JdbcPagingItemReader
. With a sample config of :
<bean id="dogQueryProvider" class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
<property name="databaseType" value="mysql" />
<property name="dataSource" ref="dataSource" />
<property name="selectClause"
value="SELECT owner.id as ownerid, first_name, last_name, dog_name " />
<property name="fromClause"
value="FROM dog_owner owner INNER JOIN dog ON owner.id = dog.id " />
<property name="sortKey" value="owner.id" />
</bean>
I am getting an error related to:
Column 'id' in order clause is ambiguous; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'id' in order clause is ambiguous.
Take it that dog_owner
and dog
tables have id
columns. I am thinking that this is related to AbstractSqlPagingQueryProvider.getSortKeysWithoutAliases
, which I think strips off owner
from owner.id
specified as sortKey
. Any suggestions to resolve this issue?