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

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

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(
at java.lang.Enum.valueOf(
at org.compass.core.converter.basic.EnumConverter.fromString(
at org.compass.core.converter.basic.AbstractBasicConverter.unmarshall(
at org.compass.core.converter.mapping.osem.ClassPropertyMappingConverter.unmarshall(
at org.compass.core.converter.mapping.osem.AbstractCollectionMappingConverter.unmarshall(
at org.compass.core.converter.mapping.osem.ClassMappingConverter.unmarshall(
at org.compass.core.marshall.DefaultMarshallingStrategy.unmarshall(
at org.compass.core.marshall.DefaultMarshallingStrategy.unmarshall(
at org.compass.core.impl.DefaultCompassSession.getByResource(
at org.compass.core.impl.DefaultCompassSession.getByResource(
at org.compass.core.impl.DefaultCompassSession.get(

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>

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.