@OnSave and asynchronicity

50 views
Skip to first unread message

Salomon Brys

unread,
Jan 8, 2013, 11:45:36 AM1/8/13
to objectify...@googlegroups.com
Hi there,

How is @OnSave treated regarding asynchronicity ?

Precisely, considering that I have a validation method that validate my bean and throws an exception when the bean is invalid.

Now, when I save my bean using ofy().save().entity(myBean); will the exception be thrown as expected or do I have to call .now(); to make sure that I can catch the exception ?

Other way to ask the question : is @OnSave annotation is called during ofy().save().entity(...) or during .now() ?

Thank you,
Salomon BRYS


Avatar Salomon BrysSalomon BRYS | Architecte Logiciel | Chief Geek Officer
Kick Your App
80 Rue des Haies - 75020 - Paris, France
+33 9 72 37 17 24 | +33 6 83 54 55 96 
sal...@kickyourapp.com
LinkedinLogo Kick Your App

Mat Jaggard

unread,
Jan 8, 2013, 1:20:06 PM1/8/13
to objectify...@googlegroups.com
It looks to me as if your code is called within ofy().save().entity(myBean); rather than the future's .now() method.

That would be fairly simple to test though, just create an @OnSave that always throws an exception.

Jeff Schnitzer

unread,
Jan 8, 2013, 2:17:18 PM1/8/13
to objectify...@googlegroups.com

Yup this is how it works. On save is called before save, not after.

Reply all
Reply to author
Forward
0 new messages