davidmoten/rxjava2-jdbc

Java 9 TODO Automapped interface

Offen

#22 geöffnet am 08.03.2018

 (5 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Java (41 Forks)github user discovery
enhancementhelp wanted

Repository-Metriken

Stars
 (396 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 2m) (1 gemergte PR in 30 T)

Beschreibung

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.

Contributor Guide