You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Patrick Casey <pa...@adelphia.net> on 2006/01/03 20:06:25 UTC

RE: dealing with optimizing ASOs

	Can't you just get a new session e.g.

	Session s = getSession();
	If (s == null)
		s = MySessionFactory.openSession();
	Object MyReloadedObject = s.load(MyClass.class, MyId);

	--- Pat

> -----Original Message-----
> From: Dan Adams [mailto:dan@ifactory.com]
> Sent: Tuesday, January 03, 2006 11:07 AM
> To: Tapestry users
> Subject: dealing with optimizing ASOs
> 
> Okay, so I have an ASO which holds an object. Now, for efficiency I made
> the object transient and also stored the objects id (id is the primary
> key). If the object is null it tries to reload the object using id. The
> problem with doing this is that the ASO has to store the dao service
> which it uses to get the object by id. But it can't store the service
> (because it is associated with a hibernate session and because that
> wouldnt really save on space) so when the ASO is unserialized both the
> object and the service is null so now I can't get the object back by id
> because I don't have the service. Anyone have a good solution to this?
> 
> --
> Dan Adams
> Software Engineer
> Interactive Factory
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: dealing with optimizing ASOs

Posted by Patrick Casey <pa...@adelphia.net>.
	I don't think I'm understanding your question here. To restore the
object you need precisely two datums of information: Its class, and its
unique identifier. You don't need to store the session or any kind of DAO if
you don't want to (although I usually store the DAOs because it keeps the
sessions out of the gui).

	--- Pat

> -----Original Message-----
> From: Dan Adams [mailto:dan@ifactory.com]
> Sent: Tuesday, January 03, 2006 11:14 AM
> To: Tapestry users
> Subject: RE: dealing with optimizing ASOs
> 
> Well, i'm using session-per-view and I don't want to have to change my
> services to have to know about their being serialized. Besides, doesn't
> serializing the service kind of defeat the point of not serializing the
> object the service is loading?
> 
> On Tue, 2006-01-03 at 11:06 -0800, Patrick Casey wrote:
> > 	Can't you just get a new session e.g.
> >
> > 	Session s = getSession();
> > 	If (s == null)
> > 		s = MySessionFactory.openSession();
> > 	Object MyReloadedObject = s.load(MyClass.class, MyId);
> >
> > 	--- Pat
> >
> > > -----Original Message-----
> > > From: Dan Adams [mailto:dan@ifactory.com]
> > > Sent: Tuesday, January 03, 2006 11:07 AM
> > > To: Tapestry users
> > > Subject: dealing with optimizing ASOs
> > >
> > > Okay, so I have an ASO which holds an object. Now, for efficiency I
> made
> > > the object transient and also stored the objects id (id is the primary
> > > key). If the object is null it tries to reload the object using id.
> The
> > > problem with doing this is that the ASO has to store the dao service
> > > which it uses to get the object by id. But it can't store the service
> > > (because it is associated with a hibernate session and because that
> > > wouldnt really save on space) so when the ASO is unserialized both the
> > > object and the service is null so now I can't get the object back by
> id
> > > because I don't have the service. Anyone have a good solution to this?
> > >
> > > --
> > > Dan Adams
> > > Software Engineer
> > > Interactive Factory
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> --
> Dan Adams
> Software Engineer
> Interactive Factory
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: dealing with optimizing ASOs

Posted by Dan Adams <da...@ifactory.com>.
Well, i'm using session-per-view and I don't want to have to change my
services to have to know about their being serialized. Besides, doesn't
serializing the service kind of defeat the point of not serializing the
object the service is loading?

On Tue, 2006-01-03 at 11:06 -0800, Patrick Casey wrote:
> 	Can't you just get a new session e.g.
> 
> 	Session s = getSession();
> 	If (s == null)
> 		s = MySessionFactory.openSession();
> 	Object MyReloadedObject = s.load(MyClass.class, MyId);
> 
> 	--- Pat
> 
> > -----Original Message-----
> > From: Dan Adams [mailto:dan@ifactory.com]
> > Sent: Tuesday, January 03, 2006 11:07 AM
> > To: Tapestry users
> > Subject: dealing with optimizing ASOs
> > 
> > Okay, so I have an ASO which holds an object. Now, for efficiency I made
> > the object transient and also stored the objects id (id is the primary
> > key). If the object is null it tries to reload the object using id. The
> > problem with doing this is that the ASO has to store the dao service
> > which it uses to get the object by id. But it can't store the service
> > (because it is associated with a hibernate session and because that
> > wouldnt really save on space) so when the ASO is unserialized both the
> > object and the service is null so now I can't get the object back by id
> > because I don't have the service. Anyone have a good solution to this?
> > 
> > --
> > Dan Adams
> > Software Engineer
> > Interactive Factory
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
-- 
Dan Adams
Software Engineer
Interactive Factory


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: dealing with optimizing ASOs

