[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
[eclipselink-dev] Question about EmbeddedAccessor#processEmbeddableClass()
|
- From: Mark Struberg <struberg@xxxxxxxx>
- Date: Wed, 12 Nov 2008 11:04:21 +0000 (GMT)
- Delivered-to: eclipselink-dev@eclipse.org
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=b517M9YOrzQTs4YAvnic7imAaX3ba2G+SA5YdwI0rK9DhmGAdB9sAv5QCAPuNEQKmxqvjW5+3EzdP2xiDNDEThm2FeCa6PiIToT7SNQMSPj9V8Qi+4LnPEOYCrlAJLioimPZyfEriEs6MuwJurZbFllhiopLcTV7yma1fRap4pc=;
Hi!
I've read through the eclipselink sources and like to add a few features.
Generally, I'd to say that it is a really well done and _very_ readable source! I did look at the sources for only 2 evenings now (and I really enjoyed digging into it), so don't be rude if I completely misinterpreted/not understood something yet :)
There's a point in the EmbeddedAccesor which I do not understand:
In the function processEmbeddableClass(), a 'cached' EmbeddedAccessor instance is retrieved (line # 299)
EmbeddableAccessor accessor = getProject().getEmbeddableAccessor(getReferenceClassName());
So I'll get the same EmbeddableAccessor instance for EVERY embedding of the same class.
A bit later in the source (line # 349), this EmbeddableAccessor will be filled with the OwningDescriptor:
accessor.setOwningDescriptor(getOwningDescriptor());
BUT: imho the owning descriptor may be different for each @Embedded !?
In praxis this means, that the EmbeddableAccessor always points to the Table-Descriptor of the 'first' occurence (which one this ever may be -> random generator?), and the other ones may simply contain wrong values.
My example:
@Embeddable
public class Price {
private BigDecimal amount;
private String currency;
}
@Entity
public class Purchase {
@Id
@GeneratedValue
private int id;
@Embedded(prefix = "N_")
private Price netPrice;
@Embedded(prefix = "G_")
private Price grossPrice;
}
@Entity
public class OtherUseOfPrice {
@Id
@GeneratedValue
private int id;
@Embedded(prefix = "O_")
private Price otherPrice;
}
In the debugger I got the following memory addresses:
O_ id=40 accessor=98 getowningDescriptor()= 45
N_ id=101 accessor=98 getowningDescriptor()= 102
G_ id=116 accessor=98 getowningDescriptor()= 102
And as expected, the accessor of the embeddings of netPrice (N_) and grossPrice (G_) point to the wrong m_owningDescriptor 45 instead of the correct 102
Does this have any impact on the result? If not, we also could remove the owningDescriptor from the EmbeddableAccessor, otherwise it may be a source of problems, isn't?