cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: check for changes before commit
Date Fri, 23 Nov 2012 16:04:46 GMT
Hi mrg,

> I haven't used the tapestry5-cayenne module, but for initializing some
> Cayenne (and non-Cayenne) things at application startup, you can use
> Tapestry's @Startup annotation in your application module:

yes I tried that yesterday, but it didn't work. I used it like this in

public void init(@InjectService("DataContext") ObjectContextProvider provider) { ... }

This didn't work. I got this exception:
Error invoking service contribution method
Unable to delegate method invocation to property 'request' of <Proxy for RequestGlobals(>,
because the property is null.

Don't know why it's about RequestGlobals here, but I think even though the TapestryCayenneModule
is defined at this point, the service ObjectContextProvider is not defined yet. 

> If the tapestry5-cayenne module provides services, perhaps they are even
> passable into your startup methods.  If not, I suppose you could still
> initialize the Cayenne runtime there.

That's what I did after reading your mail and it works :-) Thanks.

Now the method looks like this:

public void init() {
    ServerRuntime runtime = new ServerRuntime("cayenne.xml");    runtime.getDataDomain().getEntityResolver().getCallbackRegistry().addListener(new
    runtime.getDataDomain().addFilter(new ChangeSetFilter());

> You mentioned that there should only be one instance of ServerRuntime. 
> You
> can create multiple instances, but no need to do it for the same
> configuration.  However, if you have multiple models (in the past this
> would be multiple DataMaps in a single Cayenne model), then you'll need to
> create a ServerRuntime for each.

There is only one data-map in my therefore I was under the impression there
should be only one runtime. I don't mind a second runtime as long as everything works. Will
the "other" runtime inside the TapestryCayenneModule, which is instantiated later and has
all the data contexts I use, know about the filter and listener?

Should I add 
in my init method to end the first runtime which is not needed afterwards?

I'm going to try some more to find out if the last modified filter actually works.

View raw message