Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] PersistenceObjectInstantiationPolicy.buildNewInstance null'ing out all fields of an object regardless of fields set by default-constructor

På lørdag 21. september 2013 kl. 13:49:02, skrev Andreas Joseph Krogh <andreak@xxxxxxxxxxxx>:
På lørdag 21. september 2013 kl. 13:34:04, skrev Andreas Joseph Krogh <andreak@xxxxxxxxxxxx>:
Hi all.
 
Short version:
org.eclipse.persistence.internal.descriptors.PersistenceObjectInstantiationPolicy.buildNewInstance() calls _persistence_new which seems to return an object not initialized by the default-construcotor.
[snip]
 
The entity containing the @Embeddable in question is @Cacheable and removing the @Cacheable annotation from it makes this problem go away.
 
This is due to the following code:
 
org.eclipse.persistence.mappings.AggregateMapping.mergeIntoObject() line 668:
        if (targetAttributeValue == null || targetAttributeValue == sourceAttributeValue || !targetAttributeValue.getClass().equals(sourceAttributeValue.getClass())) {
 
Without caching, the targetAttributeValue "is not same as" sourceAttributeValue but when the entity is @Cacheable the memory-equals test passes and makes the code call buildNewMergeInstanceOf() which returns the invalid object (with all fields set to null).
 
However - I'd really like this entity to keep being @Cacheable so I'd appreciate a fix to this problem.
 
This seems related to this ussue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=292385
 
 
How can one argue that it will *ever* be OK to execute the weaved-in constructor instead of the default-constructor (if defined)?
 
Is there a way to disable execution of the weaved-in default-constructor only, or does one have to turn off internal weaving all together using eclipselink.weaving.internal=false?
 
One more thing; What optimizations does eclipselink.weaving.internal provide? I found this: http://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/p_weaving_internal.htm#BABJICDJ , but it didn't explain anything other than some internal optimization".
 
Thanks.
 
--
Andreas Joseph Krogh <andreak@xxxxxxxxxxxx>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
 

Back to the top