Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] PROGRESS: Sv: Re: Value of DiscriminatorValue not persisted

Andreas,

Did you try removing the abstract declaration on EmailPart?

Cheers,
Guy

On 20/08/2013 7:53 AM, Andreas Joseph Krogh wrote:
På tirsdag 20. august 2013 kl. 11:44:10, skrev Andreas Joseph Krogh <andreak@xxxxxxxxxxxx>:
På mandag 19. august 2013 kl. 21:55:29, skrev Andreas Joseph Krogh <andreak@xxxxxxxxxxxx>:
På mandag 19. august 2013 kl. 17:51:32, skrev Guy Pelletier <guy.pelletier@xxxxxxxxxx>:
Andreas,

No you don't have to map the discriminator column explicitly. The model looks to be defined correctly, so its very odd that it would be null.

What does your execution code look like? I'm not well versed in Scala but perhaps the discriminator value is being 'lost' somewhere along the way?
 
Hm, strange, persisting the same type other places works. Do you have any pointers to where the value is retreived from when generating the INSERT-query so I can debug and step thru it to se what's going on?
 
Thanks.
[snip]
 
I've tracked down som info:
 
ObjectBuilder:1560
public AbstractRecord buildRow(AbstractRecord databaseRow, Object object, AbstractSession session, WriteType writeType) {
    // PERF: Avoid synchronized enumerator as is concurrency bottleneck.
    List mappings = this.descriptor.getMappings();
    int mappingsSize = mappings.size();
    for (int index = 0; index < mappingsSize; index++) {
        DatabaseMapping mapping = (DatabaseMapping)mappings.get(index);
        mapping.writeFromObjectIntoRow(object, databaseRow, session, writeType);
    }

    // If this descriptor is involved in inheritance add the class type.
    if (this.descriptor.hasInheritance()) {
        this.descriptor.getInheritancePolicy().addClassIndicatorFieldToRow(databaseRow);
    }
 
My class-hierarchy is:
 
EmailPart (abstract)
|--> EmailSinglePart - @DiscriminatorValue("singlepart")
 
The strange thing here is that the value of this.descriptor.javaClass  is the abstract EmailPart.class and not EmailSinglePart.class in this special case where it's not working. Other places in the application the value is EmainSinglePart and then it works correctly.
 
This results in a null-value being set for the discriminator-column, by the marked addClassIndicatorFieldToRow() method, because it uses the class-object returned from descriptor.javaClass to lookup in the Map descriptor.inheritancePolicy.classIndicatorMapping, which does not hold an entry for the abstract parent-class.
 
Digging for more info on how this is possible.
 
Comments are welcome:-)
 
--
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

--

Oracle
Guy Pelletier

ORACLE Canada, 45 O'Connor Street Suite 400 Ottawa, Ontario Canada K1P 1A4

Green
            Oracle Oracle is committed to developing practices and products that help protect the environment


Back to the top