Re: Wicket Sessions, serialization and Cayenne
Christian, I think what you have suggested already exists in the Cayenne documentation (the link I already posted in my last answer). One more thing is that this filter must be inserted BEFORE the wicket one. By the way, did you see my comment on your website about the use of cayenne and wicket ? If so, any answer ? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Sessions-serialization-and-Cayenne-tp3452466p3452759.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket Sessions, serialization and Cayenne
Use a dto if you're that worried about it On Apr 15, 2011 2:55 PM, "david ruescas" wrote: > YK and Chris > > Thanks for your replies. I already have the cayenne filter installed, and > the datacontext is accessible via > > BaseContext.getThreadObjectContext(); > > but this is not the problem. The problem is that cayenne objects referenced > from models sometimes (eg when browsing to versioned pages) end up in a > hollow state, probably due to deserialization. It is similar to the problem > discussed here > > http://comments.gmane.org/gmane.comp.java.cayenne.user/12017 > > I solved the problem with models using loadable detachable models, but I am > fearing the same problem may show up with cayenne objects that are stored in > my session (i am using my own session class with references to cayenne > objects, installed with getWebSessionClass()) > > Thanks, > > David > > On Fri, Apr 15, 2011 at 8:41 PM, Christian Grobmeier wrote: > >> Hi, >> i have solved it like this: >> >> http://www.grobmeier.de/using-apache-cayenne-with-apache-wicket-05022011.html >> Cheers >> Christian >> >> On Fri, Apr 15, 2011 at 8:20 PM, YK wrote: >> >>the datacontext was lost >> > >> > I think this is the root cause of your problems. >> > >> > A cayenne dataContext is generally created once for all for each web >> session >> > where it is stored. >> > You should have a http://cayenne.apache.org/doc30/tutorial-webapp.htmlweb >> > filter that stores this dataContext in the ThreadLocal context in order >> to >> > use it >> > in the persistence layer of your application like the following : >> > ObjectContext context = BaseContext.getThreadObjectContext(); >> > List artists = context.performQuery(query); >> > >> > Make sure you are not loosing the dataContext after each request. >> > >> > take a look at http://cayenne.apache.org/doc30/tutorial-webapp.htmlthis >> > link for more information >> > >> > >> > -- >> > View this message in context: >> http://apache-wicket.1842946.n4.nabble.com/Wicket-Sessions-serialization-and-Cayenne-tp3452466p3452694.html >> > Sent from the Users forum mailing list archive at Nabble.com. >> > >> > - >> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> > For additional commands, e-mail: users-h...@wicket.apache.org >> > >> > >> >> >> >> -- >> http://www.grobmeier.de >> >> - >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >>
Re: Wicket Sessions, serialization and Cayenne
YK and Chris Thanks for your replies. I already have the cayenne filter installed, and the datacontext is accessible via BaseContext.getThreadObjectContext(); but this is not the problem. The problem is that cayenne objects referenced from models sometimes (eg when browsing to versioned pages) end up in a hollow state, probably due to deserialization. It is similar to the problem discussed here http://comments.gmane.org/gmane.comp.java.cayenne.user/12017 I solved the problem with models using loadable detachable models, but I am fearing the same problem may show up with cayenne objects that are stored in my session (i am using my own session class with references to cayenne objects, installed with getWebSessionClass()) Thanks, David On Fri, Apr 15, 2011 at 8:41 PM, Christian Grobmeier wrote: > Hi, > i have solved it like this: > > http://www.grobmeier.de/using-apache-cayenne-with-apache-wicket-05022011.html > Cheers > Christian > > On Fri, Apr 15, 2011 at 8:20 PM, YK wrote: > >>the datacontext was lost > > > > I think this is the root cause of your problems. > > > > A cayenne dataContext is generally created once for all for each web > session > > where it is stored. > > You should have a http://cayenne.apache.org/doc30/tutorial-webapp.htmlweb > > filter that stores this dataContext in the ThreadLocal context in order > to > > use it > > in the persistence layer of your application like the following : > > ObjectContext context = BaseContext.getThreadObjectContext(); > >List artists = context.performQuery(query); > > > > Make sure you are not loosing the dataContext after each request. > > > > take a look at http://cayenne.apache.org/doc30/tutorial-webapp.htmlthis > > link for more information > > > > > > -- > > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Wicket-Sessions-serialization-and-Cayenne-tp3452466p3452694.html > > Sent from the Users forum mailing list archive at Nabble.com. > > > > - > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > For additional commands, e-mail: users-h...@wicket.apache.org > > > > > > > > -- > http://www.grobmeier.de > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Re: Wicket Sessions, serialization and Cayenne
Hi, i have solved it like this: http://www.grobmeier.de/using-apache-cayenne-with-apache-wicket-05022011.html Cheers Christian On Fri, Apr 15, 2011 at 8:20 PM, YK wrote: >>the datacontext was lost > > I think this is the root cause of your problems. > > A cayenne dataContext is generally created once for all for each web session > where it is stored. > You should have a http://cayenne.apache.org/doc30/tutorial-webapp.html web > filter that stores this dataContext in the ThreadLocal context in order to > use it > in the persistence layer of your application like the following : > ObjectContext context = BaseContext.getThreadObjectContext(); > List artists = context.performQuery(query); > > Make sure you are not loosing the dataContext after each request. > > take a look at http://cayenne.apache.org/doc30/tutorial-webapp.html this > link for more information > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Wicket-Sessions-serialization-and-Cayenne-tp3452466p3452694.html > Sent from the Users forum mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > -- http://www.grobmeier.de - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket Sessions, serialization and Cayenne
>the datacontext was lost I think this is the root cause of your problems. A cayenne dataContext is generally created once for all for each web session where it is stored. You should have a http://cayenne.apache.org/doc30/tutorial-webapp.html web filter that stores this dataContext in the ThreadLocal context in order to use it in the persistence layer of your application like the following : ObjectContext context = BaseContext.getThreadObjectContext(); List artists = context.performQuery(query); Make sure you are not loosing the dataContext after each request. take a look at http://cayenne.apache.org/doc30/tutorial-webapp.html this link for more information -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Sessions-serialization-and-Cayenne-tp3452466p3452694.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Wicket Sessions, serialization and Cayenne
Hello I am using Wicket with Cayenne ORM and have some doubts regarding serialization of cayenne objects in the Session. I am not sure this list is appropriate as my question is not only about Wicket but about Wicket and Cayenne. Please let me know if my question does not belong here. In the past I've had problems creating models that had direct references to cayenne objects. It seems that during the process of deserializaing said objects when accessing versioned pages, references were set to null (persistent state hollow) and the datacontext was lost. This caused some NPE's to show up (especially when using the back button) or some null values on the markup. I then realised that the correct way to obtain these objects is via loadable detachable models. This way, the cayenne objects themselves are never serialized or deserialized, but are fetched on demand from the database. The problems were solved. However, besides the case of cayenne objects being referenced by models which I have removed, I have cayenne objects which are stored directly in the Session. For example, when the user logs there is a corresponding cayenne User object that is loaded from the database and kept in the session. For the moment I have had no problems with null references or NPE's, but given my past problems, I am not sure this is safe. In summary, is it safe to store Cayenne objects in the session? When are these objects serialized? Have I had no problems to date because these objects are kept in memory? Will I have problems when clustering, if there is session migration going on? Many Thanks, David