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

Hello Andreas,

The weaved performance enhancement is specifically designed for your application, as it is extra processing to assign the none value and then again assign the value from the database. I believe it is only a problem because your converter is run before the value gets set from the database.

One solution would be to order the mappings so that the value required is set before the values that have converters that might use it. This would be done with a descriptor customizer that used the DatabaseMapping.setWeight(Integer) api to increase the weight value on mappings with converters:
http://www.eclipse.org/eclipselink/api/2.3/org/eclipse/persistence/mappings/DatabaseMapping.html#setWeight(java.lang.Integer)

An other is to just turn off the internal weaving optimizations since you do not want to bypass the default constructor. The only way to know the cost though is to do performance testing.

Best Regards,
Chris

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 <mailto: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