Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsChanges in mutable objects not detected
https://www.eclipse.org/forums/index.php/mv/msg/126981/390504/#msg_390504
I am currently porting an application to EclipseLink. While doing so, I
faced the issue that changes inside a byte array (i.e. changes to the
contents, not the array itself) are not detected and thus not
synchronized to the database. I did some more testing and realized that
this affects all kind of mutable objects including the date/time related
data types.
Is there any way to configure EclipseLink so that it also detects
changes inside mutable objects?
Thanks and best regards,
Sabine]]>Sabine Heider2009-07-20T07:50:41-00:00Re: Changes in mutable objects not detected
https://www.eclipse.org/forums/index.php/mv/msg/126981/390505/#msg_390505
Sabine Heider wrote:
> Hi,
>
> I am currently porting an application to EclipseLink. While doing so, I
> faced the issue that changes inside a byte array (i.e. changes to the
> contents, not the array itself) are not detected and thus not
> synchronized to the database. I did some more testing and realized that
> this affects all kind of mutable objects including the date/time related
> data types.
>
> Is there any way to configure EclipseLink so that it also detects
> changes inside mutable objects?
>
> Thanks and best regards,
> Sabine]]>Tom Eugelink2009-07-20T08:56:53-00:00Re: Changes in mutable objects not detected
https://www.eclipse.org/forums/index.php/mv/msg/126981/390506/#msg_390506
> How do these changes occur? Are the mutable objects public and being
> changed directly?
Almost. The application uses a getter method to get a reference to a
byte array. The application then uses this reference to modify the byte
array directly without calling a setter method afterwards.
> Because if you were using a setter (thus overwriting
> the object) then there should be no problem. (This is how I do it for
> e.g. Calendar.)
Yes, that works, I'm not having problems with those parts. But the
application I'm trying to port also changes the arrays directly, not via
the setters. I couldn't find anything in the JPA spec that would
disallow this kind of access, so I would expect that EclipseLink is able
to detect the change somehow.
Best regards,
Sabine]]>Sabine Heider2009-07-20T12:54:04-00:00Re: Changes in mutable objects not detected
https://www.eclipse.org/forums/index.php/mv/msg/126981/390508/#msg_390508
> byte array. The application then uses this reference to modify the byte
> array directly without calling a setter method afterwards.
I don't know the spec well enough to comment, but Eclipelink would need to do a post-and-pre comparison to detect changes because and array does not have a listener mechanism for that. And that will most certainly not increase the speed.
Tom]]>Tom Eugelink2009-07-20T14:29:37-00:00Re: Changes in mutable objects not detected
https://www.eclipse.org/forums/index.php/mv/msg/126981/390509/#msg_390509
> I don't know the spec well enough to comment, but Eclipelink would need
> to do a post-and-pre comparison to detect changes because and array does
> not have a listener mechanism for that. And that will most certainly not
> increase the speed.
I'm aware of the drawbacks and I can understand that EclipseLink might
not want to provide that sort of change tracking per default. But maybe
there is a switch where I can enable it?
Otherwise it would be really a nasty porting issue, as the applications
have been developed under the assumption that changes in mutable objects
are detected.
Best regards,
Sabine]]>Sabine Heider2009-07-20T15:46:30-00:00Re: Changes in mutable objects not detected
https://www.eclipse.org/forums/index.php/mv/msg/126981/390598/#msg_390598
"eclipselink.temporal.mutable"="true"
For the byte array you can mark the mapping as mutable using @Mutable.
---
James]]>James Sutherland2009-07-27T15:31:44-00:00Re: Changes in mutable objects not detected
https://www.eclipse.org/forums/index.php/mv/msg/126981/467871/#msg_467871
You wrote:
> For dates you can set the persistence property,
>
> "eclipselink.temporal.mutable"="true"
Thanks, that's what I was looking for - and it works as expected.
> For the byte array you can mark the mapping as mutable using @Mutable.
I tried this out and it worked for a byte[] array. However, I tested it
also on the other array types that are supported according to the JPA
spec, i.e. Byte[], char[] and Character[], and it failed on all of them.
That's not limiting me, actually, as I have only a use case for the
byte[] array (I haven't seen the other array types in real-life
applications so far). Still, I wanted to mention it.
It would be much nicer, though, to have a global switch like the one for
the temporal types. It would be more consistent and would reduce the
effort when porting _many_ applications.
Best regards,
Sabine]]>Sabine Heider2009-08-03T09:06:37-00:00