-
Notifications
You must be signed in to change notification settings - Fork 42
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
Java 9 TODO Automapped interface #22
Comments
Great, thanks! I'll have a look soon. |
I tried this and did not work for me but I would be happy to review a PR if you can make one. One of the current tests is below. Once your fix is in place uncomment the version check in the test and we'll see if it works! @Test
public void testAutomappedObjectsWhenDefaultMethodInvoked() {
// only run test if java 8
if (System.getProperty("java.version").startsWith("1.8.")) {
PersonWithDefaultMethod p = Database.test() //
.select("select name, score from person where name=?") //
.parameters("FRED") //
.autoMap(PersonWithDefaultMethod.class) //
.blockingFirst();
assertEquals("fred", p.nameLower());
}
} |
Sorry for delay. I have no java 8 installed, and my project is set to java 9.04 - source/binary, compile .. |
Here is one of my prj . cropped to minimum for testing. I use postgresql database .. works like a charm ..but i tested also with mysql, mssql, oracle, |
Hi, if you can make a PR on this with unit test it would be very welcome. |
This is not an issue, but had no idea where to drop suggestions
Automapped interface with default methods currentluy does not work in Java 9
In order to work in Java 9, folowing changes should be made :
in org.davidmoten.rx.jdbc.Util#ProxyService
class add additional method
@SuppressWarnings("unchecked")
public T newInstance(ResultSet rs, Class cls) {
return (T) Proxy.newProxyInstance(cls.getClassLoader(), new Class[] { cls }, new ProxyInstance(cls, values()));
}
in org.davidmoten.rx.jdbc.Util class
alter original method that works with java8
static T autoMap(ResultSet rs, Class cls, ProxyService proxyService) {
return proxyService.newInstance();
}
to a modified version that works with java 9
static T autoMap(ResultSet rs, Class cls, ProxyService proxyService) {
return proxyService.newInstance(rs, cls);
}
Testing example that worked in Java 9
Database
.test()
.select(Person.class)
.get()
.map(Person::name)
.blockingForEach(System.out::println);
Not related to this example - another suggestion - make annotation work with sql field aliases
I would be happy to share more ideas for this great great api.
The text was updated successfully, but these errors were encountered: