Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Left Fetch associated subclass attribute in a NamedQuery

Hi Mario,

Your problem is that p.roles maps to Role and not Employee and therefore does not have an attribute called bankaccount.

We have an open enhancement request for this kind of thing and there is some discussion in the bug about how you might achieve this kind of functionality.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=259266

I would like to suggest, however, that this kind of a query is atypical of most JPA applications and I am surprised you want to include it in a performance comparison.

-Tom

Mario Sandro Schwarz wrote:
Hi everbody,

I am writing my bachelor thesis about evaluating jpa persistence
providers and have a use-case to measure performance of and urgently
need help because it is not working.

I have a class Partner with a one-to-many association to class Address
and also a one-to-many associaton to the abstract class Role. I have two
subtypes of Role which are Applicant and Employee. The used inheritance
strategy is single-table (discriminator column).
An Employee has an one-to-one association to class BankAccount which is
stored in a separate table.

Now I want to eager retrieve all Partners with all Addresses and Roles
and BankAccount in a NamedQuery. I tried the following, because it did
work with Hibernate:

@NamedQuery(name="getAllPartners" value = "SELECT p from Partner p",
hints = {
   @QueryHint(name=QueryHints.LEFT_FETCH p.addresses),
   @QueryHint(name=QueryHints.LEFT_FETCH p.roles),
   @QueryHint(QueryHints.LEFT_FETCH p.roles.bankaccount)}
)

With EclipseLink I got an exception like "navigating non-existant
association p.roles.bankaccount"... or so while trying to deploy the
.ear.

I absolutely do understand why I get the exception, but I have no
idea how to workaround.

Every help/suggestion is more than appreciated.

Mario

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


Back to the top