Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Uregntly need help for thesis: Batch reading of collection with lazy OneToOne relation

Hello Tom,

unfortunately the problem is that not the role has the "bankaccount". Just the specific role "employee" does. I remember you replying to my last post telling me that there is a an open enhancement request for this kind of thing (Downcasting in queries). Thanks a lot for the try to help though.

Anyone got any other suggestions that might help?

Mario


Tom Ware schrieb:
EclipseLink allows multi-level fetch joins and batch reading. Have you tried any of these?

http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Join_Fetch

(something like @QueryHint(name = QueryHints.LEFT_FETCH, value = "p.roles.bankAccount")

http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Batch
(something like @QueryHint(name=QueryHints.BATCH, value="p.roles.bankAccount");

Mario Schwarz wrote:
Hi everybody.

I have to do a run time comparison on Eclipselink and Hibernate for my Bachelor Thesis. I really have an urgent problem, I don't get BatchReading to work correctly.

I implemented use-case based test cases that call specific methods of a SessionBean called "PartnerService". PartnerService acts as a Facade and manages the transactions (@TransactionAttributeType.REQUIRED). It calls methods on a DAO called "PartnerDAO". PartnerDAO requires an open transaction (@TransactionAttributeType.MANDATORY)

I have the following NamedQuery which retrieves me all partners with their addresses and their roles:

@NamedQuery(name = "getAllPartnersWithAdressesAndRoles", query = "SELECT p FROM Partner as p ", hints = {
@QueryHint(name = QueryHints.LEFT_FETCH, value = "p.roles"),
@QueryHint(name = QueryHints.LEFT_FETCH, value = "p.addresses"),
@QueryHint(name = QueryHints.JDBC_FETCH_SIZE, value = "1000") })

Now I also want to retrieve the bank account of the specific role "employee" which is a unidirectional onetoone-relation. In the PartnerDAO-method I do the following:

public List<Partner> findAllPartners() {
  Query q = em.createNamedQuery("getAllPartnersWithAdressesAndRoles");
  // results in just 1 SELECTs
  List<Partner> l = q.getResultList();
  for (Partner partner : l) {
    for (Role role : partner.getRoles()) {
      // results in l.size() SELECTs
      BankAccount ba = ((Employee) role).getBankAccount();
    }
  }
}

My goal is to iterate over all roles and retrieve all BankAccounts in a single SELECT. I guess the problem is, that BankAccount has no ForeignKey of its Employee. With Hibernate it works though. Oh, by the way, I am not able to change the mapping to bidirectional anymore!

Any help is more than appeciated!
Thanks
Mario
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users




Back to the top