-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support default methods on mapper interfaces #709
Comments
I have just tested, but adding a default method to a mapper interface does not break a test case. |
@harawata Here's a simple example mapper against the latest release (3.4.1): package example;
import org.apache.ibatis.annotations.Select;
public interface ExampleMapper {
@Select("SELECT 1")
int select();
default int defaultSelect() {
return select();
}
} Calling
|
I think supporting default method is good idea!! |
Definitely a good idea. Data transformation through default methods would be a good feature IMO.
... and so on |
I wrote a patch. Still, it would be great if you could test it and see if it works as you expect. Cheers, |
Default methods are Java 8. There are no default methods in Java 6 or 7. So there is no way to achieve this pre Java 8. |
Never mind. It should be fixed in the latest 3.4.2-SNAPSHOT. |
This is not working if the interface has default (package) access modifier. ` ` I just changed the org.apache.ibatis.submitted.usesjava8.default_method.Mapper to package level, and the test fails. |
Hi @mchiareli , |
#905 here it is. thanks. |
… is called, invoke the default method instead of looking for a bound mapper method.
I'd like support for default methods on mapper interfaces. Currently if a method is not implemented (even if it is a default method) an exception is thrown:
I believe it would be relatively easy to add a type
SqlCommandType.ABSTRACT
and call the underlying default function.It is a useful feature because it allows you to put helper methods on mappers.
The text was updated successfully, but these errors were encountered: