5 Replies Latest reply on Jul 14, 2004 10:31 AM by Joern

    strange generated query by calling get-method

    Joern Newbie

      Hi,

      i dont know if this is a strange behavior, maybe all is fine.

      i have a simple cmp bean(Minfo), one table. i get my bean this way:

       Collection c = getHome().findByName(fileName);
       Object[] obj = c.toArray();
       for(int j = 0; j < obj.length; j++) {
       Minfo info = null;
       if (obj[j] instanceof Minfo) info = (Minfo)obj[j];
       System.out.println(info.getId());
       }
      


      Every time info.getId() is called, jboss makes a SQL-Query, six calls of getId() produce this in my server.log:

      Executing SQL: SELECT id,filename, extension, disk, size, id3title, id3artist, id3length, id3bitrate FROM minfo WHERE (id=?) OR (id=?) OR (id=?) OR (id=?) OR (id=?) OR (id=?)
      Executing SQL: SELECT id,filename, extension, disk, size, id3title, id3artist, id3length, id3bitrate FROM minfo WHERE (id=?) OR (id=?) OR (id=?) OR (id=?) OR (id=?)
      Executing SQL: SELECT id,filename, extension, disk, size, id3title, id3artist, id3length, id3bitrate FROM minfo WHERE (id=?) OR (id=?) OR (id=?) OR (id=?)
      Executing SQL: SELECT id,filename, extension, disk, size, id3title, id3artist, id3length, id3bitrate FROM minfo WHERE (id=?) OR (id=?) OR (id=?)
      Executing SQL: SELECT id,filename, extension, disk, size, id3title, id3artist, id3length, id3bitrate FROM minfo WHERE (id=?) OR (id=?)
      Executing SQL: SELECT filename, extension, disk, size, id3title, id3artist, id3length, id3bitrate FROM minfo WHERE (id=?)
      



      every one more call of getId() is one less "OR (id=?) " in the sql-query. i ask this because i have performance problems if i call get-methods.

      thanks a lot