You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@roller.apache.org by gregh <gr...@ricoh-uk.com> on 2007/03/29 14:49:23 UTC

RollerSession

hello,

wondering why the getAuthenticatedUser() was changed in RollerSession, as
this now seems an expensive db operation,  eg is called by the menu system
etc.

old version:
public UserData getAuthenticatedUser() {
        return authenticatedUser;
    }

3.0> version:
    public UserData getAuthenticatedUser() {
        
        UserData authenticUser = null;
        if(userId != null) {
            try {
                UserManager mgr =
RollerFactory.getRoller().getUserManager();
                authenticUser = mgr.getUser(userId);
            } catch (RollerException ex) {
                log.warn("Error looking up authenticated user "+userId, ex);
            }
        }
        
        return authenticUser;
    }

Cheers Greg.
-- 
View this message in context: http://www.nabble.com/RollerSession-tf3486135s12275.html#a9732510
Sent from the Roller - Dev mailing list archive at Nabble.com.


Re: RollerSession

Posted by gregh <gr...@ricoh-uk.com>.
OK, just was looking at the db processing (seemed to have increased since
2.1).


Allen Gilliland-3 wrote:
> 
> 
> 
> Dave wrote:
>> On 3/29/07, gregh <gr...@ricoh-uk.com> wrote:
>>> old version:
>>> public UserData getAuthenticatedUser() {
>>>         return authenticatedUser;
>>>     }
>>>
>>> 3.0> version:
>>>     public UserData getAuthenticatedUser() {
>>>
>>>         UserData authenticUser = null;
>>>         if(userId != null) {
>>>             try {
>>>                 UserManager mgr =
>>> RollerFactory.getRoller().getUserManager();
>>>                 authenticUser = mgr.getUser(userId);
>>>             } catch (RollerException ex) {
>>>                 log.warn("Error looking up authenticated user 
>>> "+userId, ex);
>>>             }
>>>         }
>>>
>>>         return authenticUser;
>>>     }
>> 
>> We probably made that change so that callers of getAuthenticatedUser()
>> get a O/R "managed" entity instead of a stale one.
> 
> Correct, the old code returned a detached object which can cause 
> problems when you are doing lazy fetching on objects.
> 
> -- Allen
> 
> 
>> 
>> - Dave
> 
> 

-- 
View this message in context: http://www.nabble.com/RollerSession-tf3486135s12275.html#a9789238
Sent from the Roller - Dev mailing list archive at Nabble.com.


Re: RollerSession

Posted by Allen Gilliland <al...@sun.com>.

Dave wrote:
> On 3/29/07, gregh <gr...@ricoh-uk.com> wrote:
>> old version:
>> public UserData getAuthenticatedUser() {
>>         return authenticatedUser;
>>     }
>>
>> 3.0> version:
>>     public UserData getAuthenticatedUser() {
>>
>>         UserData authenticUser = null;
>>         if(userId != null) {
>>             try {
>>                 UserManager mgr =
>> RollerFactory.getRoller().getUserManager();
>>                 authenticUser = mgr.getUser(userId);
>>             } catch (RollerException ex) {
>>                 log.warn("Error looking up authenticated user 
>> "+userId, ex);
>>             }
>>         }
>>
>>         return authenticUser;
>>     }
> 
> We probably made that change so that callers of getAuthenticatedUser()
> get a O/R "managed" entity instead of a stale one.

Correct, the old code returned a detached object which can cause 
problems when you are doing lazy fetching on objects.

-- Allen


> 
> - Dave

Re: RollerSession

Posted by Dave <sn...@gmail.com>.
On 3/29/07, gregh <gr...@ricoh-uk.com> wrote:
> old version:
> public UserData getAuthenticatedUser() {
>         return authenticatedUser;
>     }
>
> 3.0> version:
>     public UserData getAuthenticatedUser() {
>
>         UserData authenticUser = null;
>         if(userId != null) {
>             try {
>                 UserManager mgr =
> RollerFactory.getRoller().getUserManager();
>                 authenticUser = mgr.getUser(userId);
>             } catch (RollerException ex) {
>                 log.warn("Error looking up authenticated user "+userId, ex);
>             }
>         }
>
>         return authenticUser;
>     }

We probably made that change so that callers of getAuthenticatedUser()
get a O/R "managed" entity instead of a stale one.

- Dave