Posted by Dan Adams <da...@ifactory.com>.
No. This is because when you run the application on multiple servers
your session objects may get serialized/unserialized between requests
when passing between servers. I guess you can kind of forget about it
because I decided it wasn't worth the effort for the optimization and
took it out. Thanks anyway. :) Sorry for the confusion.

On Tue, 2006-01-03 at 14:19 -0500, Jesse Kuhnert wrote:
> Are you talking about aspectj objects? I'm not as familiar...I was going to
> question why you are serializing any objects at all, but it must be
> something having to do with aspectj that I don't know about. (which is a lot
> ;) )
> 
> On 1/3/06, Dan Adams <da...@ifactory.com> wrote:
> >
> > hmmm. maybe my question was confusing.
> >
> > my problem is that when the aso is created i inject my dao service. but
> > if the aso in serialized i lose both the object and the dao service. is
> > there another way of having the service re-injected into the aso when it
> > is unserialized?
> >
> > On Tue, 2006-01-03 at 14:09 -0500, Jesse Kuhnert wrote:
> > > That's what I do...(more or less, still using dao like objects so
> > session is
> > > hidden, but same concept with Session.load)
> > >
> > > You should also make sure you are using second level caching (if you can
> > > afford it) to be sure commonly used objects aren't ~always~ reloaded
> > > directly from the db.
> > >
> > > On 1/3/06, Patrick Casey <pa...@adelphia.net> wrote:
> > > >
> > > >
> > > >         Can't you just get a new session e.g.
> > > >
> > > >         Session s = getSession();
> > > >         If (s == null)
> > > >                 s = MySessionFactory.openSession();
> > > >         Object MyReloadedObject = s.load(MyClass.class, MyId);
> > > >
> > > >         --- Pat
> > > >
> > > > > -----Original Message-----
> > > > > From: Dan Adams [mailto:dan@ifactory.com]
> > > > > Sent: Tuesday, January 03, 2006 11:07 AM
> > > > > To: Tapestry users
> > > > > Subject: dealing with optimizing ASOs
> > > > >
> > > > > Okay, so I have an ASO which holds an object. Now, for efficiency I
> > made
> > > > > the object transient and also stored the objects id (id is the
> > primary
> > > > > key). If the object is null it tries to reload the object using id.
> > The
> > > > > problem with doing this is that the ASO has to store the dao service
> > > > > which it uses to get the object by id. But it can't store the
> > service
> > > > > (because it is associated with a hibernate session and because that
> > > > > wouldnt really save on space) so when the ASO is unserialized both
> > the
> > > > > object and the service is null so now I can't get the object back by
> > id
> > > > > because I don't have the service. Anyone have a good solution to
> > this?
> > > > >
> > > > > --
> > > > > Dan Adams
> > > > > Software Engineer
> > > > > Interactive Factory
> > > > >
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > > > For additional commands, e-mail:
> > tapestry-user-help@jakarta.apache.org
> > > >
> > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > > >
> > > >
> > --
> > Dan Adams
> > Software Engineer
> > Interactive Factory
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
-- 
Dan Adams
Software Engineer
Interactive Factory


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: dealing with optimizing ASOs

Posted by Jesse Kuhnert <jk...@gmail.com>.
Are you talking about aspectj objects? I'm not as familiar...I was going to
question why you are serializing any objects at all, but it must be
something having to do with aspectj that I don't know about. (which is a lot
;) )

