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:
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 instanceof Set && type == Set.class) { return new ArrayList((Set) value); } else if (value instanceof List && type == List.class) { return new ArrayList((List) value); } else { throw new ConversionException("Could not convert "+value+" to ArrayList!"); } } When I call BeanUtils.copyProperties(userForm, user), I get the following error - I'm assuming for a property that is a List of longs. [junit] Testcase: testGetForm(com.comcast.cable.dmc.itd.cct.webapp.service.ChangeRequestManage rI mplTest): Caused an ERROR [junit] Could not convert [EMAIL PROTECTED] to ArrayList! [junit] org.apache.commons.beanutils.ConversionException: Could not convert cirrus.hibernate.col [EMAIL PROTECTED] to ArrayList! [junit] at com.comcast.cable.dmc.itd.cct.common.util.ListConverter.convert(ListConverte r.jav a:48) [junit] at org.apache.commons.beanutils.BeanUtils.copyProperty(BeanUtils.java:362) [junit] at org.apache.commons.beanutils.BeanUtils.copyProperties(BeanUtils.java:264) [junit] at com.comcast.cable.dmc.itd.cct.webapp.service.ChangeRequestManagerImpl.getFor m(Cha ngeRequestManagerImpl.java:219) [junit] at com.comcast.cable.dmc.itd.cct.webapp.service.ChangeRequestManagerImplTest.te stGet Form(ChangeRequestManagerImplTest.java:139) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java :25) -----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