Problem with @OrderColumn when using EclipseLink

In JPA 2.0 the annotation @OrderColumn provides support for persisting the order (or rather the index) of a list. Unfortunately this feature is buggy in some versions of EclipseLink 2.* which is the JPA 2.0 Reference Implementation.

The following issue in EclipseLink’s bug tracker describes the wrong behaviour as well as the circumstances leading to the problem: @OrderColumn does not work when list read in through uow

To summarise it in short: If the shared cache is disabled (property “eclipselink.cache.shared.default” set to “false”, which is the default) the ordered list is not populated correctly on retrieval from the database (meaning not populated according to the value in the order column).

A bugfix is available in version 2.0.3 (current nightly build) and 2.1.2 (released version) and these versions should be used if the ordering annotation is needed. If an earlier version of EclipseLink is required the shared cache should be enabled or the provided patch could be applied manually.

No offense meant, of course bugs happen to all of us :).

Short URL for this post: http://wp.me/p4nxik-vv
This entry was posted in Did you know?, Java EE, Java Persistence and tagged , , . Bookmark the permalink.

Leave a Reply