Skip to content
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

DefaultRecordMapper should check whether user is attempting to map into an inner class #13582

Closed
lukaseder opened this issue May 20, 2022 · 1 comment

Comments

@lukaseder
Copy link
Member

The DefaultRecordMapper cannot instantiate inner classes via reflection, as it doesn't know anything about an enclosing instance. E.g. this isn't possible:

class Outer {
    class Inner {}
}

And then

ctx.resultQuery("...").fetchInto(Outer.Inner.class);

Users will have to make their nested classes static, e.g.

class Outer {
    static class Inner {}
}

This can easily be forgotten, because of Java's ill chosen default of making nested classes inner classes. It would be nice if the DefaultRecordMapper could check this:

clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers());

And add a debug message to the list of messages from #11794

@lukaseder
Copy link
Member Author

Fixed in jOOQ 3.17.0, 3.16.7 (#13583), and 3.15.11 (#13584)

lukaseder added a commit that referenced this issue May 20, 2022
attempting to map into an inner class
lukaseder added a commit that referenced this issue May 20, 2022
attempting to map into an inner class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant