Changes from EntityListeners not propagated in commit [message #879136] |
Wed, 30 May 2012 15:29 |
Martin Ledvinka Messages: 3 Registered: April 2011 |
Junior Member |
|
|
Hi all,
I have a JPA 2 PreUpdate/PrePersist entity listener class, in which I trim too long strings to avoid database exception. Since I wanted this to work for many classes, I created an annotation and in the listener, I search for fields annotated with this annotation and trim their values using the Reflection API.
The problem is, when I run unit tests checking this functionality, they pass, but when I use it on our Jetty server (version 6.1.24), the values are not trimmed (the listener gets called, the value is trimmed, but Eclipselink ignores this change) and our database throws truncation exceptions.
I tried using direct field set and invoking setter methods as well because I found somewhere that since Eclipselink uses proxies for entities, direct field set might not be recorded.
Is there any way how to get over this problem? Could Eclipselink event listeners help in this situation? I'm using Eclipselink version 2.3.2.v20111125-r10461.
Thanks in advance
Martin
|
|
|
|
Re: Changes from EntityListeners not propagated in commit [message #881217 is a reply to message #879778] |
Mon, 04 June 2012 06:53 |
Martin Ledvinka Messages: 3 Registered: April 2011 |
Junior Member |
|
|
Hi Chris,
thank you for the reply. You're correct about the weaving, I'm using dynamic weaving in Jetty. I tried using reflective calls, but without success.
As for the environment differences, the test environment was using JUnit 4 (called by ant), but there was no weaving in the tests. So this might have been the key difference. The rest of properties was the same, since the tests and Jetty were running on the same machine.
However, I managed to fix the issue by using Eclipselink's DescriptorEvents which work perfectly. Anyway, thanks for your help.
Regards,
Martin
|
|
|
Powered by
FUDForum. Page generated in 5.03890 seconds