mybatis / mybatipse

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

error for resultMaps whose type is an interface extending another interface #89

Closed ross-cohen closed 5 years ago

ross-cohen commented 5 years ago

Mybatipse seems to have problem following interface inheritance.

For

<resultMap id="aResultMap" type="InterfaceB">
    <result property="xInInterfaceA" />
    <result property="yInInterfaceB" />
</resultMap>

where

interface InterfaceB extends InterfaceA {
     int getYInInterfaceB();
     void setYInInterfaceB(int y);
}
interface InterfaceA {
    int getXInInterfaceA();
    void setXInInterfaceA(int x);
}  

Mybatipse reports an error for the property:

<result property="yInInterfaceB" />

It says InterfaceB has no such property. This, of course, it true, but InterfaceB extends an interface that does have such a property. Since this scheme works in mybatis, I expect it to work in mybatipse.

Now if I change the typeAlias for the resultMap types to the actual implementation classes (InterfaceAImpl & InteferaceBImpl), Mybatipse no longer reports an error.

Thanks, Rosss

harawata commented 5 years ago

Thanks for the report!

This looks similar to #58 . Which version are you using? What happens if you specify the fully-qualified name instead of typeAlias?

p.s. Just to clarify, what are the actual method names? It may be just an example, but when the method name is "setYInInterfaceB", the property name is "YInInterfaceB" not "yInInterfaceB".

ross-cohen commented 5 years ago

Method names follow standard JavaBean property conventions. In this case the inherited property is "updateTime", having standard getter/setter functions: public Date getUpdateTime(); public void setUpdateTime(Date updateTime);

The property name in the the resultMap is "updateTime": <result property="updateTime" />

And "updateTime" is the standard JavaBean property name -- though it is not (perhaps) the proper mybatis property name. This however would surprise me a bit, since we've been using ibatis/mybatis for 10+ years without any practical conflict between the JavaBean notion of a property name and mybatis'. Eclispe Market Place says 1.2.0 is installed, while the "installation details" version number is 1.0.0. I installed from Market Place.

Thanks for the prompt reply! Ross

ross-cohen commented 5 years ago

Yes, it looks the same as #58. Makes me wonder if somehow I'm running 1.0.0.

harawata commented 5 years ago

We should rule out the possibility first. Could you test it with a fresh installation of Eclipse?

ross-cohen commented 5 years ago

I apologize for wasting your time. The new Photon/Mybatipse environment works as expected.

Somehow I installed an ancient version of Mybatipse on Eclipse Oxygen -- though how that happened is a mystery to me, since the environment (Eclipse Oxygen) is less than a year old -- and I installed everything I could from Marketplace.

Regardless, thanks for your help, and I apologize again.

Ross

harawata commented 5 years ago

It turned out that 1.2.0 was incompatible with Oxygen (it was not intentional and I'll release 1.2.1 that supports Neon and Oxygen soon). I expected that Marketplace would install the latest compatible version in such case, but maybe I was wrong.

Anyway, I appreciate you for taking the time to submit the report! :)