There are more than two common fields (id ,created_by,modified_date)in DB in different tables.
While using inner join that same column name field values are overwrite .This is working fine in query browser tools but not works in spring 3, hibernate 3 environment.
Query:
select i.modified_date ,l.modified_date
from illness i inner join illness_history l on i.id=l.ill_hist_illness_id
Spring Configuration:
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/project" />
<property name="username" value="root" />
<property name="password" value="password" />
</bean>
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="myDataSource" />
<property name="packagesToScan">
<list>
<value>com.project.**.*</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.generate_statistics"> true</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="cache.use_query_cache">true</prop>
<prop key="cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="show_sql">true</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
</props>
</property>
</bean>
<tx:annotation-driven transaction-manager="txManager" />
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="mySessionFactory" />
</bean>
This may be due to an unresolved bug in hibernate . Check here . Your solution would be inclde an Alias and test .