Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362318 - Custom ValueHolder POJO cannot be Serialized
Summary: Custom ValueHolder POJO cannot be Serialized
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard: submitted_patch
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-28 10:22 EDT by Amita Mehta CLA
Modified: 2022-06-09 10:32 EDT (History)
3 users (show)

See Also:


Attachments
Suggested patch (3.94 KB, patch)
2012-04-24 15:43 EDT, Andrei Ilitchev CLA
andrei.ilitchev: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Amita Mehta CLA 2011-10-28 10:22:31 EDT
Build Identifier: version: Eclipse Persistence Services - 2.1.2.v20101206-r8635

If a POJO has a 1-1 relationship using a custom ValueHolder then the Object cannot be serialized as the EclipseLink Class ContainerIndirectionPolicy in the package org.eclipse.persistence.internal.indirection has an attribute for Constructor which is not marked as transient.

the current code is
  private Constructor containerConstructor;
It should be 
  private transient Constructor containerConstructor;


Reproducible: Always

Steps to Reproduce:
1. create a POJO with 1-1 Valueholder indirection relationship
2. Start a UOW 
3. Register a new instance of the POJO 
4. Write the uow to a file
5. read it from the file
6. commit

Step 4 will cause an error -
java.lang.RuntimeException: Serialization error: java.io.NotSerializableException: java.lang.reflect.Constructor
Comment 1 David Minsky CLA 2011-11-03 16:26:47 EDT
For step 4, do you mean that the UnitOfWork itself should be serialized to a file? UnitOfWork is not Serializable.

Or serialize the clone that is returned from the UnitOfWork to a file?

Perhaps a code example to illustrate the problem?
Comment 2 Amita Mehta CLA 2011-11-07 16:14:02 EST
(In reply to comment #1)
> For step 4, do you mean that the UnitOfWork itself should be serialized to a
> file? UnitOfWork is not Serializable.
> 
> Or serialize the clone that is returned from the UnitOfWork to a file?
> 
> Perhaps a code example to illustrate the problem?

I mean  serialize the clone that is returned from the UnitOfWork to a file.
Comment 3 David Minsky CLA 2011-11-07 16:21:59 EST
(In reply to comment #2)
> (In reply to comment #1)
> > For step 4, do you mean that the UnitOfWork itself should be serialized to a
> > file? UnitOfWork is not Serializable.
> > 
> > Or serialize the clone that is returned from the UnitOfWork to a file?
> > 
> > Perhaps a code example to illustrate the problem?
> 
> I mean  serialize the clone that is returned from the UnitOfWork to a file.

I actually tried this with EclipseLink trunk and our testing framework (with ContainerIndirectionPolicy), and was not able to reproduce the problem.

Could you please submit a small testcase demonstrating the issue, as well as details of the JDK version and vendor you are utilizing.
Comment 4 Tom Ware CLA 2011-11-09 13:44:41 EST
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 5 Tom Ware CLA 2011-11-23 10:41:11 EST
Targetting for our 2.3.3 release - the next open release.

At the moment, based on some email discussions, I am assuming the goal is to serialize an instance of UnitOfWorkImpl that ocntains a mapping with a ContainerIndirectionPolicy.  More details about exactly what you are doing and what the behavior you expect from the UnitOfWork when it is serialized will help ensure any test cases we build test your scenario.
Comment 6 Andrei Ilitchev CLA 2012-04-24 15:43:28 EDT
Created attachment 214493 [details]
Suggested patch

Changing ContainerIndirectionPolicy's containerConstructor field to be transient - as was suggested by the filer.
Added ContainerIndirectionPolicySerializationTest to eclipselink.core.test
In TestingBrowser it's found under: LRG - FeatureTestModel - MiscellaneousTests
Comment 7 Andrei Ilitchev CLA 2012-04-24 16:07:42 EDT
The patch checked into both trunk (2.4) and 2.3.3.
Comment 8 Eclipse Webmaster CLA 2022-06-09 10:32:37 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink