Re: [grails-dev] Re: Persisteny event listeners in Grails

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [grails-dev] Re: Persisteny event listeners in Grails

smaldini
To answer your question, you HAVE to get the old state from somewhere. If it's not from your request, where do you think you can get the former state ?
My take is, if your application is using 2nd level cache correctly, Domain.get(xxx) will be virtually free and no query will be issued. So hook into beforeInsert, beforeValidate or wherever you want, use Domain.get(newObject.id) to compare your old state to your new object. Something I don't see is how do you issue the update of your object in the first place, you probably have retrieved the old domain to verify its presence and return an error to your user otherwise ? 

The plugin is hosted under https://github.com/reactor/grails-events and as the version suggests there might be missing stuff, especially doc wise. However the plugin is an evolution of http://grailsrocks.github.io/grails-platform-core/guide/events.html and you can jump to slide 43 here http://www.slideshare.net/StphaneMaldini/reactor-grails-realtime-web-devoxx-2013.


On Wed, Nov 27, 2013 at 7:25 AM, smakela <[hidden email]> wrote:
And by the way smaldini, you did not even answer to my question.
How do you get OLD state of the object (And I don't want to make a query to
database)?
And where I can find documentation and source code of that plugin?



--
View this message in context: http://grails.1312388.n4.nabble.com/Persistency-event-listeners-in-Grails-tp4651809p4651901.html
Sent from the Grails - dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Stéphane
--

Reply | Threaded
Open this post in threaded view
|

Re: [grails-dev] Re: Persisteny event listeners in Grails

smakela
My point was that why the event that arrives does not include the old object? So the what ever datasource is used, takes care of the adding the old state to the event.
Reply | Threaded
Open this post in threaded view
|

Re: [grails-dev] Re: Persisteny event listeners in Grails

smaldini
Because it would make the assumption that it needs to query/fetch from cache where not everyone needs to do that. The database event is not a database event, it's a GORM event, it doesn't come from database. So basically update is agnostic to any need of read-before.


On Wed, Nov 27, 2013 at 8:51 AM, smakela <[hidden email]> wrote:
My point was that why the event that arrives does not include the old object?
So the what ever datasource is used, takes care of the adding the old state
to the event.




--
View this message in context: http://grails.1312388.n4.nabble.com/Re-grails-dev-Re-Persisteny-event-listeners-in-Grails-tp4651902p4651904.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Stéphane
--