Hi Lukas, sorry, I forgot to send a code snippet.
In my case the optional type is not a good idea cause the ID which should match to one object have to exist. But I understand my mistake and I like the 'fetchOneInto' method. Thank you very much! Am Freitag, 20. März 2015 11:29:16 UTC+1 schrieb Lukas Eder: > > Hi, > > it's always a good idea to accompany a bug report with actual code. Code > is better at describing code, than words... :) > > I'm assuming that you're using this code: > > MyType object = DSL.using(...) > .select(...) > .from(...) > .fetchOne() > .into(MyType.class); > > > Yes. That will throw a NullPointerException because fetchOne() may return > null. There is no way to throw any other exception on the into() call, as > we cannot intercept calls made on null references in Java. Unfortunately, > we're still supporting Java 6, so we do not have access to the Java 8 > Optional type, which might have been used here. > > I suggest you either handle null references yourself, or you resort to > using fetchOneInto(): > > MyType object = DSL.using(...) > .select(...) > .from(...) > .fetchOneInto(MyType.class); > > Hope this helps, > Lukas > > 2015-03-20 10:17 GMT+01:00 <[email protected] <javascript:>>: > >> When a record is null after DSL select query the method into() will throw >> a NullPointerException >> >> into() should throw any other BusinessException or return NULL >> >> -- >> You received this message because you are subscribed to the Google Groups >> "jOOQ User Group" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
