Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

ForceMappingConfigurationStrategy doesn't pick up the identity field #23

Open
ustramooner opened this Issue · 0 comments

1 participant

@ustramooner

The library doesn't correctly identify the identity field for a generated JPA class. The JpaMappingConfigurationStrategy seems to looks up the @Id annotation based on the field on line ~130 of this class. I'm not sure why the JpaMappingConfigurationStrategy is looking up the annotations against the fields instead of using a bean wrapper, but as a result it doesn't see the annotations (@Id is important in my case). My hack is to override the JpaMappingConfigurationStrategy (and change the provider in ForceMappingContext) and add this method:

public PersistentProperty getIdentity(Class javaClass, MappingContext context) {
    if ( !identities.containsKey(javaClass) ){
        final ClassPropertyFetcher cpf = ClassPropertyFetcher.forClass(javaClass);
        PropertyDescriptor propertyDescriptor = cpf.getPropertyDescriptor("id");
        final PersistentEntity owner = context.getPersistentEntity(javaClass.getName());
        identities.put(javaClass, propertyFactory.createIdentity(owner, context, propertyDescriptor));
    }
    return identities.get(javaClass);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.