Thanks for super-fast replies! ;) Only one problem remains unsolved
for me for today with jooq: 
http://groups.google.com/group/jooq-user/t/5e88b2e2f58e0cad

On 18 апр, 01:25, Lukas Eder <[email protected]> wrote:
> > There is written in javadoc, that fetchOne() "Returns: The resulting
> > values.".
>
> Thanks for pointing that out. That's a copy-paste 
> error:https://sourceforge.net/apps/trac/jooq/ticket/419
>
> > I have the following query:
>
> > int JobID =
> > sqlFactory.select(Job.ID).from(Job.JOB).where(Job.POSITION.notEqual(0),
> > Job.STATUS.equal(JobStatus.QUEUED)).orderBy(Job.POSITION).limit(1).fetchOne(Job.ID);
>
> > And I think this line can throw NullReferenceException in case SELECT
> > finds no rows matching conditions (underlying call to fetchOne(),
> > returning Record will return null in this case). And implicit cast to
> > int will get us NullReferenceException.
>
> jOOQ does not support primitive types (yet). Hence you must always
> take care when using auto-unboxing of Integer to int. This is not a
> jOOQ issue, though. jOOQ uses the generic type <T> for field types,
> which can never be a primitive type. Hence it is always nullable (even
> if the underlying field is a not null field)
>
> > I think this should be explicitly documented, that generic method
> > fetchOne() can return null also (not only "the resulting values") and
> > null means - no rows were found by SELECT query. It's especially
> > important when working with generic fetchOne() methods, returning
> > simple types like Integer since they are implicitly cast into their
> > non-object counterparts like int.
>
> Assign the value to "Integer jobID" and add an additional null check.
> I will correct the Javadoc as of #419 to clarify this behaviour.

Reply via email to