Bugs item #882195, was opened at 2004-01-22 16:59
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=882195&group_id=22866

Category: JBossCMP
Group: v3.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Rafal Kedziorski (rafciom)
Assigned to: Nobody/Anonymous (nobody)
Summary: Too much SLQ queries ...

Initial Comment:
Hi,


I took a look in my mysql.log and don't undersrtand
something.


I have this code in my stateless session bean:


  private UserVO loginUser(Long user_id, String
remote_addr, String client_type, String retail_id)
       throws CreateException, PermissionException,
ParameterException, OMAException {
    logger.debug("loginUser() entered for " + user_id);


    // get user_id (1)
    Long user_id =
userLocal.getUserId(login_name.toLowerCase(), password);


    // check permission (2)
    checkAclPermission(user_id, AclHelper.OMA_ACCESS,
PermissionHelper.ACCESS);


    // get group_id for the given user_id (3)
    BusinessDatabase database =
ComponentManager.getBusinessDatabase();
    Integer system_group_id =
database.foundSystemGroupIdByUserId(user_id);


    if (system_group_id != null) {
      UserBeanLocal userLocal = userLocalHome.create();


      // login user
      UserVO user = userLocal.loginUser(user_id,
system_group_id, retail_id, client_type);


      // multi login
      // lock user
      if (! Config.getMultiLogin()) {
        userLocal.lockUser(user_id, null, remote_addr,
client_type);
      }


      return user;
    }
    else {
      logger.warn("loginUser() can't find
system_group_id for user_id=" + user_id);
      throw new
PermissionException("AccessFacadeBean::loginUser()
failed");
    }
  }


And this cann I see in mysql.log:


(1)
228 Query       SELECT t0_o.user_id FROM users t0_o
WHERE (t0_o.login_name = 'demo' AND t0_o.password =
'demo') FOR UPDATE


(???)
228 Query       SELECT class_id, mandant_id,
language_id, user_data_id, nickname, login_name,
password, status, creation_date, last_login_date FROM
users WHERE (user_id=15) FOR UPDATE
228 Query       SELECT class_id, mandant_id,
language_id, user_data_id, nickname, login_name,
password, status, creation_date, last_login_date FROM
users WHERE (user_id=15) FOR UPDATE
228 Query       SELECT class_id, mandant_id,
language_id, user_data_id, nickname, login_name,
password, status, creation_date, last_logindate FROM
users WHERE (user_id=15) FOR UPDATE
(???)


(2)
228 Query       select distinct u.user_id from
user_2_system_group u2sg, system_group sg, users u,
acl_entry ae, acl_entry_2_system_group ae2sg where
u.user_id = 15 and ae.acl_id = 1 and ae.permission_id =
1 and ae2sg.acl_entry_id = ae.acl_entry_id and
u2sg.system_group_id = sg.system_group_id and
ae2sg.system_group_id = sg.system_group_id and
u2sg.user_id = u.user_id and now() >= u2sg.valid_from
and (u2sg.valid_to is null or now() <= u2sg.valid_to)


(3)
228 Query       select sg.system_group_id from
user_2_system_group u2g, system_group sg where
u2g.user_id = 15 and u2g.system_group_id =
sg.system_group_id and now()>= u2g.valid_from and
(u2g.valid_to is null or now() <= u2g.valid_to)


...


I wondering, because I have no idea who is creating the
queries between (???). JBoss is sending the same query
more than one time.


The getUserID() method looks so:


  public Long getUserId(String login_name, String password)
       throws FinderException {
    if (logger.isDebugEnabled()) {
      logger.debug("getUserId('" + login_name + "', '"
+ password + "') entered");
    }


    // decode password
    password = Base64.decodeToString(password);
    UserEntityBeanLocal userLocal =
userEntityLocalHome.findByLoginNameAndPassword(login_name,
password);


    if (userLocal.getLogin_name().equals(login_name) &&
userLocal.getPassword().equals(password)) {
      return userLocal.getUser_id();
    }
    else {
      throw new FinderException("UserBean::getUserId()
can't find user");
    }
  }


The last if statement, is the reason for the three
queries between (???).
first geqry for: userLocal.getLogin_name()
second query for: userLocal.getPassword()
third query for: userLocal.getUser_id()


This behaviour I see to all our entity beans.


I'm working with the current JBoss version 3.2.4RC1
from cvs (daily updates).



Best Regards,
Rafal


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=882195&group_id=22866


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to