Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Changes in mutable objects not detected
Changes in mutable objects not detected [message #390504] Mon, 20 July 2009 07:50 Go to next message
Sabine Heider is currently offline Sabine HeiderFriend
Messages: 8
Registered: July 2009
Junior Member
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
Re: Changes in mutable objects not detected [message #390505 is a reply to message #390504] Mon, 20 July 2009 08:56 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
How do these changes occur? Are the mutable objects public and being changed directly? 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.)


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
Re: Changes in mutable objects not detected [message #390506 is a reply to message #390505] Mon, 20 July 2009 12:54 Go to previous messageGo to next message
Sabine Heider is currently offline Sabine HeiderFriend
Messages: 8
Registered: July 2009
Junior Member
Hi!

> 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
Re: Changes in mutable objects not detected [message #390508 is a reply to message #390506] Mon, 20 July 2009 14:29 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
> 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.

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
Re: Changes in mutable objects not detected [message #390509 is a reply to message #390508] Mon, 20 July 2009 15:46 Go to previous messageGo to next message
Sabine Heider is currently offline Sabine HeiderFriend
Messages: 8
Registered: July 2009
Junior Member
Hi!

> 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
Re: Changes in mutable objects not detected [message #390598 is a reply to message #390509] Mon, 27 July 2009 15:31 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

For dates you can set the persistence property,

"eclipselink.temporal.mutable"="true"

See,
http://www.eclipse.org/eclipselink/api/1.1.1/constant-values .html#org.eclipse.persistence.config.PersistenceUnitProperti es.TEMPORAL_MUTABLE

For the byte array you can mark the mapping as mutable using @Mutable.

---
James


James : Wiki : Book : Blog : Twitter
Re: Changes in mutable objects not detected [message #467871 is a reply to message #390598] Mon, 03 August 2009 09:06 Go to previous message
Sabine Heider is currently offline Sabine HeiderFriend
Messages: 8
Registered: July 2009
Junior Member
Hi James!

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
Previous Topic:Eclipselink without connection pool
Next Topic:Alias for identifier have more than 30 char. ora-00972 identifier too long
Goto Forum:
  


Current Time: Thu Nov 27 18:53:25 GMT 2014

Powered by FUDForum. Page generated in 0.03366 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software