mybatis / mybatipse

Eclipse plugin adding support for MyBatis SQL Mapper Framework.
Eclipse Public License 1.0
332 stars 91 forks source link

parameterType Enum creates Class/TypeAlias 'MyEnum' not found. #74

Closed Sicaine closed 7 years ago

Sicaine commented 7 years ago

Hi,

i have one sql which takes an Enum as parameterType.

The sql works fine but MyBatis tells me that it can't find the Class/TypeAlias.

Tx.

harawata commented 7 years ago

Hi,

Thanks for the report! But...I couldn't reproduce it. Both alias and fully-qualified name are correctly recognized. Here is the enum and the select statement that I used to test.

package test;
public enum MyEnum {
}
<select id="select" parameterType="test.MyEnum">
  select 1
</select>

Any difference with your code?

Sicaine commented 7 years ago

Tx for your quick replay! :)

I'm using the package element:

<typeAliases>
    <package name="test"/>
</typeAliases>

and only using the Name of the Enum itself:

<select id="select" parameterType="MyEnum">
    select 1
</select>

Hope this is reproducable.

harawata commented 7 years ago

Still unable to reproduce it. :(

Does using fully-qualified name solve the issue? If the answer is yes, the plugin couldn't find the configuration file for some reason, I guess. Check if there is a valid DOCTYPE (no 'www' in the URL).

<!DOCTYPE configuration
    PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-config.dtd">

In case you need a quick workaround, try defining custom type alias in the setting.

Sicaine commented 7 years ago

Yes the fully-qualified name works. I have, in the same file, another class from the same package and it works fine. It is only the Enum which makes issues.

I will try to reproduce it in a small env, but probably next week.

My mybatis has the typeAliases above the mapper file where my select statements are Perhaps this file helps you:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <settings>
      ...
    </settings>

    <typeAliases>
        ...
        <package name="test"/>
    </typeAliases>

    <environments default="standard">
        ...
    </environments>

    <mappers>
        <mapper resource="mapperFile.xml"/>
    </mappers>
</configuration>
harawata commented 7 years ago

OK, I think I found the cause. Thanks for your help!

harawata commented 7 years ago

Hi @Sicaine , It should be fixed in 1.1.0. Let me know if there is anything wrong. Thanks again for your report!

Sicaine commented 7 years ago

@harawata works perfect! Got the new version directly through eclipse. Tx :-)