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

Key: CMP-314
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Shay Banon
Reporter: Dan Allen
Votes: 0
Watchers: 0
Operations

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

Add the ability to control the converter for managed id

Created: 06/Nov/06 03:59 PM   Updated: 07/Nov/06 06:18 PM
Component/s: Compass::Core
Affects Version/s: 1.1 M2
Fix Version/s: 1.1 M3

Environment: java 5 (ibm-sdk) on linux i386


 Description  « Hide
If a converter is specified on the <id> element in the compass mapping file, it is not honored (i.e. it doesn't work). However, if the annotation @SearchableId is used instead, the converter is accepted. The problem is identified below.

In the MappingProcessorUtils, the method addInternalId uses the following logic (around line 100):

internalIdMapping.setConverter(classPropertyMapping.getManagedIdConverter());
internalIdMapping.setConverterName(classPropertyMapping.getManagedIdConverterName());

at this point, the classPropertyMapping DOES have a reference to the converter specified in the mapping, but it is not passing it on to the internalIdMapping object. Rather, it is referencing the managedIdConverter, which is null at this point.

The annotation processor is much more thorough, and it correctly binds both the converter and managedId converter to the converted specified in the @SearchableId annotation. This can be found around line 482 in AnnotationsMappingBinding.

I discovered this problem because I use the generic java.io.Serializable interface for my artificial ids, and therefore a converter is required to extract the underlying value. For now I am going to stick to using annotations, but I figured the support should be the same for both methods. A unit test could easily guarantee that this bug isn't reintroduced.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Shay Banon added a comment - 06/Nov/06 06:57 PM
There is a difference between the way the annotations work and the way the xml mapping works. In annotations, the converter attribute applies to the generated meta-data, where in xml, the converter is the converter of the property (and not the meta-data).

The thing that is missing is the ability to define the converter for the managed id created in the xml mappings, which later on will initialize the ClassPropertyMapping#setManagedIdConverterName (which will then will be properly used in teh MappingProcessorUtils.

So, the suggestion is to add: managed-id-converter to the id and property elements in the xml mappings.


Dan Allen added a comment - 06/Nov/06 10:46 PM
I see, that makes sense. I figured that there was something missing as I could not see a way via XML that the managed converter was to be assigned. I will look forward to this feature in M3!

Shay Banon added a comment - 07/Nov/06 06:18 PM
Added the ability to define managed-id-converter in xml mapping for both id and property elements.