You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
When users instantiate a generated
DAOImpl
class without aConfiguration
, theDAO
doesn't really work. The intent is for theConfiguration
to be set later usingDAO.setConfiguration()
, but users might forget this. This will then produce a very unspecificNullPointerException
in random DAO operations, see e.g. #9489.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 aConfiguration
as most people will be able to initialise theirDAO
instances eagerly, e.g. using DI.See also: #9489
The text was updated successfully, but these errors were encountered: