0 Replies Latest reply on Dec 26, 2001 11:57 AM by Alex

    PLEASE HELP: weird problem with entity beans and collections

    Alex Newbie

      Hi,

      how is everyone today?

      i have a really really weird problem.

      here is what is happening:

      i have show bean and a songFile bean( both entity beans )

      i have show table and songFile table and songs_in_the_show_table

      inside show bean i have a methods


      class ShowBean extends EntityBean{

      private Collection _collectionOfSongs;

      add( SongFileRemoteI songFile ){
      // simplified code
      _loadSongCollection();
      _collectionOfSongs.add( songFile );

      }


      remove( SongFileRemoteI songFile ){
      _loadSongCollection();
      _collectionOfSongs.remove( songFile );
      }

      private void addToDB( SongFileRemoteI songFile){
      // perform necessary db calls to make a add to table statement
      }

      private void remoteFromDB( SongFileRemoteI songFile){
      // perform necessary db calls to make a delete to table statement
      }

      private void _loadSongCollection(){
      // simplified code
      if ( _collectionOfSongs == null ){
      SongFileHome home = BeanBroker.getSongHome();
      Enumeration enum = home.findSongForShow( this.getID() );

      while ( enum.hasMoreElements() ){
      // ....
      _collectionOfSongs .add( enum.nextElement() );
      //....

      } // while

      } // if
      } // _loadSongCollection
      }

      now something really interesting happens.

      when i call remove, it removes the song correctly, from both the
      collection and the db, BUT as soon as i start the client again, it is
      as if i never removed it! it is again in the collection ( it is not in
      the db ).

      if i shutdown Jboss and start it again, collection would be of correct
      size.

      so what is going on? is there something that i am missing ? is this
      legal?

      let me know.

      alex k.