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

Chris Delahunt just replied with some good ways to work around this issue.

Turning off our internal weaving will disable use of _persistence_new() as you have remarked before.  You asked about what other consequences it will have...  It will remove some optimizations we add to your code that allow us to avoid using reflection to access the object.  These things include a more efficient clone mechanism, a way to get/set instance variables without reflection and the constructor optimization.

Your other option, as you know, is to do a null check.

-Tom

On 23/09/2013 11:11 AM, Andreas Joseph Krogh wrote:
På mandag 23. september 2013 kl. 16:48:10, skrev Tom Ware <tom.ware@xxxxxxxxxx>:
Hi Andreas,

  The bug you are listing refers to attributes that are not mapped.  It appears you are experiencing this issue with attributes that are mapped.  The idea is that we use this _persistence_new() method to get a more efficient creation of the object and then use our knowledge of the mapped attributes to copy them or populate them.  For transient fields, we cannot do that - hence the bug and its fix.

  How are the converters you are seeing NPEs in defined?   Do they check attributes other than the ones they are converting in their conversion code?  Can you provide a sample including a stack trace, the converter, the object being converted and any relevant mappings.
 
In my specific case I'm having a field mapped as (in Scala-code) Option[DateTime] and have a converter for it. This field is never null, but rather None (for not set) and Some(DateTime) if set. The constructor sets the field to None and there's no way one programmatically can set the field to null. Therefore I don't check for null in my converter (or any other place using that Option-field, which is the whole purpose of using Option), because it's either None or Some, except in this particular case where _persistence_new() is used which bypasses any initialization-code.
 
Is there a way to prevent EL from using _persistence_new() ?
 
It will take some time to produce an example showing this as I'm working towards a deadline, but I'll try.
 
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
 


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top