SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye
Issue Details (XML | Word | Printable)

Key: CMP-384
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Shay Banon
Reporter: David Hay
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Compass

EnumConverter does not work for collection of enums

Created: 09/Apr/07 11:56 AM   Updated: 09/Apr/07 11:57 AM
Component/s: Compass::Core
Affects Version/s: 1.1 GA
Fix Version/s: None


 Description  « Hide
I have a class that stores a collection of Java 5 enums. However, when trying to unmarshall the object, I get the following error:

ava.lang.IllegalArgumentException: java.util.Collection is not an enum type
at java.lang.Class.enumConstantDirectory(Class.java:2895)
at java.lang.Enum.valueOf(Enum.java:187)
at org.compass.core.converter.basic.EnumConverter.fromString(EnumConverter.java:31)
at org.compass.core.converter.basic.AbstractBasicConverter.unmarshall(AbstractBasicConverter.java:84)
at org.compass.core.converter.mapping.osem.ClassPropertyMappingConverter.unmarshall(ClassPropertyMappingConverter.java:61)
at org.compass.core.converter.mapping.osem.AbstractCollectionMappingConverter.unmarshall(AbstractCollectionMappingConverter.java:139)
at org.compass.core.converter.mapping.osem.ClassMappingConverter.unmarshall(ClassMappingConverter.java:236)
at org.compass.core.marshall.DefaultMarshallingStrategy.unmarshall(DefaultMarshallingStrategy.java:153)
at org.compass.core.marshall.DefaultMarshallingStrategy.unmarshall(DefaultMarshallingStrategy.java:145)
at org.compass.core.impl.DefaultCompassSession.getByResource(DefaultCompassSession.java:229)
at org.compass.core.impl.DefaultCompassSession.getByResource(DefaultCompassSession.java:218)
at org.compass.core.impl.DefaultCompassSession.get(DefaultCompassSession.java:198)

My class is defined something like this:

public class MyClass {
Collection<MyEnum> getSomething() { ... }
void setSomething(Collection<MyEnum> values) { ... }
}

My mapping file (.cpm.xml) has this in the mapping for this class:

<property name="something">
<meta-data index="un_tokenized" >something</meta-data>
</property>

It appears that the EnumConverter is relying on the return type of the class getter method, instead of the enum type defined using generics.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
David Hay added a comment - 09/Apr/07 11:57 AM
I was able to work around the problem by using a custom converter that has the correct enum type defined in the member variables.