On 1/3/06, Dan Adams <da...@ifactory.com> wrote:
>
> hmmm. maybe my question was confusing.
>
> my problem is that when the aso is created i inject my dao service. but
> if the aso in serialized i lose both the object and the dao service. is
> there another way of having the service re-injected into the aso when it
> is unserialized?
>
> On Tue, 2006-01-03 at 14:09 -0500, Jesse Kuhnert wrote:
> > That's what I do...(more or less, still using dao like objects so
> session is
> > hidden, but same concept with Session.load)
> >
> > You should also make sure you are using second level caching (if you can
> > afford it) to be sure commonly used objects aren't ~always~ reloaded
> > directly from the db.
> >
> > On 1/3/06, Patrick Casey <pa...@adelphia.net> wrote:
> > >
> > >
> > >         Can't you just get a new session e.g.
> > >
> > >         Session s = getSession();
> > >         If (s == null)
> > >                 s = MySessionFactory.openSession();
> > >         Object MyReloadedObject = s.load(MyClass.class, MyId);
> > >
> > >         --- Pat
> > >
> > > > -----Original Message-----
> > > > From: Dan Adams [mailto:dan@ifactory.com]
> > > > Sent: Tuesday, January 03, 2006 11:07 AM
> > > > To: Tapestry users
> > > > Subject: dealing with optimizing ASOs
> > > >
> > > > Okay, so I have an ASO which holds an object. Now, for efficiency I
> made
> > > > the object transient and also stored the objects id (id is the
> primary
> > > > key). If the object is null it tries to reload the object using id.
> The
> > > > problem with doing this is that the ASO has to store the dao service
> > > > which it uses to get the object by id. But it can't store the
> service
> > > > (because it is associated with a hibernate session and because that
> > > > wouldnt really save on space) so when the ASO is unserialized both
> the
> > > > object and the service is null so now I can't get the object back by
> id
> > > > because I don't have the service. Anyone have a good solution to
> this?
> > > >
> > > > --
> > > > Dan Adams
> > > > Software Engineer
> > > > Interactive Factory
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > >
> > >
> --
> Dan Adams
> Software Engineer
> Interactive Factory
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

Re: dealing with optimizing ASOs

Posted by Dan Adams <da...@ifactory.com>.
hmmm. maybe my question was confusing.

my problem is that when the aso is created i inject my dao service. but
if the aso in serialized i lose both the object and the dao service. is
there another way of having the service re-injected into the aso when it
is unserialized?

On Tue, 2006-01-03 at 14:09 -0500, Jesse Kuhnert wrote:
> That's what I do...(more or less, still using dao like objects so session is
> hidden, but same concept with Session.load)
> 
> You should also make sure you are using second level caching (if you can
> afford it) to be sure commonly used objects aren't ~always~ reloaded
> directly from the db.
> 
> On 1/3/06, Patrick Casey <pa...@adelphia.net> wrote:
> >
> >
> >         Can't you just get a new session e.g.
> >
> >         Session s = getSession();
> >         If (s == null)
> >                 s = MySessionFactory.openSession();
> >         Object MyReloadedObject = s.load(MyClass.class, MyId);
> >
> >         --- Pat
> >
> > > -----Original Message-----
> > > From: Dan Adams [mailto:dan@ifactory.com]
> > > Sent: Tuesday, January 03, 2006 11:07 AM
> > > To: Tapestry users
> > > Subject: dealing with optimizing ASOs
> > >
> > > Okay, so I have an ASO which holds an object. Now, for efficiency I made
> > > the object transient and also stored the objects id (id is the primary
> > > key). If the object is null it tries to reload the object using id. The
> > > problem with doing this is that the ASO has to store the dao service
> > > which it uses to get the object by id. But it can't store the service
> > > (because it is associated with a hibernate session and because that
> > > wouldnt really save on space) so when the ASO is unserialized both the
> > > object and the service is null so now I can't get the object back by id
> > > because I don't have the service. Anyone have a good solution to this?
> > >
> > > --
> > > Dan Adams
> > > Software Engineer
> > > Interactive Factory
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
-- 
Dan Adams
Software Engineer
Interactive Factory


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: dealing with optimizing ASOs

Posted by Jesse Kuhnert <jk...@gmail.com>.
That's what I do...(more or less, still using dao like objects so session is
hidden, but same concept with Session.load)

You should also make sure you are using second level caching (if you can
afford it) to be sure commonly used objects aren't ~always~ reloaded
directly from the db.

On 1/3/06, Patrick Casey <pa...@adelphia.net> wrote:
>
>
>         Can't you just get a new session e.g.
>
>         Session s = getSession();
>         If (s == null)
>                 s = MySessionFactory.openSession();
>         Object MyReloadedObject = s.load(MyClass.class, MyId);
>
>         --- Pat
>
> > -----Original Message-----
> > From: Dan Adams [mailto:dan@ifactory.com]
> > Sent: Tuesday, January 03, 2006 11:07 AM
> > To: Tapestry users
> > Subject: dealing with optimizing ASOs
> >
> > Okay, so I have an ASO which holds an object. Now, for efficiency I made
> > the object transient and also stored the objects id (id is the primary
> > key). If the object is null it tries to reload the object using id. The
> > problem with doing this is that the ASO has to store the dao service
> > which it uses to get the object by id. But it can't store the service
> > (because it is associated with a hibernate session and because that
> > wouldnt really save on space) so when the ASO is unserialized both the
> > object and the service is null so now I can't get the object back by id
> > because I don't have the service. Anyone have a good solution to this?
> >
> > --
> > Dan Adams
> > Software Engineer
> > Interactive Factory
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>