|
Home > Archive > Apache JDO Project > September 2005 > UserObject
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Craig Russell 2005-09-29, 8:45 pm |
| Hi Karan,
Yes, this use case is absolutely supported, assuming that transaction
propagation is in effect.
If there is no transaction propagation, you can still achieve the same
effect if you pass a "live" object from one bean to another:
class SSBA {
pm =3D pmf.getPM();
SomeState ss =3D new SomeState(some, state);
pm.setUserObject(ss);
Object bean =3D pm.getObjectById(theID);
ssbB.B(bean);
pm.close();
....
}
class SSBB {
void B(Object bean);
pm =3D JDOHelper.getPersistenceManager(bean);
SomeState ss =3D (SomeState)pm.getUserObject();
ss.someMethod();
}
Craig
=09From: =09 karan.malhi@gmail.com
=09Subject: =09Re: PersistenceManager UserObject
=09Date: =09September 29, 2005 1:16:52 PM PDT
=09To: =09 jdo-dev@db.apache.org
=09Reply-To: =09 jdo-dev@db.apache.org, karan.malhi@gmail.com
Hi Michael,
I am thinking of a scenario where it can be used. Correct me if i am wrong=
..
lets say a stateless session bean (Container managed transaction), has a
method
method A(){
// get the pm
pm.setUserObject(new Object());
B();
pm.close();
}
another session bean has
method B(){
//get pm
pm.getUserObject(); //this should work
}
assuming that the same transaction got propagated to B(), should we be abl=
e
to get the UserObject, because the second session bean should also get the
same instance of pm as the first one.
Let me know if this could be a usecase of get/set User Object
On 9/29/05, Michael Bouschen <mbo.tech@spree.de> wrote:
Hi Karan,
Hi Craig,
Thanks.
What happens to the user object once i close the pm?
I think nothing will happen. Accoring to the spec a user object is not
inspected or used in any way by the JDO implementation.
Regards Michael
On 9/29/05, Craig Russell <craig.russell@sun.com> wrote:
Hi Karan,
The UserObject pattern is intended for applications that need to
access some local state that is associated with the persistence
context. Any persistent object can navigate to its persistence manager
and access some application-specific data.
This turned out to be very useful in JDO, so much so that users asked
for finer-grained UserObject information: a Map of UserKey and
UserValue.
Craig
From: karan.malhi@gmail.com
Subject: user object with pm
Date: September 29, 2005 8:24:33 AM PDT
To: jdo-dev@db.apache.org
Reply-To: jdo-dev@db.apache.org, karan.malhi@gmail.com
Hi Craig,
What is the purpose of get/setUserObject in the pm api? What would be
the
use-case where i would use these methods?
--
Karan Malhi
--
Karan Malhi
Michael Bouschen Tech@Spree Engineering GmbH
mailto:mbo.tech@spree.de http://www.tech.spree.de/
Tel.:++49/30/235 520-33 Buelowstr. 66
Fax.:++49/30/2175 2012 D-10783 Berlin
--
Karan Malhi
| |
| Karan Malhi 2005-09-29, 8:45 pm |
| Hi Craig,
This is assuming that both the beans are on the same jvm
I dont see this kind of a scenario working on the two SSB's on different
JVM's. Correct?
"The UserObject pattern is intended for applications that need to
access some local state that is associated with the persistence
context"
And by persistence context you mean "local persistence context", right?
On 9/29/05, Craig Russell <craig.russell@sun.com> wrote:
>
> Hi Karan,
>
> Yes, this use case is absolutely supported, assuming that transaction
> propagation is in effect.
>
> If there is no transaction propagation, you can still achieve the same
> effect if you pass a "live" object from one bean to another:
>
> class SSBA {
> pm = pmf.getPM();
> SomeState ss = new SomeState(some, state);
> pm.setUserObject(ss);
> Object bean = pm.getObjectById(theID);
> ssbB.B(bean);
> pm.close();
> ...
> }
>
> class SSBB {
> void B(Object bean);
> pm = JDOHelper.getPersistenceManager(bean);
> SomeState ss = (SomeState)pm.getUserObject();
> ss.someMethod();
> }
>
> Craig
>
> From: karan.malhi@gmail.com
> Subject: Re: PersistenceManager UserObject
> Date: September 29, 2005 1:16:52 PM PDT
> To: jdo-dev@db.apache.org
> Reply-To: jdo-dev@db.apache.org, karan.malhi@gmail.com
>
> Hi Michael,
> I am thinking of a scenario where it can be used. Correct me if i am
> wrong.
> lets say a stateless session bean (Container managed transaction), has a
> method
> method A(){
> // get the pm
> pm.setUserObject(new Object());
> B();
> pm.close();
> }
> another session bean has
> method B(){
> //get pm
> pm.getUserObject(); //this should work
> }
> assuming that the same transaction got propagated to B(), should we be
> able
> to get the UserObject, because the second session bean should also get the
> same instance of pm as the first one.
> Let me know if this could be a usecase of get/set User Object
> On 9/29/05, Michael Bouschen <mbo.tech@spree.de> wrote:
>
> Hi Karan,
>
> Hi Craig,
> Thanks.
> What happens to the user object once i close the pm?
>
>
>
> I think nothing will happen. Accoring to the spec a user object is not
> inspected or used in any way by the JDO implementation.
>
> Regards Michael
>
> On 9/29/05, Craig Russell <craig.russell@sun.com> wrote:
>
>
> Hi Karan,
>
> The UserObject pattern is intended for applications that need to
> access some local state that is associated with the persistence
> context. Any persistent object can navigate to its persistence manager
> and access some application-specific data.
>
> This turned out to be very useful in JDO, so much so that users asked
> for finer-grained UserObject information: a Map of UserKey and
> UserValue.
>
> Craig
>
> From: karan.malhi@gmail.com
> Subject: user object with pm
> Date: September 29, 2005 8:24:33 AM PDT
> To: jdo-dev@db.apache.org
> Reply-To: jdo-dev@db.apache.org, karan.malhi@gmail.com
>
> Hi Craig,
> What is the purpose of get/setUserObject in the pm api? What would be
> the
> use-case where i would use these methods?
> --
> Karan Malhi
> --
> Karan Malhi
> Michael Bouschen Tech@Spree Engineering GmbH
> mailto:mbo.tech@spree.de http://www.tech.spree.de/
> Tel.:++49/30/235 520-33 Buelowstr. 66
> Fax.:++49/30/2175 2012 D-10783 Berlin
>
>
>
>
> --
> Karan Malhi
>
--
Karan Malhi
| |
| Craig Russell 2005-09-30, 5:45 pm |
| Hi Karan,
Karen opined:
Hi Craig,
This is assuming that both the beans are on the same jvm
I dont see this kind of a scenario working on the two SSB's on different
JVM's. Correct?
Correct.
"The UserObject pattern is intended for applications that need to
access some local state that is associated with the persistence
context"
And by persistence context you mean "local persistence context", right?
Right. Read the above as local state that is associated with the local
persistence context.
Craig
On 9/29/05, Craig Russell <craig.russell@sun.com> wrote:
Hi Karan,
Yes, this use case is absolutely supported, assuming that transaction
propagation is in effect.
If there is no transaction propagation, you can still achieve the same
effect if you pass a "live" object from one bean to another:
class SSBA {
pm =3D pmf.getPM();
SomeState ss =3D new SomeState(some, state);
pm.setUserObject(ss);
Object bean =3D pm.getObjectById(theID);
ssbB.B(bean);
pm.close();
....
}
class SSBB {
void B(Object bean);
pm =3D JDOHelper.getPersistenceManager(bean);
SomeState ss =3D (SomeState)pm.getUserObject();
ss.someMethod();
}
Craig
From: karan.malhi@gmail.com
Subject: Re: PersistenceManager UserObject
Date: September 29, 2005 1:16:52 PM PDT
To: jdo-dev@db.apache.org
Reply-To: jdo-dev@db.apache.org, karan.malhi@gmail.com
Hi Michael,
I am thinking of a scenario where it can be used. Correct me if i am
wrong.
lets say a stateless session bean (Container managed transaction), has a
method
method A(){
// get the pm
pm.setUserObject(new Object());
B();
pm.close();
}
another session bean has
method B(){
//get pm
pm.getUserObject(); //this should work
}
assuming that the same transaction got propagated to B(), should we be
able
to get the UserObject, because the second session bean should also get the
same instance of pm as the first one.
Let me know if this could be a usecase of get/set User Object
On 9/29/05, Michael Bouschen <mbo.tech@spree.de> wrote:
Hi Karan,
Hi Craig,
Thanks.
What happens to the user object once i close the pm?
I think nothing will happen. Accoring to the spec a user object is not
inspected or used in any way by the JDO implementation.
Regards Michael
On 9/29/05, Craig Russell <craig.russell@sun.com> wrote:
Hi Karan,
The UserObject pattern is intended for applications that need to
access some local state that is associated with the persistence
context. Any persistent object can navigate to its persistence manager
and access some application-specific data.
This turned out to be very useful in JDO, so much so that users asked
for finer-grained UserObject information: a Map of UserKey and
UserValue.
Craig
From: karan.malhi@gmail.com
Subject: user object with pm
Date: September 29, 2005 8:24:33 AM PDT
To: jdo-dev@db.apache.org
Reply-To: jdo-dev@db.apache.org, karan.malhi@gmail.com
Hi Craig,
What is the purpose of get/setUserObject in the pm api? What would be
the
use-case where i would use these methods?
--
Karan Malhi
--
Karan Malhi
Michael Bouschen Tech@Spree Engineering GmbH
mailto:mbo.tech@spree.de http://www.tech.spree.de/
Tel.:++49/30/235 520-33 Buelowstr. 66
Fax.:++49/30/2175 2012 D-10783 Berlin
--
Karan Malhi
--
Karan Malhi
|
|
|
|
|