try this : public Object convert(Class type, Object value) {
if (log.isDebugEnabled()) { log.debug("entering 'convert' method"); } // for a null value, return null if (value == null) { return null; }else if ( value.getClass().isAssignableFrom(type) ){ return value; }else if ( ArrayList.class.isAssignableFrom(type) && ( value instanceof Collection ) ){ return new ArrayList((Collection)value); // List, Set, ollection -> ArrayList } else if ( type.isAssignableFrom( Collection.class ) && ( value instanceof Collection ) ) { try{ //most of collections implement this constructor Constructor constructor = type.getConstructor( new Class[]{ Collection.class } ); return constructor.newInstance( new Object[]{ value } ); }catch(Exception e){ //abstract ? log.debug(e); } } throw new ConversionException("Could not convert "+ value.getClass().getName() + " to " + type.getName() + "!"); } > I'm attempting to do this with ConvertUtils and BeanUtils.copyProperties: > > I have a bag defined in my mapping file and a List defined in my User. I > register the following Customer converter: > > > -----Original Message----- > From: Viktor Szathmary [mailto:[EMAIL PROTECTED] > Sent: Saturday, January 11, 2003 3:36 PM > To: Raible, Matt; [EMAIL PROTECTED] > Subject: Re: [Hibernate] List -> ArrayList > > > hi, > > On Sat, 11 Jan 2003 14:34:36 -0700, "Raible, Matt" > <[EMAIL PROTECTED]> said: > > I have a List in my User object that I want to convert to an ArrayList on > > my > > UserForm using BeanUtils.copyProperties. I can register a customer > > converter, but I need to translate cirrus.hibernate.collections.Bag into > > an > > ArrayList. I can't seem to find an Javadocs on this class - any ideas or > > suggestions? > > > > cirrus.hibernate.collections.Bag implements java.util.List, so you should > be able to copy it into an ArrayList using new ArrayList(bag)... > > regards, > viktor > -- > > [EMAIL PROTECTED] > > -- > http://fastmail.fm - Sent 0.000002 seconds ago > > > > ------------------------------------------------------- > This SF.NET email is sponsored by: > SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! > http://www.vasoftware.com > _______________________________________________ > hibernate-devel mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/hibernate-devel ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel