1 Reply Latest reply on Oct 22, 2002 1:39 AM by Joel Vogt

    Can  my entity beans implement java.lang.Comparable?

    Ryan Boder Newbie

      I would like to have the remote interface of my entity beans extend java.util.Collection, so that when I use them, I can call sort on a Collection of them.

      The problem is that the methods in the Comparable interface do not throw RemoteException, so when I have my remote interface extend Comparable, it makes my bean an illegal type for RMI.

      How is this usually handled? Is there a general way to have remote interfaces extend J2SE interfaces and still have them be legal RMI return types?


        • 1. Re: Can  my entity beans implement java.lang.Comparable?
          Joel Vogt Master

          Do you need to run different sorts? If not you could specify your order in the finder for this collection. You could also specify a couple of finders if you did need different sorting.

          Otherwise you should still be able to use your beans in a comparator class. Just don't call compareTo() on them, you will have to do something like bean.getName().compareTo(bean.getName()). It'll work the same.

          Another solution is to extract the data from your remotes with a getValueObjectMethod(). These guys can then be stored in a collection and implement Comparable.