Menu

Custom collections

Help
2006-10-02
2013-04-25
  • Sheldon Young

    Sheldon Young - 2006-10-02

    I have a case where I have a collection MySet that extends HashSet and I believe it's causing an IllegalArgumentException.  For example:

    public class MySet extend HashSet {
    }

    public class Foo {
       private MySet collection
       public MySet getCollection()
       public void setCollection(MySet collection)
    }

    The above construct will cause an IllegalArgumentException in BeanPopulator.invokeMethodAsPrivileged.  It appears to be attempting to invoke the set method of Foo it is passing a HashSet as the argument instead of an instance of MySet.

    Any ideas about how to resolve or work around this?

     
    • Joe D. Velopar

      Joe D. Velopar - 2006-10-03

      Hi Sheldon,

      Can you show me the source code for MySet, so I can construct a test to reproduce the problem ?

      Thanks!

       
    • Joe D. Velopar

      Joe D. Velopar - 2006-10-03

      I managed to reproduce the problem.  The failure is due to the following code in HibernateBeanT4ransformer#createToCollection:
      ...
          if (from instanceof Set)
              return new HashSet<Object>();
      ...

      The code is trying to avoid those proxy instances usually associated with a Hibernate persistent object.

      I am looking into ways of fixing this...

       
    • Joe D. Velopar

      Joe D. Velopar - 2006-10-03

      Hi Sheldon,

      This problem should now be fixed in release 3.2.6.  Please let me know if this works for you.

       
      • Sheldon Young

        Sheldon Young - 2006-10-03

        Thank you very much for the rapid response Joe!  I'll give it a whirl.

         
      • Sheldon Young

        Sheldon Young - 2006-10-05

        The change works fine.  Thanks again.

         

Log in to post a comment.