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

NullPointerException when calling methods on DAO that is not attached to a Configuration #9497

Closed
lukaseder opened this issue Nov 5, 2019 · 0 comments

Comments

@lukaseder
Copy link
Member

When users instantiate a generated DAOImpl class without a Configuration, the DAO doesn't really work. The intent is for the Configuration to be set later using DAO.setConfiguration(), but users might forget this. This will then produce a very unspecific NullPointerException in random DAO operations, see e.g. #9489.

Caused by: java.lang.NullPointerException
    at org.jooq.impl.DAOImpl.records(DAOImpl.java:421)
    at org.jooq.impl.DAOImpl.insert(DAOImpl.java:176)
    at org.jooq.impl.DAOImpl.insert(DAOImpl.java:152)

We should throw a DetachedException instead, which is much more specific and allows for helping users debug their DAO misconfiguration.

Additionally, we could think of deprecating the setConfiguration() method and the constructors that do not accept a Configuration as most people will be able to initialise their DAO instances eagerly, e.g. using DI.


See also: #9489

@lukaseder lukaseder added this to the Version 3.13.0 milestone Nov 5, 2019
@lukaseder lukaseder self-assigned this Nov 5, 2019
@lukaseder lukaseder changed the title DAOImpl should throw DetachedException with specific error message, when DAO is not attached to a Configuration NullPointerException when calling methods on DAO that is not attached to a Configuration Nov 5, 2019
lukaseder added a commit that referenced this issue Nov 5, 2019
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