Open chenjch opened 10 years ago
Thank you for the report! That's a pretty tricky setting for MyBatipse :-) I'll see if there is a reasonable solution to such setting, but don't hold your breath.
In 1.0.7, I have changed the parsing logic when there are multiple SqlSessionFactoryBean declaration in a Spring config file.
In 1.0.6 and earlier, MyBatipse parses only the first bean to collect type aliases. In 1.0.7, MyBatipse parses all the beans.
This change should solve the error if... 1) there is no multiple classes with the same alias (e.g. entity.a.Order and entity.b.Order) or 2) there are multiple classes with the same alias, but their properties are the same.
Please let me know if 1.0.7 changes the situation...
Thank you, Iwao
Version 1.0.15 Using org.mybatis.spring.mapper.MapperScannerConfigurer
<bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
<property name="basePackage" value="com.thinkgem.jeesite"/>
<property name="annotationClass" value="com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao"/>
</bean>
Annotation:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
@Component
public @interface MyBatisDao {
/**
* The value may indicate a suggestion for a logical component name,
* to be turned into a Spring bean in case of an autodetected component.
* @return the suggested component name, if any
*/
String value() default "";
}
There is no multiple classes with the same alias Interface is like this:
@MyBatisDao
public interface UserDao extends CrudDao<User> {
public User getByLoginName(User user);
}
<select id="getByLoginName" resultType="User" parameterType="User">
SELECT
<include refid="userColumns"/>
FROM sys_user a...
Multiple annotations found at this line:
Hi @akacd ,
Could you show me the bean definition of sqlSessionFactory
?
MyBatipse couldn't resolve the type alias User
, so I need to see how you define type aliases.
@harawata It's like this:
<!-- MyBatis begin -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="typeAliasesPackage" value="com.thinkgem.jeesite"/>
<property name="typeAliasesSuperType" value="com.thinkgem.jeesite.common.persistence.BaseEntity"/>
<property name="mapperLocations" value="classpath:/mappings/**/*.xml"/>
<property name="configLocation" value="classpath:/mybatis-config.xml"></property>
</bean>`
Ah...there is a bug in type alias search :stuck_out_tongue_closed_eyes:
As it's a different problem than #15, I have created a new issue #42 . Thanks for the help!
every mapper xml file in mapper/a/.xml is ok but every mapper xml file in mapper/b/.xml have error:
Class/TypeAlias 'Order' not found.