Null instead of NotFoundException

18 views
Skip to first unread message

andreu...@taskize.co.uk

unread,
Nov 4, 2015, 9:28:29 AM11/4/15
to Sculptor Generator
Hi,

I am having some trouble with our application. I am seeing our repositories return null instead of throwing a NotFoundException when calling findById. I have checked the documentation and I know there is a sculptor property you can set for that (generate.NotFoundException) but we are not setting it. I also tried setting it to true to see if that forced the issue but still getting nulls.

Could anyone help with this?


Taskize Limited - Innovative solutions for Financial Services Technology.
Registered address: 33 Cannon Street, London, EC4M 5SB. Registered in England No. 7921239. This message may contain information that is privileged or confidential. If you are not the intended recipient please delete it and inform the sender immediately.

Torsten Juergeleit

unread,
Nov 4, 2015, 10:10:58 AM11/4/15
to Sculptor Generator
How did you define the findById method in your model?
if using "findByID;" (without throws clause) or scaffold you end up with a repository method which throws an "<AggregateRootName>NotFoundException" if the query result is null.

/Torsten

andreu...@taskize.co.uk

unread,
Nov 4, 2015, 11:54:28 AM11/4/15
to Sculptor Generator
I am defining it like this:

Repository PositionRepository {
findById;
   findAll;
   ...

Torsten Juergeleit

unread,
Nov 4, 2015, 12:41:53 PM11/4/15
to Sculptor Generator
Strange, here you should end up with “Position findById(Long id) throws PositionNotFoundException”. Otherwise the generator property “generate.NotFoundException” was set to false.

Please check if this is a side effect of your custom Sculptor extensions (e.g. custom ID generator).

As workaround you can define “findById throws PositionNotFoundException;” in the model.

/Torsten
Reply all
Reply to author
Forward
0 new messages