Monday, October 21, 2013

EclipseLink bug with @MappedSuperclass

Today I fought through an issue with EclipseLink / JPA. We are upgrading from TopLink (*really, really old*) to EclipseLink, but the version of EclipseLink we were using was 2.0.2, based on another project in our stack.

We use static weaving in our JPA projects. For some reason, any class marked with @MappedSuperclass wouldn't get weaved correctly, leading to an error similar to this:

Exception Description: The method [setXXXXXXX] on the object is throwing an exception. Argument: [1.18] Internal Exception: java.lang.reflect.InvocationTargetException Target Invocation Exception: java.lang.NoSuchMethodError: com.blah.MyClass._persistence_checkFetched(Ljava/lang/String;)V Mapping: org.eclipse.persistence.mappings.DirectToFieldMapping[myFieldInClass-->MYTABLE.MYFIELDINCLASS] Descriptor: RelationalDescriptor(com.blah.MyClass --> [DatabaseTable(MYTABLE.MYFIELDINCLASS)])] with root cause java.lang.NoSuchMethodError: com.blah.MyClass._persistence_checkFetched(Ljava/lang/String;)V

The method it was trying to find was the "getter" for that field - which did, in fact, exist! I searched through a ton of forums with no help, so I finally decided to get the latest EclipseLink jar version (2.5.1 as of this post) and latest JPA spec jar (2.1.0). Voila...everything works perfectly. So, somewhere in between EclipseLink 2.0.2 and 2.5.1 this issue/bug got fixed.

No comments:

Post a Comment