在不同的表中,DB中有两个以上的公共字段(id ,created_by,modified_date)
。
使用内部联接时,相同的列名字段值将被覆盖。这在查询浏览器工具中工作正常但在春季3,hibernate 3环境中无效。
查询:
select i.modified_date ,l.modified_date
from illness i inner join illness_history l on i.id=l.ill_hist_illness_id
Spring配置:
<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>
答案 0 :(得分:1)
这可能是由于hibernate中未解决的错误。检查here。您的解决方案将包含Alias并进行测试。
select i.modified_date m1 ,l.modified_date m2, from illness i inner join illness_history l on i.id=l.ill_hist_illness_id